Thank you for direct links:) In fact, you used classes from QtMobility.
Lets compare 2 APIs:
https://qt.gitorious.org/qt/qtsystems/blobs/master/src/systeminfo/qstorageinfo.h
https://gitorious.org/qdrive/qdrive/blobs/master/src/qdriveinfo.h
The main difference is that you use one single class for all drives; i use
struct that represents one specific drive.
The advantages you have - only 1 class:), you can monitor drives via same class
and you can use easily it from script.
Disadvantages - you have to pass same string for each method to retrieve
different information for one drive; your API is not intuitive i think.
In my implementation, i tried to keep API already used in Qt and maid my class
very similar to QFileInfo. Also my API is similar to lib solid.
Let i show some example:
void useInfo(QString path, qint64 size, qint64 total, DriveType type) {…}
useInfo(pathToDrive ,
storageInfo->availableDiskSpace(pathToDrive),
storageInfo->totalDiskSpace(pathToDrive)),
storageInfo->driveType(pathToDrive)));
my variant:
QDriveInfo drive(pathToDrive);
useInfo(drive.rootPath(), // real root path, not pathToDrive, which can be
folder on drive
drive.bytesAvailable(),
drive.bytesTotal(),
drive.type());
I used only same parameters which both present in your variant and mine. If
number of parameters will grow up, you will have hell with passing pathToDrive
every time.
Next, my variant uses cache, like QFileInfo (it requires only one call for all
3 sizes - total/available/free), you API makes using cache much harder (public
function void clearCache(const QString &drive) to clear cache for specific
drive? hmmm).
The other use case is to compare drives - i can specify path to two
folders/file and compare if these fs entries belongs to same drive:
QDriveInfo(pathToFolder1) == QDriveInfo(pathToFolder2) That can be useful when
moving files - if source and dest on same drive, it's simply QFile::rename,
otherwise you need to copy whole file (maybe in thread). Current implementation
doesn't allow that.
Notification about appearing of new drives - i think that should be done using
separate class, like QFileSystemWatcher. The advantage is that you can add
notification about _request_ for eject and perform some actions (free resources
- close files, remove FSWatcherMonitoring). In current implementation we will
have 2 different use cases in one class - gathering info (1) and monitoring and
even controlling (2) (i.e. changing label, mounting/unmouting) of drives.
The only advantage you have is that your class is "scriptable", but we can
easily write wrapper - QVariantMap/or class derived from QObject
About dbus - i suggested to merge my class in QtCore in 4.8, but i didn't
finished merge request before tech preview. So, in qtcore i couldn't use dubs.
But if you have specific module for system info, no one stops me from using it,
like you do. So implementation will be almost the same (as far as i remember,
there was some bugs in QtMobylity storage info classes, in my code i think
everything is tested properly).
In fact, i can add d-bus implementation to my classes and replace current
implementation in qtsystems module.
What do you think?
> 08.08.2011, в 12:40, <[email protected]> <[email protected]> написал(а):
>
> Hi,
>
> I mean for Qt5, in the QtSystems module. The source is at:
> http://qt.gitorious.org/qt/qtsystems/trees/master/src/systeminfo
>
> All the ex-system info classes are part of the QtSystems module, more info at:
> http://developer.qt.nokia.com/wiki/Qt_5.0
>
> Yes, blkid requires root privilege, and I'm not really a fan of D-Bus calls.
> The other alternative is to retrieve from /dev/disk/, and probably I'll use
> that later (need to check its stability and availability on different Linux
> distros).
>
> ================
> Xizhi Zhu (Steven)
>
> Software Engineer @ Qt
> Nokia
>
> Mobile: +358 (0)50 4801247
>
>
> -----Original Message-----
> From: ext Иван Комиссаров [mailto:[email protected]]
> Sent: 08. elokuuta 2011 11:28
> To: Zhu Xizhi (Nokia-MP-Qt/Tampere)
> Subject: Re: [Qt5-feedback] Drive Information
>
> "Currently have" where? In Qt Mobility? API of QStrorageInfo is awful I
> believe this functionality should be in QtCore, and you can't use dbus there.
> As for blkid it seems requires root privileges in most cases.
>
>> 08.08.2011, в 10:54, <[email protected]> <[email protected]> написал(а):
>>
>> Hi,
>>
>> For storage info in Qt5, we currently have:
>> allLogicalDrives - use getmntent()
>> availableDiskSpace - use statfs()
>> totalDiskSpace - use statfs()
>> uriForDrive - use BLKID or UDisks (D-Bus) driveType - use getmntent()
>> directly for RAM, Remote, and CDROM, and /sys/block/*/removable for
>> Internal and Removable logicalDriveChanged (signal) - monitor changes
>> of the _PATH_MOUNTED file
>>
>> ================
>> Xizhi Zhu (Steven)
>>
>> Software Engineer @ Qt
>> Nokia
>>
>> Mobile: +358 (0)50 4801247
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of
>> ext ???? ??????????
>> Sent: 05. elokuuta 2011 23:50
>> To: [email protected]
>> Subject: Re: [Qt5-feedback] Drive Information
>>
>> Want to update this conversation:)
>> What mechanism will be used in qt5?
>>
>> 08.07.2011, в 10:24, <[email protected]> <[email protected]> написал(а):
>>
>> Hi,
>>
>> Seems your code is more or less similar to the latest implementation (I only
>> briefly looked at the Linux one), but we take different approach for caching.
>> Your idea for file system type and drive name / label (we have UUID on the
>> other hand, but maybe not as readable as label) seem interesting.
>>
>> You can check the latest code (still under development, and some more will
>> be published soon) at:
>> http://qt.gitorious.org/qt/qtsystems/blobs/master/src/systeminfo/qstor
>> ageinfo.h
>>
>> ================
>> Xizhi Zhu (Steven)
>>
>> Software Engineer @ Qt
>> Nokia
>>
>> Mobile: +358 (0)50 4801247
>>
>>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of
>> ext ???? ??????????
>> Sent: 07. heinäkuuta 2011 22:07
>> To: [email protected]
>> Subject: [Qt5-feedback] Drive Information
>>
>> I've written class for receiving different information about drives
>> present in filesystem
>> (https://gitorious.org/qdrive/qdrive/blobs/master/src/qdriveinfo.h)
>> Class is implemented for Windows, Mac OS, Linux and Symbian and
>> implementation is better than in QtMobility.
>>
>> Does Qt5 needs this functionality?
>>
>> In fact, it seems that such classes exists in libsolid, but why not to move
>> code to QtCore on platforms supported by Qt?
>>
>> Also i have class for monitoring of appearance of drives in system
>> (https://gitorious.org/qdrive/qdrive/blobs/master/src/qdrivecontroller
>> .h). This monitoring can be expanded to provide request for
>> application that OS wants to unmount volume (and Qt and app can
>> unregister resources on that drive - for example QFSWatcher still
>> locks flash drives on Win and they can't be unmounted properly; we can
>> monitor requests and free resources correctly)
>>
>> Ivan.
>> _______________________________________________
>> Qt5-feedback mailing list
>> [email protected]
>> http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
>>
>> _______________________________________________
>> Qt5-feedback mailing list
>> [email protected]
>> http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback
>>
>
_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback