author | leseb <leseb> | 2002-08-30 18:10:11 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-08-30 18:10:11 (UTC) |
commit | b5ec106e5f612042987397a5a5b6683fdabaf793 (patch) (unidiff) | |
tree | 58da0aac60a7a39cca162fe222107c9e3d676dac | |
parent | f6125710c0ca99fc62ffce69973a168b6604f29d (diff) | |
download | opie-b5ec106e5f612042987397a5a5b6683fdabaf793.zip opie-b5ec106e5f612042987397a5a5b6683fdabaf793.tar.gz opie-b5ec106e5f612042987397a5a5b6683fdabaf793.tar.bz2 |
Try to handle RAM storage for documents
-rw-r--r-- | library/applnk.cpp | 2 | ||||
-rw-r--r-- | library/global.cpp | 4 | ||||
-rw-r--r-- | library/lnkproperties.cpp | 7 | ||||
-rw-r--r-- | library/storage.cpp | 14 |
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 | |||
295 | QString AppLnk::file() const | 295 | QString AppLnk::file() const |
296 | { | 296 | { |
297 | if ( mFile.isNull() ) { | 297 | if ( mFile.isNull() ) { |
298 | AppLnk* that = (AppLnk*)this; // copy? | 298 | AppLnk* that = (AppLnk*)this; // copy? |
299 | QString ext = MimeType(mType).extension(); | 299 | QString ext = MimeType(mType).extension(); |
300 | if ( !ext.isEmpty() ) | 300 | if ( !ext.isEmpty() ) |
301 | ext = "." + ext; | 301 | ext = "." + ext; |
302 | if ( !mLinkFile.isEmpty() ) { | 302 | if ( !mLinkFile.isEmpty() ) { |
303 | that->mFile = | 303 | that->mFile = |
304 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") | 304 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") |
305 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; | 305 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; |
306 | } else if ( mType.contains('/') ) { | 306 | } else if ( mType.contains('/') ) { |
307 | that->mFile = | 307 | that->mFile = |
308 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); | 308 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); |
309 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { // a .desktop with the same name exists | 309 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { // a .desktop with the same name exists |
310 | int n=1; | 310 | int n=1; |
311 | qWarning("AppLnk::file() n=1 %s", that->mFile.latin1() ); | 311 | qWarning("AppLnk::file() n=1 %s", that->mFile.latin1() ); |
312 | QString nn; | 312 | QString nn; |
313 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) | 313 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) |
314 | || QFile::exists(nn+".desktop")) | 314 | || QFile::exists(nn+".desktop")) |
315 | n++; | 315 | n++; |
316 | that->mFile = nn; | 316 | that->mFile = nn; |
317 | qWarning("AppLnl::file() now mFile is %s", that->mFile.latin1() ); | 317 | qWarning("AppLnl::file() now mFile is %s", that->mFile.latin1() ); |
318 | } | 318 | } |
319 | that->mLinkFile = that->mFile+".desktop"; | 319 | that->mLinkFile = that->mFile+".desktop"; |
320 | that->mFile += ext; | 320 | that->mFile += ext; |
321 | } | 321 | } |
322 | prepareDirectories(that->mFile); | 322 | prepareDirectories(that->mFile); |
323 | QFile f(that->mFile); | 323 | QFile f(that->mFile); |
324 | if ( !f.open(IO_WriteOnly) ) | 324 | if ( !f.open(IO_WriteOnly) ) |
325 | that->mFile = QString::null; | 325 | that->mFile = QString::null; |
326 | return that->mFile; | 326 | return that->mFile; |
327 | } | 327 | } |
328 | return mFile; | 328 | return mFile; |
329 | } | 329 | } |
330 | 330 | ||
331 | /*! | 331 | /*! |
332 | Returns the desktop file coresponding to this AppLnk. | 332 | Returns the desktop file coresponding to this AppLnk. |
333 | 333 | ||
334 | \sa file(), exec() | 334 | \sa file(), exec() |
335 | */ | 335 | */ |
336 | QString AppLnk::linkFile() const | 336 | QString AppLnk::linkFile() const |
337 | { | 337 | { |
338 | if ( mLinkFile.isNull() ) { | 338 | if ( mLinkFile.isNull() ) { |
339 | AppLnk* that = (AppLnk*)this; | 339 | AppLnk* that = (AppLnk*)this; |
340 | if ( type().contains('/') ) { | 340 | if ( type().contains('/') ) { |
341 | StorageInfo storage; | 341 | StorageInfo storage; |
342 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); | 342 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); |
343 | if ( fs && fs->isRemovable() ) { | 343 | if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs" ) ) { |
344 | that->mLinkFile = fs->path(); | 344 | that->mLinkFile = fs->path(); |
345 | } else | 345 | } else |
346 | that->mLinkFile = getenv( "HOME" ); | 346 | that->mLinkFile = getenv( "HOME" ); |
347 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); | 347 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); |
348 | if ( QFile::exists(that->mLinkFile+".desktop") ) { // ok the file exists lets check if we point to the same file | 348 | if ( QFile::exists(that->mLinkFile+".desktop") ) { // ok the file exists lets check if we point to the same file |
349 | int n=1; | 349 | int n=1; |
350 | QString nn; | 350 | QString nn; |
351 | AppLnk lnk( that->mLinkFile+".desktop" ); | 351 | AppLnk lnk( that->mLinkFile+".desktop" ); |
352 | if(that->file() != lnk.file() ){ | 352 | if(that->file() != lnk.file() ){ |
353 | qWarning("AppLnk::linkFile exists %s", that->mLinkFile.latin1() ); | 353 | qWarning("AppLnk::linkFile exists %s", that->mLinkFile.latin1() ); |
354 | while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")){ | 354 | while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")){ |
355 | n++; | 355 | n++; |
356 | AppLnk lnk(nn ); // just to be sure | 356 | AppLnk lnk(nn ); // just to be sure |
357 | if(lnk.file() ==that->file() ){ | 357 | if(lnk.file() ==that->file() ){ |
358 | break; | 358 | break; |
359 | } | 359 | } |
360 | } | 360 | } |
361 | that->mLinkFile = nn; | 361 | that->mLinkFile = nn; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | that->mLinkFile += ".desktop"; | 364 | that->mLinkFile += ".desktop"; |
365 | qWarning("AppLnk::linkFile is %s", that->mLinkFile.latin1() ); | 365 | qWarning("AppLnk::linkFile is %s", that->mLinkFile.latin1() ); |
366 | storeLink(); | 366 | storeLink(); |
367 | } | 367 | } |
368 | return that->mLinkFile; | 368 | return that->mLinkFile; |
369 | } | 369 | } |
370 | return mLinkFile; | 370 | return mLinkFile; |
371 | } | 371 | } |
372 | 372 | ||
373 | /*! | 373 | /*! |
374 | Copies \a copy. | 374 | Copies \a copy. |
375 | */ | 375 | */ |
376 | AppLnk::AppLnk( const AppLnk © ) | 376 | AppLnk::AppLnk( const AppLnk © ) |
377 | { | 377 | { |
378 | mName = copy.mName; | 378 | mName = copy.mName; |
379 | mPixmap = copy.mPixmap; | 379 | mPixmap = copy.mPixmap; |
380 | mBigPixmap = copy.mBigPixmap; | 380 | mBigPixmap = copy.mBigPixmap; |
381 | mExec = copy.mExec; | 381 | mExec = copy.mExec; |
382 | mType = copy.mType; | 382 | mType = copy.mType; |
383 | mRotation = copy.mRotation; | 383 | mRotation = copy.mRotation; |
384 | mComment = copy.mComment; | 384 | mComment = copy.mComment; |
385 | mFile = copy.mFile; | 385 | mFile = copy.mFile; |
386 | mLinkFile = copy.mLinkFile; | 386 | mLinkFile = copy.mLinkFile; |
387 | mIconFile = copy.mIconFile; | 387 | mIconFile = copy.mIconFile; |
388 | mMimeTypes = copy.mMimeTypes; | 388 | mMimeTypes = copy.mMimeTypes; |
389 | mMimeTypeIcons = copy.mMimeTypeIcons; | 389 | mMimeTypeIcons = copy.mMimeTypeIcons; |
390 | mId = 0; | 390 | mId = 0; |
391 | d = new AppLnkPrivate(); | 391 | 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) | |||
636 | QString r="\""; | 636 | QString r="\""; |
637 | for (int i=0; i<(int)s.length(); i++) { | 637 | for (int i=0; i<(int)s.length(); i++) { |
638 | char c = s[i].latin1(); | 638 | char c = s[i].latin1(); |
639 | switch (c) { | 639 | switch (c) { |
640 | case '\\': case '"': | 640 | case '\\': case '"': |
641 | r+="\\"; | 641 | r+="\\"; |
642 | } | 642 | } |
643 | r += s[i]; | 643 | r += s[i]; |
644 | } | 644 | } |
645 | r += "\""; | 645 | r += "\""; |
646 | return r; | 646 | return r; |
647 | } | 647 | } |
648 | 648 | ||
649 | /*! | 649 | /*! |
650 | Finds all documents on the system's document directories which | 650 | Finds all documents on the system's document directories which |
651 | match the filter \a mimefilter, and appends the resulting DocLnk | 651 | match the filter \a mimefilter, and appends the resulting DocLnk |
652 | objects to \a folder. | 652 | objects to \a folder. |
653 | */ | 653 | */ |
654 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) | 654 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) |
655 | { | 655 | { |
656 | QString homedocs = QString(getenv("HOME")) + "/Documents"; | 656 | QString homedocs = QString(getenv("HOME")) + "/Documents"; |
657 | DocLnkSet d(homedocs,mimefilter); | 657 | DocLnkSet d(homedocs,mimefilter); |
658 | folder->appendFrom(d); | 658 | folder->appendFrom(d); |
659 | /** let's do intellegint way of searching these files | 659 | /** let's do intellegint way of searching these files |
660 | * a) the user don't want to check mediums global | 660 | * a) the user don't want to check mediums global |
661 | * b) the user wants to check but use the global options for it | 661 | * b) the user wants to check but use the global options for it |
662 | * c) the user wants to check it but not this medium | 662 | * c) the user wants to check it but not this medium |
663 | * d) the user wants to check and this medium as well | 663 | * d) the user wants to check and this medium as well |
664 | * | 664 | * |
665 | * In all cases we need to apply a different mimefilter to | 665 | * In all cases we need to apply a different mimefilter to |
666 | * the medium. | 666 | * the medium. |
667 | * a) mimefilter.isEmpty() we need to apply the responding filter | 667 | * a) mimefilter.isEmpty() we need to apply the responding filter |
668 | * either the global or the one on the medium | 668 | * either the global or the one on the medium |
669 | * | 669 | * |
670 | * b) mimefilter is set to an application we need to find out if the | 670 | * b) mimefilter is set to an application we need to find out if the |
671 | * mimetypes are included in the mime mask of the medium | 671 | * mimetypes are included in the mime mask of the medium |
672 | */ | 672 | */ |
673 | StorageInfo storage; | 673 | StorageInfo storage; |
674 | const QList<FileSystem> &fs = storage.fileSystems(); | 674 | const QList<FileSystem> &fs = storage.fileSystems(); |
675 | QListIterator<FileSystem> it ( fs ); | 675 | QListIterator<FileSystem> it ( fs ); |
676 | for ( ; it.current(); ++it ) { | 676 | for ( ; it.current(); ++it ) { |
677 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 677 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
678 | // this is a candidate look at the cf and see if we should search on it | 678 | // this is a candidate look at the cf and see if we should search on it |
679 | QString path = (*it)->path(); | 679 | QString path = (*it)->path(); |
680 | if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) | 680 | if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) |
681 | continue; | 681 | continue; |
682 | DocLnkSet ide( path, mimefilter ); | 682 | DocLnkSet ide( path, mimefilter ); |
683 | folder->appendFrom(ide); | 683 | folder->appendFrom(ide); |
684 | } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | ||
685 | QString path = (*it)->path() + "/Documents"; | ||
686 | DocLnkSet ide( path, mimefilter ); | ||
687 | folder->appendFrom(ide); | ||
684 | } | 688 | } |
685 | } | 689 | } |
686 | } | 690 | } |
687 | 691 | ||
688 | QStringList Global::languageList() | 692 | QStringList Global::languageList() |
689 | { | 693 | { |
690 | QString lang = getenv("LANG"); | 694 | QString lang = getenv("LANG"); |
691 | QStringList langs; | 695 | QStringList langs; |
692 | langs.append(lang); | 696 | langs.append(lang); |
693 | int i = lang.find("."); | 697 | int i = lang.find("."); |
694 | if ( i > 0 ) | 698 | if ( i > 0 ) |
695 | lang = lang.left( i ); | 699 | lang = lang.left( i ); |
696 | i = lang.find( "_" ); | 700 | i = lang.find( "_" ); |
697 | if ( i > 0 ) | 701 | if ( i > 0 ) |
698 | langs.append(lang.left(i)); | 702 | langs.append(lang.left(i)); |
699 | return langs; | 703 | return langs; |
700 | } | 704 | } |
701 | 705 | ||
702 | QStringList Global::helpPath() | 706 | QStringList Global::helpPath() |
703 | { | 707 | { |
704 | QStringList path; | 708 | QStringList path; |
705 | QStringList langs = Global::languageList(); | 709 | QStringList langs = Global::languageList(); |
706 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { | 710 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { |
707 | QString lang = *it; | 711 | QString lang = *it; |
708 | if ( !lang.isEmpty() ) | 712 | if ( !lang.isEmpty() ) |
709 | path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; | 713 | path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; |
710 | } | 714 | } |
711 | path += QPEApplication::qpeDir() + "/pics"; | 715 | path += QPEApplication::qpeDir() + "/pics"; |
712 | path += QPEApplication::qpeDir() + "/help/en/html"; | 716 | path += QPEApplication::qpeDir() + "/help/en/html"; |
713 | path += QPEApplication::qpeDir() + "/docs"; | 717 | path += QPEApplication::qpeDir() + "/docs"; |
714 | QString dir = QDir::current().canonicalPath(); | 718 | QString dir = QDir::current().canonicalPath(); |
715 | if ( dir == "/" ) | 719 | if ( dir == "/" ) |
716 | dir += "/docs"; | 720 | dir += "/docs"; |
717 | else { | 721 | else { |
718 | path += dir + "/../pics"; | 722 | path += dir + "/../pics"; |
719 | dir += "/../docs"; | 723 | dir += "/../docs"; |
720 | path += dir; | 724 | path += dir; |
721 | } | 725 | } |
722 | return path; | 726 | return path; |
723 | } | 727 | } |
724 | 728 | ||
725 | 729 | ||
726 | #include "global.moc" | 730 | #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() | |||
128 | { | 128 | { |
129 | if ( QPEMessageBox::confirmDelete( this, tr("Delete"), lnk->name() ) ) { | 129 | if ( QPEMessageBox::confirmDelete( this, tr("Delete"), lnk->name() ) ) { |
130 | if ( QFile::exists(lnk->file()) ) | 130 | if ( QFile::exists(lnk->file()) ) |
131 | lnk->removeFiles(); | 131 | lnk->removeFiles(); |
132 | else | 132 | else |
133 | QMessageBox::warning( this, tr("Delete"), tr("File does not exist.") ); | 133 | QMessageBox::warning( this, tr("Delete"), tr("File does not exist.") ); |
134 | if ( QFile::exists(lnk->file()) ) { | 134 | if ( QFile::exists(lnk->file()) ) { |
135 | QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") ); | 135 | QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") ); |
136 | } else { | 136 | } else { |
137 | reject(); | 137 | reject(); |
138 | } | 138 | } |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
143 | /* | 143 | /* |
144 | * remove only the link from documents, not also the file | 144 | * remove only the link from documents, not also the file |
145 | */ | 145 | */ |
146 | void LnkProperties::unlinkIcon() | 146 | void LnkProperties::unlinkIcon() |
147 | { | 147 | { |
148 | if ( QPEMessageBox::confirmDelete( this, tr("Delete Icon and leave file"), lnk->name() ) ) { | 148 | if ( QPEMessageBox::confirmDelete( this, tr("Delete Icon and leave file"), lnk->name() ) ) { |
149 | lnk->removeLinkFile(); | 149 | lnk->removeLinkFile(); |
150 | if ( QFile::exists(lnk->linkFile()) ) { | 150 | if ( QFile::exists(lnk->linkFile()) ) { |
151 | QMessageBox::warning( this, tr("Delete"), tr("Icon deletion failed.") ); | 151 | QMessageBox::warning( this, tr("Delete"), tr("Icon deletion failed.") ); |
152 | } else { | 152 | } else { |
153 | reject(); | 153 | reject(); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void LnkProperties::setupLocations() | 158 | void LnkProperties::setupLocations() |
159 | { | 159 | { |
160 | QFileInfo fi( lnk->file() ); | 160 | QFileInfo fi( lnk->file() ); |
161 | fileSize = fi.size(); | 161 | fileSize = fi.size(); |
162 | StorageInfo storage; | 162 | StorageInfo storage; |
163 | const QList<FileSystem> &fs = storage.fileSystems(); | 163 | const QList<FileSystem> &fs = storage.fileSystems(); |
164 | QListIterator<FileSystem> it ( fs ); | 164 | QListIterator<FileSystem> it ( fs ); |
165 | QString s; | 165 | QString s; |
166 | QString homeDir = getenv("HOME"); | 166 | QString homeDir = getenv("HOME"); |
167 | QString hardDiskHome; | 167 | QString hardDiskHome; |
168 | QString hardDiskPath; | 168 | QString hardDiskPath; |
169 | int index = 0; | 169 | int index = 0; |
170 | currentLocation = -1; | 170 | currentLocation = -1; |
171 | for ( ; it.current(); ++it ) { | 171 | for ( ; it.current(); ++it ) { |
172 | // we add 10k to the file size so we are sure we can also save the desktop file | 172 | // we add 10k to the file size so we are sure we can also save the desktop file |
173 | if ( (*it)->availBlocks() * (*it)->blockSize() > fileSize + 10000 ) { | 173 | if ( (*it)->availBlocks() * (*it)->blockSize() > fileSize + 10000 ) { |
174 | if ( (*it)->isRemovable() || | 174 | if ( (*it)->isRemovable() || |
175 | (*it)->disk() == "/dev/mtdblock1" || | 175 | (*it)->disk() == "/dev/mtdblock1" || |
176 | (*it)->disk() == "/dev/mtdblock/1" || (*it)->disk().left(13) == "/dev/mtdblock" ) { | 176 | (*it)->disk() == "/dev/mtdblock/1" || (*it)->disk().left(13) == "/dev/mtdblock" || |
177 | (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | ||
177 | d->locationCombo->insertItem( (*it)->name(), index ); | 178 | d->locationCombo->insertItem( (*it)->name(), index ); |
178 | locations.append( ((*it)->isRemovable() ? (*it)->path() : homeDir) ); | 179 | locations.append( ((*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ? (*it)->path() : homeDir) ); |
179 | if ( lnk->file().contains( (*it)->path() ) ) { | 180 | if ( lnk->file().contains( (*it)->path() ) ) { |
180 | d->locationCombo->setCurrentItem( index ); | 181 | d->locationCombo->setCurrentItem( index ); |
181 | currentLocation = index; | 182 | currentLocation = index; |
182 | } | 183 | } |
183 | index++; | 184 | index++; |
184 | } else if ( (*it)->name().contains( "Hard Disk") && | 185 | } else if ( (*it)->name().contains( tr("Hard Disk") ) && |
185 | homeDir.contains( (*it)->path() ) && | 186 | homeDir.contains( (*it)->path() ) && |
186 | (*it)->path().length() > hardDiskHome.length() ) { | 187 | (*it)->path().length() > hardDiskHome.length() ) { |
187 | hardDiskHome = (*it)->name(); | 188 | hardDiskHome = (*it)->name(); |
188 | hardDiskPath = (*it)->path(); | 189 | hardDiskPath = (*it)->path(); |
189 | } | 190 | } |
190 | } | 191 | } |
191 | } | 192 | } |
192 | if ( !hardDiskHome.isEmpty() ) { | 193 | if ( !hardDiskHome.isEmpty() ) { |
193 | d->locationCombo->insertItem( hardDiskHome ); | 194 | d->locationCombo->insertItem( hardDiskHome ); |
194 | locations.append( hardDiskPath ); | 195 | locations.append( hardDiskPath ); |
195 | if ( currentLocation == -1 ) { // assume it's the hard disk | 196 | if ( currentLocation == -1 ) { // assume it's the hard disk |
196 | d->locationCombo->setCurrentItem( index ); | 197 | d->locationCombo->setCurrentItem( index ); |
197 | currentLocation = index; | 198 | currentLocation = index; |
198 | } | 199 | } |
199 | } | 200 | } |
200 | } | 201 | } |
201 | 202 | ||
202 | void LnkProperties::duplicateLnk() | 203 | void LnkProperties::duplicateLnk() |
203 | { | 204 | { |
204 | // The duplicate takes the new properties. | 205 | // The duplicate takes the new properties. |
205 | DocLnk newdoc( *((DocLnk *)lnk) ); | 206 | DocLnk newdoc( *((DocLnk *)lnk) ); |
206 | if ( d->docname->text() == lnk->name() ) | 207 | if ( d->docname->text() == lnk->name() ) |
207 | newdoc.setName(tr("Copy of ")+d->docname->text()); | 208 | newdoc.setName(tr("Copy of ")+d->docname->text()); |
208 | else | 209 | else |
209 | newdoc.setName(d->docname->text()); | 210 | newdoc.setName(d->docname->text()); |
210 | 211 | ||
211 | if ( !copyFile( newdoc ) ) { | 212 | if ( !copyFile( newdoc ) ) { |
212 | QMessageBox::warning( this, tr("Duplicate"), tr("File copy failed.") ); | 213 | QMessageBox::warning( this, tr("Duplicate"), tr("File copy failed.") ); |
213 | return; | 214 | return; |
214 | } | 215 | } |
215 | reject(); | 216 | reject(); |
216 | } | 217 | } |
217 | 218 | ||
218 | bool LnkProperties::moveLnk() | 219 | bool LnkProperties::moveLnk() |
219 | { | 220 | { |
220 | DocLnk newdoc( *((DocLnk *)lnk) ); | 221 | DocLnk newdoc( *((DocLnk *)lnk) ); |
221 | newdoc.setName(d->docname->text()); | 222 | newdoc.setName(d->docname->text()); |
222 | 223 | ||
223 | if ( !copyFile( newdoc ) ) { | 224 | if ( !copyFile( newdoc ) ) { |
224 | QMessageBox::warning( this, tr("Details"), tr("Moving Document failed.") ); | 225 | QMessageBox::warning( this, tr("Details"), tr("Moving Document failed.") ); |
225 | return FALSE; | 226 | return FALSE; |
226 | } | 227 | } |
227 | // remove old lnk | 228 | // remove old lnk |
228 | lnk->removeFiles(); | 229 | lnk->removeFiles(); |
229 | 230 | ||
230 | return TRUE; | 231 | return TRUE; |
231 | } | 232 | } |
232 | 233 | ||
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) | |||
60 | } | 60 | } |
61 | return FALSE; | 61 | return FALSE; |
62 | } | 62 | } |
63 | 63 | ||
64 | StorageInfo::StorageInfo( QObject *parent ) | 64 | StorageInfo::StorageInfo( QObject *parent ) |
65 | : QObject( parent ) | 65 | : QObject( parent ) |
66 | { | 66 | { |
67 | mFileSystems.setAutoDelete( TRUE ); | 67 | mFileSystems.setAutoDelete( TRUE ); |
68 | channel = new QCopChannel( "QPE/Card", this ); | 68 | channel = new QCopChannel( "QPE/Card", this ); |
69 | connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), | 69 | connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), |
70 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); | 70 | this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); |
71 | update(); | 71 | update(); |
72 | } | 72 | } |
73 | 73 | ||
74 | const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) | 74 | const FileSystem *StorageInfo::fileSystemOf( const QString &filename ) |
75 | { | 75 | { |
76 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { | 76 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { |
77 | if ( filename.startsWith( (*i)->path() ) ) | 77 | if ( filename.startsWith( (*i)->path() ) ) |
78 | return (*i); | 78 | return (*i); |
79 | } | 79 | } |
80 | return 0; | 80 | return 0; |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) | 84 | void StorageInfo::cardMessage( const QCString& msg, const QByteArray& ) |
85 | { | 85 | { |
86 | if ( msg == "mtabChanged()" ) | 86 | if ( msg == "mtabChanged()" ) |
87 | update(); | 87 | update(); |
88 | } | 88 | } |
89 | // cause of the lack of a d pointer we need | 89 | // cause of the lack of a d pointer we need |
90 | // to store informations in a config file :( | 90 | // to store informations in a config file :( |
91 | void StorageInfo::update() | 91 | void StorageInfo::update() |
92 | { | 92 | { |
93 | //qDebug("StorageInfo::updating"); | 93 | //qDebug("StorageInfo::updating"); |
94 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 94 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
95 | struct mntent *me; | 95 | struct mntent *me; |
96 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 96 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
97 | 97 | ||
98 | QStringList curdisks; | 98 | QStringList curdisks; |
99 | QStringList curopts; | 99 | QStringList curopts; |
100 | QStringList curfs; | 100 | QStringList curfs; |
101 | bool rebuild = FALSE; | 101 | bool rebuild = FALSE; |
102 | int n=0; | 102 | int n=0; |
103 | if ( mntfp ) { | 103 | if ( mntfp ) { |
104 | while ( (me = getmntent( mntfp )) != 0 ) { | 104 | while ( (me = getmntent( mntfp )) != 0 ) { |
105 | QString fs = me->mnt_fsname; | 105 | QString fs = me->mnt_fsname; |
106 | if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" | 106 | if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd" |
107 | || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" | 107 | || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd" |
108 | || fs.left(8)=="/dev/ram" || fs.left(5)=="tmpfs" ) | 108 | || fs.left(5)=="tmpfs" ) |
109 | { | 109 | { |
110 | n++; | 110 | n++; |
111 | curdisks.append(fs); | 111 | curdisks.append(fs); |
112 | curopts.append( me->mnt_opts ); | 112 | curopts.append( me->mnt_opts ); |
113 | //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); | 113 | //qDebug("-->fs %s opts %s", fs.latin1(), me->mnt_opts ); |
114 | curfs.append( me->mnt_dir ); | 114 | curfs.append( me->mnt_dir ); |
115 | bool found = FALSE; | 115 | bool found = FALSE; |
116 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { | 116 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) { |
117 | if ( (*i)->disk() == fs ) { | 117 | if ( (*i)->disk() == fs ) { |
118 | found = TRUE; | 118 | found = TRUE; |
119 | break; | 119 | break; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | if ( !found ) | 122 | if ( !found ) |
123 | rebuild = TRUE; | 123 | rebuild = TRUE; |
124 | } | 124 | } |
125 | } | 125 | } |
126 | endmntent( mntfp ); | 126 | endmntent( mntfp ); |
127 | } | 127 | } |
128 | if ( rebuild || n != (int)mFileSystems.count() ) { | 128 | if ( rebuild || n != (int)mFileSystems.count() ) { |
129 | mFileSystems.clear(); | 129 | mFileSystems.clear(); |
130 | QStringList::ConstIterator it=curdisks.begin(); | 130 | QStringList::ConstIterator it=curdisks.begin(); |
131 | QStringList::ConstIterator fsit=curfs.begin(); | 131 | QStringList::ConstIterator fsit=curfs.begin(); |
132 | QStringList::ConstIterator optsIt=curopts.begin(); | 132 | QStringList::ConstIterator optsIt=curopts.begin(); |
133 | for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) { | 133 | for (; it!=curdisks.end(); ++it, ++fsit, ++optsIt) { |
134 | QString opts = *optsIt; | 134 | QString opts = *optsIt; |
135 | 135 | ||
136 | QString disk = *it; | 136 | QString disk = *it; |
137 | QString humanname; | 137 | QString humanname; |
138 | bool removable = FALSE; | 138 | bool removable = FALSE; |
139 | if ( isCF(disk) ) { | 139 | if ( isCF(disk) ) { |
140 | humanname = tr("CF Card"); | 140 | humanname = tr("CF Card"); |
141 | removable = TRUE; | 141 | removable = TRUE; |
142 | } else if ( disk == "/dev/hda1" ) { | 142 | } else if ( disk == "/dev/hda1" ) { |
143 | humanname = tr("Hard Disk"); | 143 | humanname = tr("Hard Disk"); |
144 | } else if ( disk.left(9) == "/dev/mmcd" ) { | 144 | } else if ( disk.left(9) == "/dev/mmcd" ) { |
145 | humanname = tr("SD Card"); | 145 | humanname = tr("SD Card"); |
146 | removable = TRUE; | 146 | removable = TRUE; |
147 | } else if ( disk.left(7) == "/dev/hd" ) | 147 | } else if ( disk.left(7) == "/dev/hd" ) |
148 | humanname = tr("Hard Disk") + " " + humanname.mid(7); | 148 | humanname = tr("Hard Disk") + " " + disk.mid(7); |
149 | else if ( disk.left(7) == "/dev/sd" ) | 149 | else if ( disk.left(7) == "/dev/sd" ) |
150 | humanname = tr("SCSI Hard Disk") + " " + humanname.mid(7); | 150 | humanname = tr("SCSI Hard Disk") + " " + disk.mid(7); |
151 | else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs | 151 | else if ( disk.left(14) == "/dev/mtdblock6" ) //openzaurus ramfs |
152 | humanname = tr("Ram FS") + " " + humanname.mid(14); | 152 | humanname = tr("Internal Memory"); |
153 | else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) | 153 | else if ( disk == "/dev/mtdblock1" || humanname == "/dev/mtdblock/1" ) |
154 | humanname = tr("Internal Storage"); | 154 | humanname = tr("Internal Storage"); |
155 | else if ( disk.left(14) == "/dev/mtdblock/" ) | 155 | else if ( disk.left(14) == "/dev/mtdblock/" ) |
156 | humanname = tr("Internal Storage") + " " + humanname.mid(14); | 156 | humanname = tr("Internal Storage") + " " + disk.mid(14); |
157 | else if ( disk.left(13) == "/dev/mtdblock" ) | 157 | else if ( disk.left(13) == "/dev/mtdblock" ) |
158 | humanname = tr("Internal Storage") + " " + humanname.mid(13); | 158 | humanname = tr("Internal Storage") + " " + disk.mid(13); |
159 | else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs | 159 | else if ( disk.left(5) == "tmpfs" ) //ipaqs /mnt/ramfs |
160 | humanname = tr("Ram FS") + " " + humanname.mid(5); | 160 | humanname = tr("Internal Memory"); |
161 | FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); | 161 | FileSystem *fs = new FileSystem( disk, *fsit, humanname, removable, opts ); |
162 | mFileSystems.append( fs ); | 162 | mFileSystems.append( fs ); |
163 | } | 163 | } |
164 | emit disksChanged(); | 164 | emit disksChanged(); |
165 | } else { | 165 | } else { |
166 | // just update them | 166 | // just update them |
167 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) | 167 | for (QListIterator<FileSystem> i(mFileSystems); i.current(); ++i) |
168 | i.current()->update(); | 168 | i.current()->update(); |
169 | } | 169 | } |
170 | #endif | 170 | #endif |
171 | } | 171 | } |
172 | 172 | ||
173 | //--------------------------------------------------------------------------- | 173 | //--------------------------------------------------------------------------- |
174 | 174 | ||
175 | FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) | 175 | FileSystem::FileSystem( const QString &disk, const QString &path, const QString &name, bool rem, const QString &o ) |
176 | : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) | 176 | : fsdisk( disk ), fspath( path ), humanname( name ), blkSize(512), totalBlks(0), availBlks(0), removable( rem ), opts( o ) |
177 | { | 177 | { |
178 | update(); | 178 | update(); |
179 | } | 179 | } |
180 | 180 | ||
181 | void FileSystem::update() | 181 | void FileSystem::update() |
182 | { | 182 | { |
183 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 183 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
184 | struct statfs fs; | 184 | struct statfs fs; |
185 | if ( !statfs( fspath.latin1(), &fs ) ) { | 185 | if ( !statfs( fspath.latin1(), &fs ) ) { |
186 | blkSize = fs.f_bsize; | 186 | blkSize = fs.f_bsize; |
187 | totalBlks = fs.f_blocks; | 187 | totalBlks = fs.f_blocks; |
188 | availBlks = fs.f_bavail; | 188 | availBlks = fs.f_bavail; |
189 | } else { | 189 | } else { |
190 | blkSize = 0; | 190 | blkSize = 0; |
191 | totalBlks = 0; | 191 | totalBlks = 0; |
192 | availBlks = 0; | 192 | availBlks = 0; |
193 | } | 193 | } |
194 | #endif | 194 | #endif |
195 | } | 195 | } |
196 | 196 | ||