[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Forthcoming changes for libsolid
From:       Kevin Ottens <ervin () kde ! org>
Date:       2007-05-26 21:44:19
Message-ID: 200705262344.31785.ervin () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Hi list,

I've been away for two weeks partly due to some commitment regarding my 
researchs. Now I'm back but that means that I had to delay even more some 
important, and less important, changes I planned for libsolid in kdelibs.

So I'm requesting the right to work on the following changes for the coming 
monday (sorry for the late notice) and the next one.

1) solid_isDeviceInterface.patch (monday 28th may)
It simply renames Solid::Device::queryDeviceInterface to 
Solid::Device::isDeviceInterface. This method is not widely used outside of 
libsolid, the template convenience is more commonly used. This is a small 
cleanup, but necessary IMO to improve the discoverability of this API, this 
way the class fully follow the is/as metaphor.

2) (kdelibs|kdebase)_no_Solid_DeviceList.path (monday 28th may)
Get ride of the useless DeviceList typedef. It's really unnecessary IMO, I 
prefer avoid having useless type definitions around. I admit I could live 
without those patches applied, but for completeness I'd feel better with 
it. :-)

3) I'd need to strip out a few features from StorageVolume (monday 4th june). 
In fact, the mount/unmount/eject features should be in a separate interface, 
since it could be applied on other type of devices (at least StorageDrive in 
case of floppy drives). Also, it would make the whole more portable since 
mount/unmount is a very unixy concept that might not exist on other platforms 
and should then be made more generic.
My current plan is to move the eject() method to the OpticalDrive interface, 
where it actually makes sense (for instance this interface already have an 
ejectPressed() signal). And the mount/unmount state management in a separate 
interface. This interface and the methods it'll contains are yet to be 
named... Actually that's my only trouble with them, from a technical 
standpoint it should be an easy change, giving them the right names requires 
some brainstorming. :-)

4) I'd need to rework a bit a few classes, mainly AudioHw, Camera and 
PortableMediaPlayer (monday 4th june). They need to be consistent in the way 
we expose drivers/protocols information. Currently they aren't and they're 
enum based which might quickly prove to be a mistake for future 
extensibility, I'd like to switch them to a string based scheme. I still have 
to work out the details though. But for sure that'll be an API incompatible 
change. Luckily those classes are not widely used yet.

(3) and (4) are not ready yet, and are probably the most important. Without 
those changes the aforementioned device interfaces would probably become 
almost useless even before 4.0 is out, and would for sure become a problem 
for future expansion. In particular, the upgrade path for supporting more 
protocols would be tied to kdelibs release cycle which is not acceptable to 
application not tied to KDE release cycle (think third parties and 
extragear).

Opinions?

If no one object I'll apply the patches for (1) and (2) on monday 28th may 
evenning and start working on (3) and (4) to be able to commit them on monday 
4th june.

Regards.
-- 
Kévin 'ervin' Ottens, http://ervin.ipsquad.net
"Ni le maître sans disciple, Ni le disciple sans maître,
Ne font reculer l'ignorance."

["kdebase_no_Solid_DeviceList.patch" (text/x-diff)]

Index: runtime/solid/hal/halpower.cpp
===================================================================
--- runtime/solid/hal/halpower.cpp	(révision 668407)
+++ runtime/solid/hal/halpower.cpp	(copie de travail)
@@ -342,7 +342,7 @@
 
 void HalPower::computeAcAdapters()
 {
-    Solid::DeviceList adapters
+    QList<Solid::Device> adapters
         = Solid::Device::listFromType(Solid::DeviceInterface::AcAdapter);
 
     foreach (Solid::Device adapter, adapters)
@@ -365,7 +365,7 @@
 
     predicate = predicate.arg((int)Solid::Battery::PrimaryBattery);
 
-    Solid::DeviceList batteries
+    QList<Solid::Device> batteries
         = Solid::Device::listFromType(Solid::DeviceInterface::Battery,
                                                      predicate);
 
@@ -381,7 +381,7 @@
 
 void HalPower::computeButtons()
 {
-    Solid::DeviceList buttons
+    QList<Solid::Device> buttons
         = Solid::Device::listFromType(Solid::DeviceInterface::Button);
 
     foreach (Solid::Device button, buttons)
Index: runtime/kioslave/trash/trashimpl.cpp
===================================================================
--- runtime/kioslave/trash/trashimpl.cpp	(révision 668407)
+++ runtime/kioslave/trash/trashimpl.cpp	(copie de travail)
@@ -747,7 +747,7 @@
     return m_lastId;
 #endif
 
-    const Solid::DeviceList lst = \
Solid::Device::listFromQuery("StorageVolume.mounted == true AND \
StorageVolume.mountPoint == '"+mountPoint+"'"); +    const QList<Solid::Device> lst = \
Solid::Device::listFromQuery("StorageVolume.mounted == true AND \
                StorageVolume.mountPoint == '"+mountPoint+"'");
     if ( lst.isEmpty() ) // not a device. Maybe some tmpfs mount for instance.
         return 0; // use the home trash instead
     // Pretend we got exactly one...
@@ -766,8 +766,8 @@
 
 void TrashImpl::scanTrashDirectories() const
 {
-    const Solid::DeviceList lst = \
                Solid::Device::listFromQuery("StorageVolume.mounted == true");
-    for ( Solid::DeviceList::ConstIterator it = lst.begin() ; it != lst.end() ; ++it \
) { +    const QList<Solid::Device> lst = \
Solid::Device::listFromQuery("StorageVolume.mounted == true"); +    for ( \
QList<Solid::Device>::ConstIterator it = lst.begin() ; it != lst.end() ; ++it ) {  \
QString topdir = (*it).as<Solid::StorageVolume>()->mountPoint();  QString trashDir = \
trashForMountPoint( topdir, false );  if ( !trashDir.isEmpty() ) {


["kdelibs_no_Solid_DeviceList.patch" (text/x-diff)]

Index: kio/kfile/kdevicelistmodel.cpp
===================================================================
--- kio/kfile/kdevicelistmodel.cpp	(révision 668407)
+++ kio/kfile/kdevicelistmodel.cpp	(copie de travail)
@@ -228,9 +228,9 @@
 
     // Use allDevices() from the manager if the predicate is not valid
     // otherwise the returned list is empty
-    const Solid::DeviceList &deviceList = predicate.isValid()?
-                                          Solid::Device::listFromQuery(predicate)
-                                        : Solid::Device::allDevices();
+    const QList<Solid::Device> &deviceList = predicate.isValid()?
+                                             Solid::Device::listFromQuery(predicate)
+                                           : Solid::Device::allDevices();
 
     foreach(Solid::Device device, deviceList)
     {
Index: solid/tests/solidhwtest.cpp
===================================================================
--- solid/tests/solidhwtest.cpp	(révision 668407)
+++ solid/tests/solidhwtest.cpp	(copie de travail)
@@ -53,7 +53,7 @@
 
 void SolidHwTest::testAllDevices()
 {
-    Solid::DeviceList devices = Solid::Device::allDevices();
+    QList<Solid::Device> devices = Solid::Device::allDevices();
 
     // Verify that the framework reported correctly the devices available
     // in the backend.
@@ -308,7 +308,7 @@
     QCOMPARE((int)Solid::DeviceInterface::stringToType("blup"), -1);
 }
 
-static QSet<QString> to_string_set(const Solid::DeviceList &list)
+static QSet<QString> to_string_set(const QList<Solid::Device> &list)
 {
     QSet<QString> res;
 
@@ -381,7 +381,7 @@
 
     parentUdi = QString();
     ifaceType = Solid::DeviceInterface::Unknown;
-    Solid::DeviceList list;
+    QList<Solid::Device> list;
 
     list = Solid::Device::listFromQuery(p1, parentUdi);
     QCOMPARE(list.size(), 2);
Index: solid/solid/device.h
===================================================================
--- solid/solid/device.h	(révision 668407)
+++ solid/solid/device.h	(copie de travail)
@@ -239,8 +239,6 @@
         QExplicitlySharedDataPointer<DevicePrivate> d;
         friend class DeviceManagerPrivate;
     };
-
-    typedef QList<Device> DeviceList;
 }
 
 #endif

["solid_isDeviceInterface.patch" (text/x-diff)]

Index: kio/kfile/kdevicelistmodel.cpp
===================================================================
--- kio/kfile/kdevicelistmodel.cpp	(révision 668407)
+++ kio/kfile/kdevicelistmodel.cpp	(copie de travail)
@@ -109,27 +109,27 @@
         }
         else
         {
-            if (device.queryDeviceInterface(Solid::DeviceInterface::OpticalDrive))
+            if (device.isDeviceInterface(Solid::DeviceInterface::OpticalDrive))
             {
                 iconName = "cdrom-unmount";
             }
-            else if (device.queryDeviceInterface(Solid::DeviceInterface::PortableMediaPlayer))
+            else if (device.isDeviceInterface(Solid::DeviceInterface::PortableMediaPlayer))
             {
                 iconName = "ipod-unmount";
             }
-            else if (device.queryDeviceInterface(Solid::DeviceInterface::Camera))
+            else if (device.isDeviceInterface(Solid::DeviceInterface::Camera))
             {
                 iconName = "camera-unmount";
             }
-            else if(device.queryDeviceInterface(Solid::DeviceInterface::Processor))
+            else if(device.isDeviceInterface(Solid::DeviceInterface::Processor))
             {
                 iconName = "ksim-cpu";
             }
-            else if (device.queryDeviceInterface(Solid::DeviceInterface::StorageDrive))
+            else if (device.isDeviceInterface(Solid::DeviceInterface::StorageDrive))
             {
                 iconName = "hdd-unmount";
             }
-            else if (device.queryDeviceInterface(Solid::DeviceInterface::Block))
+            else if (device.isDeviceInterface(Solid::DeviceInterface::Block))
             {
                 iconName = "blockdevice";
             }
Index: solid/tests/solidhwtest.cpp
===================================================================
--- solid/tests/solidhwtest.cpp	(révision 668407)
+++ solid/tests/solidhwtest.cpp	(copie de travail)
@@ -106,12 +106,12 @@
 
 
     // Query device interfaces
-    QCOMPARE(valid_dev.queryDeviceInterface(Solid::DeviceInterface::StorageDrive), true);
-    QCOMPARE(valid_dev.queryDeviceInterface(Solid::DeviceInterface::OpticalDrive), true);
-    QCOMPARE(valid_dev.queryDeviceInterface(Solid::DeviceInterface::StorageVolume), false);
+    QCOMPARE(valid_dev.isDeviceInterface(Solid::DeviceInterface::StorageDrive), true);
+    QCOMPARE(valid_dev.isDeviceInterface(Solid::DeviceInterface::OpticalDrive), true);
+    QCOMPARE(valid_dev.isDeviceInterface(Solid::DeviceInterface::StorageVolume), false);
 
-    QCOMPARE(invalid_dev.queryDeviceInterface(Solid::DeviceInterface::Unknown), false);
-    QCOMPARE(invalid_dev.queryDeviceInterface(Solid::DeviceInterface::StorageDrive), false);
+    QCOMPARE(invalid_dev.isDeviceInterface(Solid::DeviceInterface::Unknown), false);
+    QCOMPARE(invalid_dev.isDeviceInterface(Solid::DeviceInterface::StorageDrive), false);
 
 
     // Query parent
@@ -235,7 +235,7 @@
     Solid::DeviceInterface *iface = cpu.asDeviceInterface(Solid::DeviceInterface::Processor);
     Solid::Processor *processor = cpu.as<Solid::Processor>();
 
-    QVERIFY(cpu.queryDeviceInterface(Solid::DeviceInterface::Processor));
+    QVERIFY(cpu.isDeviceInterface(Solid::DeviceInterface::Processor));
     QVERIFY(iface!=0);
     QCOMPARE(iface, processor);
 
Index: solid/solid/predicate.cpp
===================================================================
--- solid/solid/predicate.cpp	(révision 668407)
+++ solid/solid/predicate.cpp	(copie de travail)
@@ -213,7 +213,7 @@
         break;
     }
     case Private::IsType:
-        return device.queryDeviceInterface(d->ifaceType);
+        return device.isDeviceInterface(d->ifaceType);
     }
 
     return false;
Index: solid/solid/device.h
===================================================================
--- solid/solid/device.h	(révision 668407)
+++ solid/solid/device.h	(copie de travail)
@@ -179,7 +179,7 @@
          * @param type the device interface type to query
          * @return true if the device interface is available, false otherwise
          */
-        bool queryDeviceInterface(const DeviceInterface::Type &type) const;
+        bool isDeviceInterface(const DeviceInterface::Type &type) const;
 
         /**
          * Retrieves a specialized interface to interact with the device corresponding to
@@ -232,7 +232,7 @@
          */
         template <class DevIface> bool is() const
         {
-            return queryDeviceInterface(DevIface::deviceInterfaceType());
+            return isDeviceInterface(DevIface::deviceInterfaceType());
         }
 
     private:
Index: solid/solid/device.cpp
===================================================================
--- solid/solid/device.cpp	(révision 668407)
+++ solid/solid/device.cpp	(copie de travail)
@@ -120,7 +120,7 @@
     return_SOLID_CALL(Ifaces::Device *, d->backendObject(), QString(), product());
 }
 
-bool Solid::Device::queryDeviceInterface(const DeviceInterface::Type &type) const
+bool Solid::Device::isDeviceInterface(const DeviceInterface::Type &type) const
 {
     return_SOLID_CALL(Ifaces::Device *, d->backendObject(), false, queryDeviceInterface(type));
 }

[Attachment #8 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic