summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp7
-rw-r--r--core/launcher/qprocess_unix.cpp6
-rw-r--r--core/launcher/server.cpp13
-rw-r--r--core/settings/launcher/menusettings.cpp5
-rw-r--r--core/settings/launcher/taskbarsettings.cpp13
-rw-r--r--libopie2/opiecore/oglobal.cpp2
-rw-r--r--libopie2/opiecore/oprocess.cpp2
-rw-r--r--library/global.cpp5
-rw-r--r--noncore/apps/advancedfm/output.cpp5
-rw-r--r--noncore/apps/tinykate/libkate/document/katebuffer.cpp5
-rw-r--r--noncore/settings/usermanager/userdialog.cpp5
11 files changed, 47 insertions, 21 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 759e440..61beac5 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -574,203 +574,204 @@ void TextEdit::fileOpen() {
QString::null, map);
if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() )
{
openFile( str );
}
else
updateCaption();
}
void TextEdit::doSearchBar() {
if(!useSearchBar)
searchBar->hide();
else
searchBar->show();
}
#if 0
void TextEdit::slotFind() {
FindDialog frmFind( tr("Text Editor"), this );
connect( &frmFind, SIGNAL(signalFindClicked(const QString&,bool,bool,int)),
editor, SLOT(slotDoFind(const QString&,bool,bool)));
//case sensitive, backwards, [category]
connect( editor, SIGNAL(notFound()),
&frmFind, SLOT(slotNotFound()) );
connect( editor, SIGNAL(searchWrapped()),
&frmFind, SLOT(slotWrapAround()) );
frmFind.exec();
}
#endif
void TextEdit::fileRevert() {
clear();
fileOpen();
}
void TextEdit::editCut() {
#ifndef QT_NO_CLIPBOARD
editor->cut();
#endif
}
void TextEdit::editCopy() {
#ifndef QT_NO_CLIPBOARD
editor->copy();
#endif
}
void TextEdit::editPaste() {
#ifndef QT_NO_CLIPBOARD
editor->paste();
#endif
}
void TextEdit::editFind() {
searchBar->show();
searchEdit->setFocus();
}
void TextEdit::findNext() {
editor->find( searchEdit->text(), false, false );
}
void TextEdit::findClose() {
searchBar->hide();
}
void TextEdit::search() {
editor->find( searchEdit->text(), false, false );
}
void TextEdit::newFile( const DocLnk &f ) {
DocLnk nf = f;
nf.setType("text/plain");
clear();
setWState (WState_Reserved1 );
editor->setFocus();
doc = new DocLnk(nf);
currentFileName = "Unnamed";
odebug << "newFile "+currentFileName << oendl;
updateCaption( currentFileName);
// editor->setEdited( false);
}
void TextEdit::openDotFile( const QString &f ) {
if(!currentFileName.isEmpty()) {
currentFileName=f;
odebug << "openFile dotfile " + currentFileName << oendl;
QString txt;
QFile file(f);
- file.open(IO_ReadWrite);
+ if (!file.open(IO_ReadWrite))
+ owarn << "Failed to open file " << file.name() << oendl;
+ else {
QTextStream t(&file);
while ( !t.atEnd()) {
txt+=t.readLine()+"\n";
}
editor->setText(txt);
editor->setEdited( false);
edited1=false;
edited=false;
-
-
+ }
}
updateCaption( currentFileName);
}
void TextEdit::openFile( const QString &f ) {
odebug << "filename is "+ f << oendl;
QString filer;
QFileInfo fi( f);
// bFromDocView = true;
if(f.find(".desktop",0,true) != -1 && !openDesktop )
{
switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) )
{
case 0: //desktop
filer = f;
break;
case 1: //linked
DocLnk sf(f);
filer = sf.file();
break;
};
}
else if(fi.baseName().left(1) == "")
{
odebug << "opening dotfile" << oendl;
currentFileName=f;
openDotFile(currentFileName);
return;
}
/*
* The problem is a file where Config(f).isValid() and it does not
* end with .desktop will be treated as desktop file
*/
else if (f.find(".desktop",0,true) != -1 )
{
DocLnk sf(f);
filer = sf.file();
if(filer.right(1) == "/")
filer = f;
}
else
filer = f;
DocLnk nf;
nf.setType("text/plain");
nf.setFile(filer);
currentFileName=filer;
nf.setName(fi.baseName());
openFile(nf);
odebug << "openFile string "+currentFileName << oendl;
showEditTools();
// Show filename in caption
QString name = filer;
int sep = name.findRev( '/' );
if ( sep > 0 )
name = name.mid( sep+1 );
updateCaption( name );
}
void TextEdit::openFile( const DocLnk &f ) {
// clear();
// bFromDocView = true;
FileManager fm;
QString txt;
currentFileName=f.file();
odebug << "openFile doclnk " + currentFileName << oendl;
if ( !fm.loadFile( f, txt ) ) {
// ####### could be a new file
odebug << "Cannot open file" << oendl;
}
// fileNew();
if ( doc )
delete doc;
doc = new DocLnk(f);
editor->setText(txt);
editor->setEdited( false);
edited1=false;
edited=false;
doc->setName(currentFileName);
updateCaption();
setTimer();
}
void TextEdit::showEditTools() {
menu->show();
editBar->show();
if(!useSearchBar)
searchBar->hide();
else
searchBar->show();
setWState (WState_Reserved1 );
diff --git a/core/launcher/qprocess_unix.cpp b/core/launcher/qprocess_unix.cpp
index 97c0460..3125bcc 100644
--- a/core/launcher/qprocess_unix.cpp
+++ b/core/launcher/qprocess_unix.cpp
@@ -220,193 +220,197 @@ QProcessManager::QProcessManager()
this, SLOT(sigchldHnd(int)) );
sn->setEnabled( TRUE );
}
// install a SIGCHLD handler and ignore SIGPIPE
struct sigaction act;
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessManager: install a SIGCHLD handler" << oendl;
#endif
act.sa_handler = qt_C_sigchldHnd;
sigemptyset( &(act.sa_mask) );
sigaddset( &(act.sa_mask), SIGCHLD );
act.sa_flags = SA_NOCLDSTOP;
#if defined(SA_RESTART)
act.sa_flags |= SA_RESTART;
#endif
if ( sigaction( SIGCHLD, &act, &oldactChld ) != 0 )
owarn << "Error installing SIGCHLD handler" << oendl;
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessManager: install a SIGPIPE handler (SIG_IGN)" << oendl;
#endif
/*
Using qt_C_sigpipeHnd rather than SIG_IGN is a workaround
for a strange problem where GNU tar (called by backuprestore)
would hang on filesystem-full. Strangely, the qt_C_sigpipeHnd
is never even called, yet this avoids the hang.
*/
act.sa_handler = qt_C_sigpipeHnd;
sigemptyset( &(act.sa_mask) );
sigaddset( &(act.sa_mask), SIGPIPE );
act.sa_flags = 0;
if ( sigaction( SIGPIPE, &act, &oldactPipe ) != 0 )
owarn << "Error installing SIGPIPE handler" << oendl;
}
QProcessManager::~QProcessManager()
{
delete procList;
if ( sigchldFd[0] != 0 )
::close( sigchldFd[0] );
if ( sigchldFd[1] != 0 )
::close( sigchldFd[1] );
// restore SIGCHLD handler
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessManager: restore old sigchild handler" << oendl;
#endif
if ( sigaction( SIGCHLD, &oldactChld, 0 ) != 0 )
owarn << "Error restoring SIGCHLD handler" << oendl;
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessManager: restore old sigpipe handler" << oendl;
#endif
if ( sigaction( SIGPIPE, &oldactPipe, 0 ) != 0 )
owarn << "Error restoring SIGPIPE handler" << oendl;
}
void QProcessManager::append( QProc *p )
{
procList->append( p );
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessManager: append process (procList.count(): " << procList->count() << ")" << oendl;
#endif
}
void QProcessManager::remove( QProc *p )
{
procList->remove( p );
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessManager: remove process (procList.count(): " << procList->count() << ")" << oendl;
#endif
cleanup();
}
void QProcessManager::cleanup()
{
if ( procList->count() == 0 ) {
QTimer::singleShot( 0, this, SLOT(removeMe()) );
}
}
void QProcessManager::removeMe()
{
if ( procList->count() == 0 ) {
qprocess_cleanup_procmanager.remove( &QProcessPrivate::procManager );
QProcessPrivate::procManager = 0;
delete this;
}
}
void QProcessManager::sigchldHnd( int fd )
{
char tmp;
- ::read( fd, &tmp, sizeof(tmp) );
+ if (::read( fd, &tmp, sizeof(tmp) ) < 0)
+#if defined(QT_QPROCESS_DEBUG)
+ odebug << "QProcessManager::sigchldHnd() failed dummy read of file descriptor" << oendl;
+#endif
+ ;
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessManager::sigchldHnd()" << oendl;
#endif
QProc *proc;
QProcess *process;
bool removeProc;
proc = procList->first();
while ( proc != 0 ) {
removeProc = FALSE;
process = proc->process;
QProcess *process_exit_notify=0;
if ( process != 0 ) {
if ( !process->isRunning() ) {
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): process exited (QProcess available)" << oendl;
#endif
// read pending data
int nbytes = 0;
if ( ::ioctl(proc->socketStdout, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) {
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): reading " << nbytes << " bytes of pending data on stdout" << oendl;
#endif
process->socketRead( proc->socketStdout );
}
nbytes = 0;
if ( ::ioctl(proc->socketStderr, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) {
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): reading " << nbytes << " bytes of pending data on stderr" << oendl;
#endif
process->socketRead( proc->socketStderr );
}
if ( process->notifyOnExit )
process_exit_notify = process;
removeProc = TRUE;
}
} else {
int status;
if ( ::waitpid( proc->pid, &status, WNOHANG ) == proc->pid ) {
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): process exited (QProcess not available)" << oendl;
#endif
removeProc = TRUE;
}
}
if ( removeProc ) {
QProc *oldproc = proc;
proc = procList->next();
remove( oldproc );
} else {
proc = procList->next();
}
if ( process_exit_notify )
emit process_exit_notify->processExited();
}
}
#include "qprocess_unix.moc"
/***********************************************************************
*
* QProcessPrivate
*
**********************************************************************/
QProcessManager *QProcessPrivate::procManager = 0;
QProcessPrivate::QProcessPrivate()
{
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessPrivate: Constructor" << oendl;
#endif
stdinBufRead = 0;
notifierStdin = 0;
notifierStdout = 0;
notifierStderr = 0;
exitValuesCalculated = FALSE;
socketReadCalled = FALSE;
proc = 0;
}
QProcessPrivate::~QProcessPrivate()
{
#if defined(QT_QPROCESS_DEBUG)
odebug << "QProcessPrivate: Destructor" << oendl;
#endif
if ( proc != 0 ) {
if ( proc->socketStdin != 0 ) {
::close( proc->socketStdin );
proc->socketStdin = 0;
}
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp
index 921b790..c45265a 100644
--- a/core/launcher/server.cpp
+++ b/core/launcher/server.cpp
@@ -274,202 +274,210 @@ void Server::activate(const ODeviceButton* button, bool held)
#ifdef Q_WS_QWS
typedef struct KeyOverride {
ushort scan_code;
QWSServer::KeyMap map;
};
static const KeyOverride jp109keys[] = {
{ 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } },
{ 0x07, { Qt::Key_6, '6' , '&' , 0xffff } },
{ 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } },
{ 0x09, { Qt::Key_8, '8' , '(' , 0xffff } },
{ 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } },
{ 0x0b, { Qt::Key_0, '0' , 0xffff, 0xffff } },
{ 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } },
{ 0x0d, { Qt::Key_AsciiCircum, '^' , '~' , '^'-64 } },
{ 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } },
{ 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '['-64 } },
{ 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } },
{ 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } },
{ 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff, 0xffff, 0xffff } },
{ 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } },
{ 0x70, { Qt::Key_Hiragana_Katakana, 0xffff, 0xffff, 0xffff } },
{ 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } },
{ 0x79, { Qt::Key_Henkan, 0xffff, 0xffff, 0xffff } },
{ 0x7b, { Qt::Key_Muhenkan, 0xffff, 0xffff, 0xffff } },
{ 0x7d, { Qt::Key_yen, 0x00a5, '|' , 0xffff } },
{ 0x00, { 0, 0xffff, 0xffff, 0xffff } }
};
bool Server::setKeyboardLayout( const QString &kb )
{
//quick demo version that can be extended
QIntDict<QWSServer::KeyMap> *om = 0;
if ( kb == "us101" ) { // No tr
om = 0;
} else if ( kb == "jp109" ) {
om = new QIntDict<QWSServer::KeyMap>(37);
const KeyOverride *k = jp109keys;
while ( k->scan_code ) {
om->insert( k->scan_code, &k->map );
k++;
}
}
QWSServer::setOverrideKeys( om );
return TRUE;
}
#endif
void Server::systemMsg(const QCString &msg, const QByteArray &data)
{
QDataStream stream( data, IO_ReadOnly );
if ( msg == "securityChanged()" ) {
if ( transferServer )
transferServer->authorizeConnections();
if ( qcopBridge )
qcopBridge->authorizeConnections();
#warning FIXME support TempScreenSaverMode
#if 0
} else if ( msg == "setTempScreenSaverMode(int,int)" ) {
int mode, pid;
stream >> mode >> pid;
tsmMonitor->setTempMode(mode, pid);
#endif
} else if ( msg == "linkChanged(QString)" ) {
QString link;
stream >> link;
odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl;
docList->linkChanged(link);
} else if (msg =="reforceDocuments()") {
docList->reforceDocuments();
} else if ( msg == "serviceChanged(QString)" ) {
MimeType::updateApplications();
} else if ( msg == "mkdir(QString)" ) {
QString dir;
stream >> dir;
if ( !dir.isEmpty() )
mkdir( dir );
} else if ( msg == "rdiffGenSig(QString,QString)" ) {
QString baseFile, sigFile;
stream >> baseFile >> sigFile;
QRsync::generateSignature( baseFile, sigFile );
} else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
QString baseFile, sigFile, deltaFile;
stream >> baseFile >> sigFile >> deltaFile;
QRsync::generateDiff( baseFile, sigFile, deltaFile );
} else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
QString baseFile, deltaFile;
stream >> baseFile >> deltaFile;
+ bool fileWasCreated = false;
if ( !QFile::exists( baseFile ) ) {
QFile f( baseFile );
- f.open( IO_WriteOnly );
+ fileWasCreated = f.open( IO_WriteOnly );
f.close();
}
+ if ( fileWasCreated ) {
QRsync::applyDiff( baseFile, deltaFile );
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
e << baseFile;
#endif
+ } else {
+#ifndef QT_NO_COP
+ QCopEnvelope e( "QPE/Desktop", "patchUnapplied(QString)" );
+ e << baseFile;
+#endif
+ }
} else if ( msg == "rdiffCleanup()" ) {
mkdir( "/tmp/rdiff" );
QDir dir;
dir.setPath( "/tmp/rdiff" );
QStringList entries = dir.entryList();
for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
dir.remove( *it );
} else if ( msg == "sendHandshakeInfo()" ) {
QString home = getenv( "HOME" );
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
e << home;
int locked = (int) ServerApplication::screenLocked();
e << locked;
#endif
} else if ( msg == "sendVersionInfo()" ) {
/*
* @&$*! Qtopiadesktop relies on the major number
* to start with 1. (or 2 as the case of version 2.1 will be)
* we need to fake 1.7 to be able
* to sync with Qtopiadesktop 1.7.
* We'll send it Opie's version in the platform string for now,
* until such time when QD gets rewritten correctly.
*/
QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" );
QString opiename = "Opie "+QString(QPE_VERSION);
QString QDVersion="1.7";
e << QDVersion << opiename;
} else if ( msg == "sendCardInfo()" ) {
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
#endif
storage->update();
const QList<FileSystem> &fs = storage->fileSystems();
QListIterator<FileSystem> it ( fs );
QString s;
QString homeDir = getenv("HOME");
QString homeFs, homeFsPath;
for ( ; it.current(); ++it ) {
int k4 = (*it)->blockSize()/256;
if ( (*it)->isRemovable() ) {
s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr
+ QString::number( (*it)->availBlocks() * k4/4 )
+ "K " + (*it)->options() + ";";
} else if ( homeDir.contains( (*it)->path() ) &&
(*it)->path().length() > homeFsPath.length() ) {
homeFsPath = (*it)->path();
homeFs =
(*it)->name() + "=" + homeDir + "/Documents " // No tr
+ QString::number( (*it)->availBlocks() * k4/4 )
+ "K " + (*it)->options() + ";";
}
}
if ( !homeFs.isEmpty() )
s += homeFs;
#ifndef QT_NO_COP
e << s;
#endif
} else if ( msg == "sendInstallLocations()" ) {
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" );
e << installLocationsString();
#endif
} else if ( msg == "sendSyncDate(QString)" ) {
QString app;
stream >> app;
Config cfg( "qpe" );
cfg.setGroup("SyncDate");
#ifndef QT_NO_COP
QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
e << app << cfg.readEntry( app );
#endif
//odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response "
// << cfg.readEntry( app ).latin1() << oendl;
} else if ( msg == "setSyncDate(QString,QString)" ) {
QString app, date;
stream >> app >> date;
Config cfg( "qpe" );
cfg.setGroup("SyncDate");
cfg.writeEntry( app, date );
//odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl;
} else if ( msg == "startSync(QString)" ) {
QString what;
stream >> what;
delete syncDialog;
syncDialog = new SyncDialog( this, what );
syncDialog->show();
connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) );
} else if ( msg == "stopSync()") {
delete syncDialog;
syncDialog = 0;
} else if (msg == "restoreDone(QString)") {
docList->restoreDone();
} else if ( msg == "getAllDocLinks()" ) {
@@ -905,102 +913,103 @@ void Server::desktopMessage( const QCString &message, const QByteArray &data )
}
if ( qrr && qrr->waitingForMessages )
qrr->desktopMessage( message, data );
}
// This is only connected if QPE_HAVE_DIRECT_ACCESS is defined
void Server::runDirectAccess()
{
#ifdef QPE_HAVE_DIRECT_ACCESS
// The timer must have fired after all the apps responded
// with flushDone(). Just ignore it.
if ( directAccessRun )
return;
directAccessRun = TRUE;
::readyDirectAccess(cardInfoString(), installLocationsString());
#endif
}
// This is only called if QPE_HAVE_DIRECT_ACCESS is defined
void Server::postDirectAccess()
{
#ifdef QPE_HAVE_DIRECT_ACCESS
qDebug( "Server::postDirectAccess()" );
// Categories may have changed
QCopEnvelope e1( "QPE/System", "categoriesChanged()" );
// Apps need to reload their data
QCopEnvelope e2( "QPE/System", "reload()" );
// Reload DocLinks
docList->storageChanged();
// Restart the PDA server stuff
startTransferServer();
// restart the mtab monitor
#ifndef QT_NO_COP
{
QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" );
}
#endif
// Process queued requests
const char *queueFile = ::directAccessQueueFile();
QFile *file = new QFile( queueFile );
if ( !file->exists() ) {
delete file;
// Get rid of the dialog
if ( syncDialog ) {
delete syncDialog;
syncDialog = 0;
}
#warning FIXME support TempScreenSaverMode
#if 0
QPEApplication::setTempScreenSaverMode(QPEApplication::Enable);
#endif
} else {
qrr = new QueuedRequestRunner( file, syncDialog );
connect( qrr, SIGNAL(finished()),
this, SLOT(finishedQueuedRequests()) );
QTimer::singleShot( 100, qrr, SLOT(process()) );
// qrr will remove the sync dialog later
}
#endif
}
void Server::finishedQueuedRequests()
{
if ( qrr->readyToDelete ) {
delete qrr;
qrr = 0;
// Get rid of the dialog
if ( syncDialog ) {
delete syncDialog;
syncDialog = 0;
}
#warning FIXME support TempScreenSaverMode
#if 0
QPEApplication::setTempScreenSaverMode(QPEApplication::Enable);
#endif
} else {
qrr->readyToDelete = TRUE;
QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) );
}
}
void Server::startSoundServer() {
if ( !process ) {
process = new Opie::Core::OProcess( this );
connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
SLOT(soundServerExited()));
}
process->clearArguments();
*process << QPEApplication::qpeDir() + "bin/qss";
- process->start();
+ if (!process->start())
+ owarn << "Sound server process did not start" << oendl;
}
void Server::soundServerExited() {
QTimer::singleShot(5000, this, SLOT(startSoundServer()));
}
diff --git a/core/settings/launcher/menusettings.cpp b/core/settings/launcher/menusettings.cpp
index 29ce841..d63b203 100644
--- a/core/settings/launcher/menusettings.cpp
+++ b/core/settings/launcher/menusettings.cpp
@@ -1,178 +1,181 @@
/*
This file is part of the OPIE Project
=. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
.=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
.>+-=
_;:, .> :=|. This file is free software; you can
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This file is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.= = ; Public License for more details.
++= -. .` .:
: = ...= . :.=- You should have received a copy of the GNU
-. .:....=;==+<; General Public License along with this file;
-_. . . )=. = see the file COPYING. If not, write to the
-- :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "menusettings.h"
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/qpeapplication.h>
#include <qpe/menuappletinterface.h>
#include <qpe/qcopenvelope_qws.h>
+#include <opie2/odebug.h>
#include <qdir.h>
#include <qlistview.h>
#include <qcheckbox.h>
#include <qheader.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qwhatsthis.h>
#include <stdlib.h>
MenuSettings::MenuSettings ( QWidget *parent, const char *name )
: QWidget ( parent, name )
{
m_applets_changed = false;
QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
QLabel *l = new QLabel ( tr( "Load applets in O-Menu:" ), this );
lay-> addWidget ( l );
m_list = new QListView ( this );
m_list-> addColumn ( "foobar" );
m_list-> header ( )-> hide ( );
lay-> addWidget ( m_list );
m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this );
lay-> addWidget ( m_menutabs );
m_menusubpopup = new QCheckBox ( tr( "Show Applications in Subpopups" ), this );
lay-> addWidget ( m_menusubpopup );
QWhatsThis::add ( m_list, tr( "Check the applets that you want to have included in the O-Menu." ));
QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher Tabs as menus in the O-Menu." ));
connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged()));
init ( );
}
void MenuSettings::init ( )
{
Config cfg ( "StartMenu" );
cfg. setGroup ( "Applets" );
QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' );
QString path = QPEApplication::qpeDir ( ) + "plugins/applets";
#ifdef Q_OS_MACX
QStringList list = QDir ( path, "lib*.dylib" ). entryList ( );
#else
QStringList list = QDir ( path, "lib*.so" ). entryList ( );
#endif /* Q_OS_MACX */
for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
QString name;
QPixmap icon;
MenuAppletInterface *iface = 0;
QLibrary *lib = new QLibrary ( path + "/" + *it );
- lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface );
+ QRESULT retVal = QS_OK;
+ if ((retVal = lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**)(&iface) )) != QS_OK )
+ owarn << "queryInterface failed with " << retVal << oendl;
if ( iface ) {
QString lang = getenv( "LANG" );
QTranslator *trans = new QTranslator ( qApp );
QString type = (*it). left ((*it). find ("."));
QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm";
if ( trans-> load ( tfn ))
qApp-> installTranslator ( trans );
else
delete trans;
name = iface-> name ( );
icon = iface-> icon ( ). pixmap ();
iface-> release ( );
lib-> unload ( );
QCheckListItem *item;
item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
if ( !icon. isNull ( ))
item-> setPixmap ( 0, icon );
item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
m_applets [*it] = item;
} else {
delete lib;
}
}
cfg. setGroup ( "Menu" );
m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) );
m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) );
m_menusubpopup->setEnabled( m_menutabs->isChecked() );
connect( m_menutabs, SIGNAL( stateChanged(int) ), m_menusubpopup, SLOT( setEnabled(bool) ) );
}
void MenuSettings::appletChanged()
{
m_applets_changed = true;
}
void MenuSettings::accept ( )
{
bool apps_changed = false;
Config cfg ( "StartMenu" );
cfg. setGroup ( "Applets" );
if ( m_applets_changed ) {
QStringList exclude;
QMap <QString, QCheckListItem *>::Iterator it;
for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) {
if ( !(*it)-> isOn ( ))
exclude << it. key ( );
}
cfg. writeEntry ( "ExcludeApplets", exclude, ',' );
}
cfg. writeEntry ( "SafeMode", false );
cfg. setGroup ( "Menu" );
if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) {
apps_changed = true;
cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( ));
}
if ( m_menusubpopup-> isChecked ( ) != cfg. readBoolEntry ( "LauncherSubPopup", true )) {
apps_changed = true;
cfg. writeEntry ( "LauncherSubPopup", m_menusubpopup-> isChecked ( ));
}
cfg. write ( );
if ( m_applets_changed ) {
QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
m_applets_changed = false;
}
if ( apps_changed ) {
// currently use reloadApplets() since reloadApps is now used exclusive for server
// to refresh the tabs. But what we want here is also a refresh of the startmenu entries
QCopEnvelope ( "QPE/TaskBar", "reloadApps()" );
QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
}
}
diff --git a/core/settings/launcher/taskbarsettings.cpp b/core/settings/launcher/taskbarsettings.cpp
index 861ff3a..c2b82b9 100644
--- a/core/settings/launcher/taskbarsettings.cpp
+++ b/core/settings/launcher/taskbarsettings.cpp
@@ -1,176 +1,179 @@
/*
                This file is part of the OPIE Project
=. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
           .>+-=
 _;:,     .>    :=|. This file is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This file is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
..}^=.=       =       ; Public License for more details.
++=   -.     .`     .:
 :     =  ...= . :.=- You should have received a copy of the GNU
 -.   .:....=;==+<; General Public License along with this file;
  -_. . .   )=.  = see the file COPYING. If not, write to the
    --        :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "taskbarsettings.h"
/* OPIE */
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/qpeapplication.h>
#include <qpe/taskbarappletinterface.h>
#include <qpe/qcopenvelope_qws.h>
#include <opie2/odebug.h>
/* QT */
#include <qdir.h>
#include <qlistview.h>
#include <qheader.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qwhatsthis.h>
/* STD */
#include <stdlib.h>
TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name )
: QWidget ( parent, name )
{
m_applets_changed = false;
QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this );
lay-> addWidget ( l );
m_list = new QListView ( this );
m_list-> addColumn ( "foobar" );
m_list-> header ( )-> hide ( );
lay-> addWidget ( m_list );
QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." ));
connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged()));
init ( );
}
void TaskbarSettings::init ( )
{
Config cfg ( "Taskbar" );
cfg. setGroup ( "Applets" );
QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' );
QString path = QPEApplication::qpeDir ( ) + "plugins/applets";
#ifdef Q_OS_MACX
QStringList list = QDir ( path, "lib*.dylib" ). entryList ( );
#else
QStringList list = QDir ( path, "lib*.so" ). entryList ( );
#endif /* Q_OS_MACX */
for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
QString name;
QPixmap icon;
TaskbarNamedAppletInterface *iface = 0;
owarn << "Load applet: " << (*it) << "" << oendl;
QLibrary *lib = new QLibrary ( path + "/" + *it );
- lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface );
+ QRESULT retVal = QS_OK;
+ if ((retVal = lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**)(&iface) )) != QS_OK)
+ owarn << "<0>" << oendl;
owarn << "<1>" << oendl;
if ( iface ) {
owarn << "<2>" << oendl;
QString lang = getenv( "LANG" );
QTranslator *trans = new QTranslator ( qApp );
QString type = (*it). left ((*it). find ("."));
QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm";
if ( trans-> load ( tfn ))
qApp-> installTranslator ( trans );
else
delete trans;
name = iface-> name ( );
icon = iface-> icon ( );
iface-> release ( );
}
owarn << "<3>" << oendl;
if ( !iface ) {
owarn << "<4>" << oendl;
- lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface );
+ if ((retVal = lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**)(&iface))) != QS_OK)
+ owarn << "<5>" << oendl;
if ( iface ) {
- owarn << "<5>" << oendl;
+ owarn << "<6>" << oendl;
name = (*it). mid ( 3 );
owarn << "Found applet: " << name << "" << oendl;
#ifdef Q_OS_MACX
int sep = name. find( ".dylib" );
#else
int sep = name. find( ".so" );
#endif /* Q_OS_MACX */
if ( sep > 0 )
name. truncate ( sep );
sep = name. find ( "applet" );
if ( sep == (int) name.length ( ) - 6 )
name. truncate ( sep );
name[0] = name[0]. upper ( );
iface-> release ( );
}
}
- owarn << "<6>" << oendl;
+ owarn << "<7>" << oendl;
if ( iface ) {
- owarn << "<7>" << oendl;
+ owarn << "<8>" << oendl;
QCheckListItem *item;
item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
if ( !icon. isNull ( ))
item-> setPixmap ( 0, icon );
item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
m_applets [*it] = item;
}
lib-> unload ( );
delete lib;
}
}
void TaskbarSettings::appletChanged()
{
m_applets_changed = true;
}
void TaskbarSettings::accept ( )
{
Config cfg ( "Taskbar" );
cfg. setGroup ( "Applets" );
if ( m_applets_changed ) {
QStringList exclude;
QMap <QString, QCheckListItem *>::Iterator it;
for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) {
if ( !(*it)-> isOn ( ))
exclude << it. key ( );
}
cfg. writeEntry ( "ExcludeApplets", exclude, ',' );
}
cfg. writeEntry ( "SafeMode", false );
cfg. write ( );
if ( m_applets_changed ) {
QCopEnvelope e ( "QPE/TaskBar", "reloadApplets()" );
m_applets_changed = false;
}
}
diff --git a/libopie2/opiecore/oglobal.cpp b/libopie2/opiecore/oglobal.cpp
index 706ac6c..b7d59fc 100644
--- a/libopie2/opiecore/oglobal.cpp
+++ b/libopie2/opiecore/oglobal.cpp
@@ -251,172 +251,172 @@ QByteArray OGlobal::decodeBase64( const QByteArray& in) {
// Deal with possible *nix "BEGIN" marker!!
while ( count < len && (data[count] == '\n' || data[count] == '\r' ||
data[count] == '\t' || data[count] == ' ') )
count++;
if ( strncasecmp(data+count, "begin", 5) == 0 )
{
count += 5;
while ( count < len && data[count] != '\n' && data[count] != '\r' )
count++;
while ( count < len && (data[count] == '\n' || data[count] == '\r') )
count ++;
data += count;
tail = (len -= count);
}
// Find the tail end of the actual encoded data even if
// there is/are trailing CR and/or LF.
while ( data[tail-1] == '=' || data[tail-1] == '\n' ||
data[tail-1] == '\r' )
if ( data[--tail] != '=' ) len = tail;
unsigned int outIdx = 0;
out.resize( (count=len) );
for (unsigned int idx = 0; idx < count; idx++)
{
// Adhere to RFC 2045 and ignore characters
// that are not part of the encoding table.
unsigned char ch = data[idx];
if ( (ch > 47 && ch < 58) || (ch > 64 && ch < 91 ) ||
(ch > 96 && ch < 123)|| ch == '+' || ch == '/' || ch == '=')
{
out[outIdx++] = Base64DecMap[ch];
}
else
{
len--;
tail--;
}
}
// kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl;
// 4-byte to 3-byte conversion
len = (tail>(len/4)) ? tail-(len/4) : 0;
unsigned int sidx = 0, didx = 0;
if ( len > 1 )
{
while (didx < len-2)
{
out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077));
sidx += 4;
didx += 3;
}
}
if (didx < len)
out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
if (++didx < len )
out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
// Resize the output buffer
if ( len == 0 || len < out.size() )
out.resize(len);
return out;
}
bool OGlobal::isAppLnkFileName( const QString& str )
{
if (str.isEmpty()||str.at(str.length()-1)==QDir::separator()) return false;
return str.startsWith(MimeType::appsFolderName()+QDir::separator());
}
/* ToDo:
* This fun should check the document-path value for the mounted media
* which has to be implemented later. this moment we just check for a
* mounted media name.
*/
bool OGlobal::isDocumentFileName( const QString& file )
{
if (file.isEmpty()||file.at(file.length()-1)==QDir::separator()) return false;
if (file.startsWith(QPEApplication::documentDir()+QDir::separator())) return true;
StorageInfo si;
QList< FileSystem > fl = si.fileSystems();
FileSystem*fs;
for (fs = fl.first();fs!=0;fs=fl.next()) {
if (fs->isRemovable()&&file.startsWith(fs->name()+QDir::separator()))
return true;
}
- if (file.startsWith(homeDirPath())+"/Documents/") return true;
+ if (file.startsWith(homeDirPath()+"/Documents/")) return true;
return false;
}
QString OGlobal::tempDirPath()
{
static QString defstring="/tmp";
char * tmpp = 0;
if ( (tmpp=getenv("TEMP"))) {
return tmpp;
}
return defstring;
}
QString OGlobal::homeDirPath()
{
char * tmpp = getenv("HOME");
return (tmpp?tmpp:"/");
}
bool OGlobal::weekStartsOnMonday()
{
OConfig*conf=OGlobal::qpe_config();
if (!conf)return false;
conf->setGroup("Time");
return conf->readBoolEntry("MONDAY",true);
}
void OGlobal::setWeekStartsOnMonday( bool what)
{
OConfig*conf=OGlobal::qpe_config();
if (!conf)return;
conf->setGroup("Time");
return conf->writeEntry("MONDAY",what);
}
bool OGlobal::useAMPM()
{
OConfig*conf=OGlobal::qpe_config();
if (!conf)return false;
conf->setGroup("Time");
return conf->readBoolEntry("AMPM",false);
}
void OGlobal::setUseAMPM( bool what)
{
OConfig*conf=OGlobal::qpe_config();
if (!conf)return;
conf->setGroup("Time");
return conf->writeEntry("AMPM",what);
}
OConfig* OGlobal::qpe_config()
{
if ( !OGlobal::_qpe_config ) {
OGlobal::_qpe_config = new OConfig( "qpe" );
}
return OGlobal::_qpe_config;
}
bool OGlobal::truncateFile( QFile &f, off_t size )
{
/* or should we let enlarge Files? then remove this
f.size()< part! - Alwin
*/
if (!f.exists()||f.size()<(unsigned)size) return false;
bool closeit=false;
if (!f.isOpen()) {
closeit=true;
f.open(IO_Raw | IO_ReadWrite | IO_Append);
}
if (!f.isOpen()) { return false; }
int r = ftruncate(f.handle(),size);
if (closeit) f.close();
return r==0;
}
diff --git a/libopie2/opiecore/oprocess.cpp b/libopie2/opiecore/oprocess.cpp
index b3f9724..56f9883 100644
--- a/libopie2/opiecore/oprocess.cpp
+++ b/libopie2/opiecore/oprocess.cpp
@@ -835,117 +835,117 @@ void OProcess::commClose()
}
if ( b_in )
{
communication = ( Communication ) ( communication & ~Stdin );
close( in[ 1 ] );
}
if ( b_out )
{
communication = ( Communication ) ( communication & ~Stdout );
close( out[ 0 ] );
}
if ( b_err )
{
communication = ( Communication ) ( communication & ~Stderr );
close( err[ 0 ] );
}
}
}
void OProcess::setUseShell( bool useShell, const char *shell )
{
if ( !d )
d = new OProcessPrivate;
d->useShell = useShell;
d->shell = shell;
if ( d->shell.isEmpty() )
d->shell = searchShell();
}
QString OProcess::quote( const QString &arg )
{
QString res = arg;
res.replace( QRegExp( QString::fromLatin1( "\'" ) ),
QString::fromLatin1( "'\"'\"'" ) );
res.prepend( '\'' );
res.append( '\'' );
return res;
}
QCString OProcess::searchShell()
{
QCString tmpShell = QCString( getenv( "SHELL" ) ).stripWhiteSpace();
if ( !isExecutable( tmpShell ) )
{
tmpShell = "/bin/sh";
}
return tmpShell;
}
bool OProcess::isExecutable( const QCString &filename )
{
struct stat fileinfo;
if ( filename.isEmpty() )
return false;
// CC: we've got a valid filename, now let's see whether we can execute that file
if ( -1 == stat( filename.data(), &fileinfo ) )
return false;
// CC: return false if the file does not exist
// CC: anyway, we cannot execute directories, block/character devices, fifos or sockets
if ( ( S_ISDIR( fileinfo.st_mode ) ) ||
( S_ISCHR( fileinfo.st_mode ) ) ||
( S_ISBLK( fileinfo.st_mode ) ) ||
#ifdef S_ISSOCK
// CC: SYSVR4 systems don't have that macro
( S_ISSOCK( fileinfo.st_mode ) ) ||
#endif
( S_ISFIFO( fileinfo.st_mode ) ) ||
( S_ISDIR( fileinfo.st_mode ) ) )
{
return false;
}
// CC: now check for permission to execute the file
if ( access( filename.data(), X_OK ) != 0 )
return false;
// CC: we've passed all the tests...
return true;
}
int OProcess::processPID( const QString& process )
{
QString line;
QDir d = QDir( "/proc" );
QStringList dirs = d.entryList( QDir::Dirs );
QStringList::Iterator it;
for ( it = dirs.begin(); it != dirs.end(); ++it )
{
//qDebug( "next entry: %s", (const char*) *it );
QFile file( "/proc/"+*it+"/cmdline" );
- file.open( IO_ReadOnly );
+ if ( !file.open( IO_ReadOnly ) ) continue;
if ( !file.isOpen() ) continue;
QTextStream t( &file );
line = t.readLine();
//qDebug( "cmdline = %s", (const char*) line );
if ( line.contains( process ) ) break; //FIXME: That may find also other process, if the name is not long enough ;)
}
if ( line.contains( process ) )
{
//qDebug( "found process id #%d", (*it).toInt() );
return (*it).toInt();
}
else
{
//qDebug( "process '%s' not found", (const char*) process );
return 0;
}
}
}
}
diff --git a/library/global.cpp b/library/global.cpp
index f7a0767..7bdd0b1 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -149,200 +149,199 @@ static QString dictDir()
\class Global global.h
\brief The Global class provides application-wide global functions.
The Global functions are grouped as follows:
\tableofcontents
\section1 User Interface
The statusMessage() function provides short-duration messages to the
user. The showInputMethod() function shows the current input method,
and hideInputMethod() hides the input method.
\section1 Document related
The findDocuments() function creates a set of \link doclnk.html
DocLnk\endlink objects in a particular folder.
\section1 Filesystem related
Global provides an applicationFileName() function that returns the
full path of an application-specific file.
The execute() function runs an application.
\section1 Word list related
A list of words relevant to the current locale is maintained by the
system. The list is held in a \link qdawg.html DAWG\endlink
(implemented by the QDawg class). This list is used, for example, by
the pickboard input method.
The global QDawg is returned by fixedDawg(); this cannot be updated.
An updatable copy of the global QDawg is returned by addedDawg().
Applications may have their own word lists stored in \l{QDawg}s
which are returned by dawg(). Use addWords() to add words to the
updateable copy of the global QDawg or to named application
\l{QDawg}s.
\section1 Quoting
The shellQuote() function quotes a string suitable for passing to a
shell. The stringQuote() function backslash escapes '\' and '"'
characters.
\section1 Hardware
The implementation of the writeHWClock() function depends on the AlarmServer
implementation. If the AlarmServer is using atd the clock will be synced to
hardware. If opie-alarm is used the hardware clock will be synced before
suspending the device. opie-alarm is used by iPAQ and Zaurii implementation
\ingroup qtopiaemb
*/
/*!
\internal
*/
Global::Global()
{
}
/*!
Returns the unchangeable QDawg that contains general
words for the current locale.
\sa addedDawg()
*/
const QDawg& Global::fixedDawg()
{
if ( !fixed_dawg ) {
if ( !docDirCreated )
createDocDir();
fixed_dawg = new QDawg;
QString dawgfilename = dictDir() + "/dawg";
QString words_lang;
QStringList langs = Global::languageList();
for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
QString lang = *it;
words_lang = dictDir() + "/words." + lang;
QString dawgfilename_lang = dawgfilename + "." + lang;
if ( QFile::exists(dawgfilename_lang) ||
QFile::exists(words_lang) ) {
dawgfilename = dawgfilename_lang;
break;
}
}
QFile dawgfile(dawgfilename);
if ( !dawgfile.exists() ) {
QString fn = dictDir() + "/words";
if ( QFile::exists(words_lang) )
fn = words_lang;
QFile in(fn);
if ( in.open(IO_ReadOnly) ) {
fixed_dawg->createFromWords(&in);
- dawgfile.open(IO_WriteOnly);
+ if (dawgfile.open(IO_WriteOnly))
fixed_dawg->write(&dawgfile);
dawgfile.close();
}
- } else {
+ } else
fixed_dawg->readFile(dawgfilename);
}
- }
return *fixed_dawg;
}
/*!
Returns the changeable QDawg that contains general
words for the current locale.
\sa fixedDawg()
*/
const QDawg& Global::addedDawg()
{
return dawg("local");
}
/*!
Returns the QDawg with the given \a name.
This is an application-specific word list.
\a name should not contain "/".
*/
const QDawg& Global::dawg(const QString& name)
{
createDocDir();
if ( !named_dawg )
named_dawg = new QDict<QDawg>;
QDawg* r = named_dawg->find(name);
if ( !r ) {
r = new QDawg;
named_dawg->insert(name,r);
QString dawgfilename = applicationFileName("Dictionary", name ) + ".dawg";
QFile dawgfile(dawgfilename);
if ( dawgfile.open(IO_ReadOnly) )
r->readFile(dawgfilename);
}
return *r;
}
/*!
\overload
Adds \a wordlist to the addedDawg().
Note that the addition of words persists between program executions
(they are saved in the dictionary files), so you should confirm the
words with the user before adding them.
*/
void Global::addWords(const QStringList& wordlist)
{
addWords("local",wordlist);
}
/*!
\overload
Adds \a wordlist to the addedDawg().
Note that the addition of words persists between program executions
(they are saved in the dictionary files), so you should confirm the
words with the user before adding them.
*/
void Global::addWords(const QString& dictname, const QStringList& wordlist)
{
QDawg& d = (QDawg&)dawg(dictname);
QStringList all = d.allWords() + wordlist;
d.createFromWords(all);
QString dawgfilename = applicationFileName("Dictionary", dictname) + ".dawg";
QFile dawgfile(dawgfilename);
if ( dawgfile.open(IO_WriteOnly) ) {
d.write(&dawgfile);
dawgfile.close();
}
// #### Re-read the dawg here if we use mmap().
// #### Signal other processes to re-read.
}
/*!
Returns the full path for the application called \a appname, with the
given \a filename. Returns QString::null if there was a problem creating
the directory tree for \a appname.
If \a filename contains "/", it is the caller's responsibility to
ensure that those directories exist.
*/
QString Global::applicationFileName(const QString& appname, const QString& filename)
{
QDir d;
QString r = getenv("HOME");
r += "/Applications/";
if ( !QFile::exists( r ) )
if ( d.mkdir(r) == false )
return QString::null;
r += appname;
if ( !QFile::exists( r ) )
if ( d.mkdir(r) == false )
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
index 8c585f4..8f654d5 100644
--- a/noncore/apps/advancedfm/output.cpp
+++ b/noncore/apps/advancedfm/output.cpp
@@ -99,183 +99,184 @@ static char * filesave_xpm[] = {
"I c #404040",
"J c #858585",
"K c #323232",
"L c #D0D0D0",
"M c #1C1C1C",
" ...+ ",
" @#$%&..+ ",
" .*=-;;>,..+ ",
" ')!~;;;;;;{]..",
" ^/(-;;;;;;;_:<",
" [}|;;;;;;;{12$",
" #34-55;;;;678$+",
" 90ab=c;dd;e1fg ",
" [ahij((kbl0mn$ ",
" op^q^^7r&]s/$+ ",
"@btu;vbwxy]zAB ",
"CzDEvEv;;DssF$ ",
"G.H{E{E{IxsJ$+ ",
" +...vEKxzLM ",
" +...z]n$ ",
" +... "};
Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl)
: QDialog( parent, name, modal, fl )
{
QStringList cmmds;
// cmmds=QStringList::split( " ", commands, false);
cmmds=commands;
// odebug << "count " << cmmds.count() << "" << oendl;
if ( !name )
setName( tr("Output"));
resize( 196, 269 );
setCaption( name );
OutputLayout = new QGridLayout( this );
OutputLayout->setSpacing( 2);
OutputLayout->setMargin( 2);
QPushButton *docButton;
docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton");
docButton->setFixedSize( QSize( 20, 20 ) );
connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() ));
// docButton->setFlat(TRUE);
OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 );
OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 );
proc = new OProcess();
connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)),
this, SLOT( processFinished()));
connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)),
this, SLOT(commandStdout(Opie::Core::OProcess*,char*,int)));
connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),
this, SLOT(commandStderr(Opie::Core::OProcess*,char*,int)));
// connect( , SIGNAL(received(const QByteArray&)),
// this, SLOT(commandStdin(const QByteArray&)));
// * proc << commands.latin1();
for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) {
odebug << "" << (*it).latin1() << "" << oendl;
* proc << (*it).latin1();
}
if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) {
OutputEdit->append(tr("Process could not start") );
OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
perror("Error: ");
QString errorMsg=tr("Error\n")+(QString)strerror(errno);
OutputEdit->append( errorMsg);
OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
}
}
Output::~Output() {
}
void Output::saveOutput() {
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = QPEApplication::documentDir();
if(filename.right(1).find('/') == -1)
filename+="/";
QString name = fileDlg->LineEdit1->text();
filename+="text/plain/"+name;
odebug << filename << oendl;
QFile f(filename);
- f.open( IO_WriteOnly);
- if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) {
+ if ( !f.open( IO_WriteOnly ) )
+ owarn << "Could no open file" << oendl;
+ else if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) {
DocLnk lnk;
lnk.setName(name); //sets file name
lnk.setFile(filename); //sets File property
lnk.setType("text/plain");
if(!lnk.writeLink()) {
odebug << "Writing doclink did not work" << oendl;
}
} else
owarn << "Could not write file" << oendl;
f.close();
}
}
void Output::commandStdout(OProcess*, char *buffer, int buflen) {
owarn << "received stdout " << buflen << " bytes" << oendl;
// QByteArray data(buflen);
// data.fill(*buffer, buflen);
// for (uint i = 0; i < data.count(); i++ ) {
// printf("%c", buffer[i] );
// }
// printf("\n");
QString lineStr = buffer;
lineStr=lineStr.left(lineStr.length()-1);
OutputEdit->append(lineStr);
OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
}
void Output::commandStdin( const QByteArray &data) {
owarn << "received stdin " << data.size() << " bytes" << oendl;
// recieved data from the io layer goes to sz
proc->writeStdin(data.data(), data.size());
}
void Output::commandStderr(OProcess*, char *buffer, int buflen) {
owarn << "received stderrt " << buflen << " bytes" << oendl;
QString lineStr = buffer;
// lineStr=lineStr.left(lineStr.length()-1);
OutputEdit->append(lineStr);
OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
}
void Output::processFinished() {
delete proc;
OutputEdit->append( tr("\nFinished\n") );
OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
// close();
// disconnect( layer(), SIGNAL(received(const QByteArray&)),
// this, SLOT(commandStdin(const QByteArray&)));
}
//==============================
InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "InputDialog" );
resize( 234, 50 );
setMaximumSize( QSize( 240, 50 ) );
setCaption( tr(name ) );
LineEdit1 = new QLineEdit( this, "LineEdit1" );
LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
LineEdit1->setFocus();
LineEdit1->setFocus();
connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() ));
}
InputDialog::~InputDialog() {
inputText = LineEdit1->text();
}
void InputDialog::setInputText(const QString &string) {
LineEdit1->setText( string);
}
void InputDialog::returned() {
inputText = LineEdit1->text();
this->accept();
}
diff --git a/noncore/apps/tinykate/libkate/document/katebuffer.cpp b/noncore/apps/tinykate/libkate/document/katebuffer.cpp
index 4c15fd0..d89edbd 100644
--- a/noncore/apps/tinykate/libkate/document/katebuffer.cpp
+++ b/noncore/apps/tinykate/libkate/document/katebuffer.cpp
@@ -1,171 +1,174 @@
/*
This file is part of KWrite
Copyright (c) 2000 Waldo Bastian <bastian@kde.org>
Copyright (c) 2002 Joseph Wenninger <jowenn@kde.org>
$Id$
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "katebuffer.h"
#include "kdebug.h"
/* OPIE */
#include <opie2/odebug.h>
/* QT */
#include <qfile.h>
#include <qtextstream.h>
#include <qtimer.h>
#include <qtextcodec.h>
/* STD */
// Includes for reading file
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <assert.h>
/**
* Create an empty buffer.
*/
KWBuffer::KWBuffer()
{
clear();
}
void
KWBuffer::clear()
{
m_stringListIt=0;
m_stringListCurrent=0;
m_stringList.clear();
m_lineCount=1;
m_stringListIt = m_stringList.append(new TextLine());
}
/**
* Insert a file at line @p line in the buffer.
*/
void
KWBuffer::insertFile(int line, const QString &file, QTextCodec *codec)
{
if (line) {
odebug << "insert File only supports insertion at line 0 == file opening" << oendl;
return;
}
clear();
QFile iofile(file);
- iofile.open(IO_ReadOnly);
+ if (!iofile.open(IO_ReadOnly)) {
+ owarn << "failed to open file " << iofile.name() << oendl;
+ return;
+ }
QTextStream stream(&iofile);
stream.setCodec(codec);
QString qsl;
int count=0;
for (count=0;((qsl=stream.readLine())!=QString::null); count++)
{
if (count==0)
{
(*m_stringListIt)->append(qsl.unicode(),qsl.length());
}
else
{
TextLine::Ptr tl=new TextLine();
tl ->append(qsl.unicode(),qsl.length());
m_stringListIt=m_stringList.append(tl);
}
}
if (count!=0)
{
m_stringListCurrent=count-1;
m_lineCount=count;
}
}
void
KWBuffer::loadFilePart()
{
}
void
KWBuffer::insertData(int line, const QByteArray &data, QTextCodec *codec)
{
}
void
KWBuffer::slotLoadFile()
{
loadFilePart();
// emit linesChanged(m_totalLines);
emit linesChanged(20);
}
/**
* Return the total number of lines in the buffer.
*/
int
KWBuffer::count()
{
odebug << "m_stringList.count " << m_stringList.count() << "" << oendl;
return m_lineCount;
// return m_stringList.count();
// return m_totalLines;
}
void KWBuffer::seek(int i)
{
if (m_stringListCurrent == i)
return;
while(m_stringListCurrent < i)
{
++m_stringListCurrent;
++m_stringListIt;
}
while(m_stringListCurrent > i)
{
--m_stringListCurrent;
--m_stringListIt;
}
}
TextLine::Ptr
KWBuffer::line(int i)
{
if (i>=m_stringList.count()) return 0;
seek(i);
return *m_stringListIt;
}
void
KWBuffer::insertLine(int i, TextLine::Ptr line)
{
seek(i);
m_stringListIt = m_stringList.insert(m_stringListIt, line);
m_stringListCurrent = i;
m_lineCount++;
}
void
KWBuffer::removeLine(int i)
{
seek(i);
m_stringListIt = m_stringList.remove(m_stringListIt);
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp
index 3654639..75a96a6 100644
--- a/noncore/settings/usermanager/userdialog.cpp
+++ b/noncore/settings/usermanager/userdialog.cpp
@@ -149,196 +149,199 @@ void UserDialog::setupTab1()
if(vm==VIEWMODE_NEW)
{
vlayout1->addSpacing(5);
vlayout1->addWidget(skelLabel);
}
// Second column, data
vlayout2->addWidget(loginLineEdit);
vlayout2->addSpacing(5);
vlayout2->addWidget(uidLineEdit);
vlayout2->addSpacing(5);
vlayout2->addWidget(gecosLineEdit);
vlayout2->addSpacing(5);
vlayout2->addWidget(passwordLineEdit);
vlayout2->addSpacing(5);
vlayout2->addWidget(shellComboBox);
vlayout2->addSpacing(5);
vlayout2->addWidget(groupComboBox);
if(vm==VIEWMODE_NEW)
{
vlayout2->addSpacing(5);
vlayout2->addWidget(skelCheckBox);
}
hlayout->addLayout(vlayout1);
hlayout->addLayout(vlayout2);
myTabWidget->addTab(tabpage,"User Info");
}
/**
* Creates the second tab containing additional groups for the user.
*
*/
void UserDialog::setupTab2()
{
QWidget *tabpage = new QWidget(myTabWidget,"page2");
QVBoxLayout *layout = new QVBoxLayout(tabpage);
layout->setMargin(5);
// Additional groups
groupsListView=new QListView(tabpage,"groups");
groupsListView->addColumn("Additional groups");
groupsListView->setColumnWidthMode(0,QListView::Maximum);
groupsListView->setMultiSelection(false);
groupsListView->setAllColumnsShowFocus(false);
layout->addSpacing(5);
// Grouplist
layout->addWidget(groupsListView);
myTabWidget->addTab(tabpage,"User Groups");
}
/**
* Static function that creates the userinfo dialog.
* The user will be prompted to add a user.
*
* @param uid This is a suggested available UID.
* @param gid This is a suggested available GID.
*
* @return <code>true</code> if the user was successfully added, otherwise <code>false</code>.
*
*/
bool UserDialog::addUser(int uid, int gid)
{
QCheckListItem *temp;
QFile ozTest;
int oz=false;
if(ODevice::inst()->system()==System_OpenZaurus) oz=true;
// viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here.
UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW);
adduserDialog->setCaption(tr("Add User"));
adduserDialog->userID=uid; // Set next available UID as default uid.
adduserDialog->groupID=gid; // Set next available GID as default gid.
// Insert default group into groupComboBox
adduserDialog->groupComboBox->insertItem("<create new group>",0);
adduserDialog->uidLineEdit->setText(QString::number(uid));
// If we're running on OZ, add new users to some default groups.
if(oz)
{
QListViewItemIterator iter( adduserDialog->groupsListView );
for ( ; iter.current(); ++iter )
{
temp=(QCheckListItem*)iter.current();
if (temp->text()=="video") temp->setOn(true);
if (temp->text()=="audio") temp->setOn(true);
if (temp->text()=="time") temp->setOn(true);
if (temp->text()=="power") temp->setOn(true);
if (temp->text()=="input") temp->setOn(true);
if (temp->text()=="sharp") temp->setOn(true);
if (temp->text()=="tty") temp->setOn(true);
}
}
// Show the dialog!
if(!(adduserDialog->exec())) return false;
if((adduserDialog->groupComboBox->currentItem()!=0))
{
- accounts->findGroup(adduserDialog->groupComboBox->currentText());
+ // making the call findGroup() puts the group info in the accounts gr_gid
+ if (accounts->findGroup(adduserDialog->groupComboBox->currentText()))
+ {
adduserDialog->groupID=accounts->gr_gid;
owarn << QString::number(accounts->gr_gid) << oendl;
}
+ }
if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(),
adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(),
QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText())))
{
QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user.");
return false;
}
// Add User to additional groups.
QListViewItemIterator it( adduserDialog->groupsListView );
for ( ; it.current(); ++it )
{
temp=(QCheckListItem*)it.current();
if (temp->isOn() )
accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text());
}
// Copy image to pics/users/
if(!(adduserDialog->userImage.isNull()))
{
QDir d;
if(!(d.exists(QPEApplication::qpeDir() + "pics/users")))
{
d.mkdir(QPEApplication::qpeDir() + "pics/users");
}
QString filename= QPEApplication::qpeDir()+"pics/users/"+accounts->pw_name+".png";
// adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48);
adduserDialog->userImage.save(filename,"PNG");
}
// Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory?
accounts->findUser(adduserDialog->loginLineEdit->text());
if(adduserDialog->skelCheckBox->isChecked())
{
QString command_cp;
QString command_chown;
command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1());
system(command_cp);
command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1()); // Bug in busybox, ".*" includes parent directory, does this work as a workaround?
system(command_cp);
command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1());
system(command_chown);
}
return true;
}
/**
* Deletes the user account.
*
* @param username User to be deleted.
*
* @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
*
*/
bool UserDialog::delUser(const char *username)
{
if((accounts->findUser(username)))
{ // Does that user exist?
if(!(accounts->delUser(username)))
{ // Delete the user.
QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+".");
}
}
else
{
QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist.");
return false;
}
return true;
}
/**
* This displays a confirmation dialog wether a user should be deleted or not.
* (And also deletes the account)
*
* @param username User to be deleted.
*
* @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>.
*
*/
bool UserDialog::editUser(const char *username)
{
int invalid_group=0;
// viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here.
UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT); // Create Dialog
edituserDialog->setCaption(tr("Edit User"));
accounts->findUser(username); // Locate user in database and fill variables in 'accounts' object.
if(!(accounts->findGroup(accounts->pw_gid)))
{ // Locate the user's primary group, and fill group variables in 'accounts' object.
invalid_group=1;
}
// Fill widgets with userinfo.
edituserDialog->loginLineEdit->setText(accounts->pw_name);
edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid));