summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/applnk.cpp2
-rw-r--r--library/global.cpp4
-rw-r--r--library/lnkproperties.cpp7
-rw-r--r--library/storage.cpp14
4 files changed, 16 insertions, 11 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp
index 5185b5f..778ccab 100644
--- a/library/applnk.cpp
+++ b/library/applnk.cpp
@@ -295,97 +295,97 @@ QString AppLnk::type() const
QString AppLnk::file() const
{
if ( mFile.isNull() ) {
AppLnk* that = (AppLnk*)this; // copy?
QString ext = MimeType(mType).extension();
if ( !ext.isEmpty() )
ext = "." + ext;
if ( !mLinkFile.isEmpty() ) {
that->mFile =
mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop")
? mLinkFile.left(mLinkFile.length()-8) : mLinkFile;
} else if ( mType.contains('/') ) {
that->mFile =
QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName);
if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { // a .desktop with the same name exists
int n=1;
qWarning("AppLnk::file() n=1 %s", that->mFile.latin1() );
QString nn;
while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext)
|| QFile::exists(nn+".desktop"))
n++;
that->mFile = nn;
qWarning("AppLnl::file() now mFile is %s", that->mFile.latin1() );
}
that->mLinkFile = that->mFile+".desktop";
that->mFile += ext;
}
prepareDirectories(that->mFile);
QFile f(that->mFile);
if ( !f.open(IO_WriteOnly) )
that->mFile = QString::null;
return that->mFile;
}
return mFile;
}
/*!
Returns the desktop file coresponding to this AppLnk.
\sa file(), exec()
*/
QString AppLnk::linkFile() const
{
if ( mLinkFile.isNull() ) {
AppLnk* that = (AppLnk*)this;
if ( type().contains('/') ) {
StorageInfo storage;
const FileSystem *fs = storage.fileSystemOf( that->mFile );
- if ( fs && fs->isRemovable() ) {
+ if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs" ) ) {
that->mLinkFile = fs->path();
} else
that->mLinkFile = getenv( "HOME" );
that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName);
if ( QFile::exists(that->mLinkFile+".desktop") ) { // ok the file exists lets check if we point to the same file
int n=1;
QString nn;
AppLnk lnk( that->mLinkFile+".desktop" );
if(that->file() != lnk.file() ){
qWarning("AppLnk::linkFile exists %s", that->mLinkFile.latin1() );
while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")){
n++;
AppLnk lnk(nn ); // just to be sure
if(lnk.file() ==that->file() ){
break;
}
}
that->mLinkFile = nn;
}
}
that->mLinkFile += ".desktop";
qWarning("AppLnk::linkFile is %s", that->mLinkFile.latin1() );
storeLink();
}
return that->mLinkFile;
}
return mLinkFile;
}
/*!
Copies \a copy.
*/
AppLnk::AppLnk( const AppLnk &copy )
{
mName = copy.mName;
mPixmap = copy.mPixmap;
mBigPixmap = copy.mBigPixmap;
mExec = copy.mExec;
mType = copy.mType;
mRotation = copy.mRotation;
mComment = copy.mComment;
mFile = copy.mFile;
mLinkFile = copy.mLinkFile;
mIconFile = copy.mIconFile;
mMimeTypes = copy.mMimeTypes;
mMimeTypeIcons = copy.mMimeTypeIcons;
mId = 0;
d = new AppLnkPrivate();
diff --git a/library/global.cpp b/library/global.cpp
index edb7b85..ab27b3f 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -636,91 +636,95 @@ QString Global::stringQuote(const QString& s)
QString r="\"";
for (int i=0; i<(int)s.length(); i++) {
char c = s[i].latin1();
switch (c) {
case '\\': case '"':
r+="\\";
}
r += s[i];
}
r += "\"";
return r;
}
/*!
Finds all documents on the system's document directories which
match the filter \a mimefilter, and appends the resulting DocLnk
objects to \a folder.
*/
void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter)
{
QString homedocs = QString(getenv("HOME")) + "/Documents";
DocLnkSet d(homedocs,mimefilter);
folder->appendFrom(d);
/** let's do intellegint way of searching these files
* a) the user don't want to check mediums global
* b) the user wants to check but use the global options for it
* c) the user wants to check it but not this medium
* d) the user wants to check and this medium as well
*
* In all cases we need to apply a different mimefilter to
* the medium.
* a) mimefilter.isEmpty() we need to apply the responding filter
* either the global or the one on the medium
*
* b) mimefilter is set to an application we need to find out if the
* mimetypes are included in the mime mask of the medium
*/
StorageInfo storage;
const QList<FileSystem> &fs = storage.fileSystems();
QListIterator<FileSystem> it ( fs );
for ( ; it.current(); ++it ) {
if ( (*it)->isRemovable() ) { // let's find out if we should search on it
// this is a candidate look at the cf and see if we should search on it
QString path = (*it)->path();
if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) )
continue;
DocLnkSet ide( path, mimefilter );
folder->appendFrom(ide);
+ } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) {
+ QString path = (*it)->path() + "/Documents";
+ DocLnkSet ide( path, mimefilter );
+ folder->appendFrom(ide);
}
}
}
QStringList Global::languageList()
{
QString lang = getenv("LANG");
QStringList langs;
langs.append(lang);
int i = lang.find(".");
if ( i > 0 )
lang = lang.left( i );
i = lang.find( "_" );
if ( i > 0 )
langs.append(lang.left(i));
return langs;
}
QStringList Global::helpPath()
{
QStringList path;
QStringList langs = Global::languageList();
for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) {
QString lang = *it;
if ( !lang.isEmpty() )
path += QPEApplication::qpeDir() + "/help/" + lang + "/html";
}
path += QPEApplication::qpeDir() + "/pics";
path += QPEApplication::qpeDir() + "/help/en/html";
path += QPEApplication::qpeDir() + "/docs";
QString dir = QDir::current().canonicalPath();
if ( dir == "/" )
dir += "/docs";
else {
path += dir + "/../pics";
dir += "/../docs";
path += dir;
}
return path;
}
#include "global.moc"
diff --git a/library/lnkproperties.cpp b/library/lnkproperties.cpp
index e8baca6..c020328 100644
--- a/library/lnkproperties.cpp
+++ b/library/lnkproperties.cpp
@@ -128,105 +128,106 @@ void LnkProperties::unlinkLnk()
{
if ( QPEMessageBox::confirmDelete( this, tr("Delete"), lnk->name() ) ) {
if ( QFile::exists(lnk->file()) )
lnk->removeFiles();
else
QMessageBox::warning( this, tr("Delete"), tr("File does not exist.") );
if ( QFile::exists(lnk->file()) ) {
QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") );
} else {
reject();
}
}
}
/*
* remove only the link from documents, not also the file
*/
void LnkProperties::unlinkIcon()
{
if ( QPEMessageBox::confirmDelete( this, tr("Delete Icon and leave file"), lnk->name() ) ) {
lnk->removeLinkFile();
if ( QFile::exists(lnk->linkFile()) ) {
QMessageBox::warning( this, tr("Delete"), tr("Icon deletion failed.") );
} else {
reject();
}
}
}
void LnkProperties::setupLocations()
{
QFileInfo fi( lnk->file() );
fileSize = fi.size();
StorageInfo storage;
const QList<FileSystem> &fs = storage.fileSystems();
QListIterator<FileSystem> it ( fs );
QString s;
QString homeDir = getenv("HOME");
QString hardDiskHome;
QString hardDiskPath;
int index = 0;
currentLocation = -1;
for ( ; it.current(); ++it ) {
// we add 10k to the file size so we are sure we can also save the desktop file
if ( (*it)->availBlocks() * (*it)->blockSize() > fileSize + 10000 ) {
if ( (*it)->isRemovable() ||
(*it)->disk() == "/dev/mtdblock1" ||
- (*it)->disk() == "/dev/mtdblock/1" || (*it)->disk().left(13) == "/dev/mtdblock" ) {
+ (*it)->disk() == "/dev/mtdblock/1" || (*it)->disk().left(13) == "/dev/mtdblock" ||
+ (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) {
d->locationCombo->insertItem( (*it)->name(), index );
- locations.append( ((*it)->isRemovable() ? (*it)->path() : homeDir) );
+ locations.append( ((*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ? (*it)->path() : homeDir) );
if ( lnk->file().contains( (*it)->path() ) ) {
d->locationCombo->setCurrentItem( index );
currentLocation = index;
}
index++;
- } else if ( (*it)->name().contains( "Hard Disk") &&
+ } else if ( (*it)->name().contains( tr("Hard Disk") ) &&
homeDir.contains( (*it)->path() ) &&
(*it)->path().length() > hardDiskHome.length() ) {
hardDiskHome = (*it)->name();
hardDiskPath = (*it)->path();
}
}
}
if ( !hardDiskHome.isEmpty() ) {
d->locationCombo->insertItem( hardDiskHome );
locations.append( hardDiskPath );
if ( currentLocation == -1 ) { // assume it's the hard disk
d->locationCombo->setCurrentItem( index );
currentLocation = index;
}
}
}
void LnkProperties::duplicateLnk()
{
// The duplicate takes the new properties.
DocLnk newdoc( *((DocLnk *)lnk) );
if ( d->docname->text() == lnk->name() )
newdoc.setName(tr("Copy of ")+d->docname->text());
else
newdoc.setName(d->docname->text());
if ( !copyFile( newdoc ) ) {
QMessageBox::warning( this, tr("Duplicate"), tr("File copy failed.") );
return;
}
reject();
}
bool LnkProperties::moveLnk()
{
DocLnk newdoc( *((DocLnk *)lnk) );
newdoc.setName(d->docname->text());
if ( !copyFile( newdoc ) ) {
QMessageBox::warning( this, tr("Details"), tr("Moving Document failed.") );
return FALSE;
}
// remove old lnk
lnk->removeFiles();
return TRUE;
}
diff --git a/library/storage.cpp b/library/storage.cpp
index 2d996fa..13639fe 100644
--- a/library/storage.cpp
+++ b/library/storage.cpp
@@ -60,137 +60,137 @@ static bool isCF(const QString& m)
}
return FALSE;
}
StorageInfo::StorageInfo( QObject *parent )
: QObject( parent )
{
mFileSystems.setAutoDelete( TRUE );
channel = new QCopChannel( "QPE/Card", this );
connect( channel, SIGNAL(received(const QCString &, const QByteArray &)),
this, SLOT(cardMessage( const QCString &, const QByteArray &)) );
update();
}
const FileSystem *StorageInfo::fileSystemOf( const QString &filename )
{
for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) {
if ( filename.startsWith( (*i)->path() ) )
return (*i);
}
return 0;
}
void StorageInfo::cardMessage( const QCString& msg, const QByteArray& )
{
if ( msg == "mtabChanged()" )
update();
}
// cause of the lack of a d pointer we need
// to store informations in a config file :(
void StorageInfo::update()
{
//qDebug("StorageInfo::updating");
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
struct mntent *me;
FILE *mntfp = setmntent( "/etc/mtab", "r" );
QStringList curdisks;
QStringList curopts;
QStringList curfs;
bool rebuild = FALSE;
int n=0;
if ( mntfp ) {
while ( (me = getmntent( mntfp )) != 0 ) {
QString fs = me->mnt_fsname;
if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd"
|| fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd"
- || fs.left(8)=="/dev/ram" || fs.left(5)=="tmpfs" )
+ || fs.left(5)=="tmpfs" )
{
n++;
curdisks.append(fs);
curopts.append( me->mnt_opts );
//qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts );
curfs.append( me->mnt_dir );
bool found = FALSE;
for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) {
if ( (*i)->disk() == fs ) {
found = TRUE;
break;
}
}
if ( !found )
rebuild = TRUE;
}
}
endmntent( mntfp );
}
if ( rebuild || n != (int)mFileSystems.count() ) {
mFileSystems.clear();
QStringList::ConstIterator it=curdisks.begin();
QStringList::ConstIterator fsit=curfs.begin();
QStringList::ConstIterator optsIt=curopts.begin();
for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) {
QString opts = *optsIt;
QString disk = *it;
QString humanname;
bool removable = FALSE;
if ( isCF(disk) ) {
humanname = tr("CF Card");
removable = TRUE;
} else if ( disk == "/dev/hda1" ) {
humanname = tr("Hard Disk");
} else if ( disk.left(9) == "/dev/mmcd" ) {
humanname = tr("SD Card");
removable = TRUE;
} else if ( disk.left(7) == "/dev/hd" )
- humanname = tr("Hard Disk") + " " + humanname.mid(7);
+ humanname = tr("Hard Disk") + " " + disk.mid(7);
else if ( disk.left(7) == "/dev/sd" )
- humanname = tr("SCSI Hard Disk") + " " + humanname.mid(7);
+ humanname = tr("SCSI Hard Disk") + " " + disk.mid(7);
else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs
- humanname = tr("Ram FS") + " " + humanname.mid(14);
+ humanname = tr("Internal Memory");
else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" )
humanname = tr("Internal Storage");
else if ( disk.left(14) == "/dev/mtdblock/" )
- humanname = tr("Internal Storage") + " " + humanname.mid(14);
+ humanname = tr("Internal Storage") + " " + disk.mid(14);
else if ( disk.left(13) == "/dev/mtdblock" )
- humanname = tr("Internal Storage") + " " + humanname.mid(13);
+ humanname = tr("Internal Storage") + " " + disk.mid(13);
else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs
- humanname = tr("Ram FS") + " " + humanname.mid(5);
+ humanname = tr("Internal Memory");
FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts );
mFileSystems.append( fs );
}
emit disksChanged();
} else {
// just update them
for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i)
i.current()->update();
}
#endif
}
//---------------------------------------------------------------------------
FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o )
: fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o )
{
update();
}
void FileSystem::update()
{
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
struct statfs fs;
if ( !statfs( fspath.latin1(), &fs ) ) {
blkSize = fs.f_bsize;
totalBlks = fs.f_blocks;
availBlks = fs.f_bavail;
} else {
blkSize = 0;
totalBlks = 0;
availBlks = 0;
}
#endif
}