From kde-core-devel Sat May 26 21:44:19 2007 From: Kevin Ottens Date: Sat, 26 May 2007 21:44:19 +0000 To: kde-core-devel Subject: Forthcoming changes for libsolid Message-Id: <200705262344.31785.ervin () kde ! org> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=118021590631281 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--nextPart1461087.mGP7SrsKxv" --nextPart1461087.mGP7SrsKxv Content-Type: multipart/mixed; boundary="Boundary-01=_1oKWGEgSmbeb0Ro" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_1oKWGEgSmbeb0Ro Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi list, I've been away for two weeks partly due to some commitment regarding my=20 researchs. Now I'm back but that means that I had to delay even more some=20 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= =20 monday (sorry for the late notice) and the next one. 1) solid_isDeviceInterface.patch (monday 28th may) It simply renames Solid::Device::queryDeviceInterface to=20 Solid::Device::isDeviceInterface. This method is not widely used outside of= =20 libsolid, the template convenience is more commonly used. This is a small=20 cleanup, but necessary IMO to improve the discoverability of this API, this= =20 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= =20 prefer avoid having useless type definitions around. I admit I could live=20 without those patches applied, but for completeness I'd feel better with=20 it. :-) 3) I'd need to strip out a few features from StorageVolume (monday 4th june= ).=20 In fact, the mount/unmount/eject features should be in a separate interface= ,=20 since it could be applied on other type of devices (at least StorageDrive i= n=20 case of floppy drives). Also, it would make the whole more portable since=20 mount/unmount is a very unixy concept that might not exist on other platfor= ms=20 and should then be made more generic. My current plan is to move the eject() method to the OpticalDrive interface= ,=20 where it actually makes sense (for instance this interface already have an= =20 ejectPressed() signal). And the mount/unmount state management in a separat= e=20 interface. This interface and the methods it'll contains are yet to be=20 named... Actually that's my only trouble with them, from a technical=20 standpoint it should be an easy change, giving them the right names require= s=20 some brainstorming. :-) 4) I'd need to rework a bit a few classes, mainly AudioHw, Camera and=20 PortableMediaPlayer (monday 4th june). They need to be consistent in the wa= y=20 we expose drivers/protocols information. Currently they aren't and they're= =20 enum based which might quickly prove to be a mistake for future=20 extensibility, I'd like to switch them to a string based scheme. I still ha= ve=20 to work out the details though. But for sure that'll be an API incompatible= =20 change. Luckily those classes are not widely used yet. (3) and (4) are not ready yet, and are probably the most important. Without= =20 those changes the aforementioned device interfaces would probably become=20 almost useless even before 4.0 is out, and would for sure become a problem= =20 for future expansion. In particular, the upgrade path for supporting more=20 protocols would be tied to kdelibs release cycle which is not acceptable to= =20 application not tied to KDE release cycle (think third parties and=20 extragear). Opinions? If no one object I'll apply the patches for (1) and (2) on monday 28th may= =20 evenning and start working on (3) and (4) to be able to commit them on mond= ay=20 4th june. Regards. =2D-=20 K=E9vin 'ervin' Ottens, http://ervin.ipsquad.net "Ni le ma=EEtre sans disciple, Ni le disciple sans ma=EEtre, Ne font reculer l'ignorance." --Boundary-01=_1oKWGEgSmbeb0Ro Content-Type: text/x-diff; charset="iso-8859-15"; name="kdebase_no_Solid_DeviceList.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="kdebase_no_Solid_DeviceList.patch" Index: runtime/solid/hal/halpower.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- runtime/solid/hal/halpower.cpp (r=C3=A9vision 668407) +++ runtime/solid/hal/halpower.cpp (copie de travail) @@ -342,7 +342,7 @@ =20 void HalPower::computeAcAdapters() { =2D Solid::DeviceList adapters + QList adapters =3D Solid::Device::listFromType(Solid::DeviceInterface::AcAdapter); =20 foreach (Solid::Device adapter, adapters) @@ -365,7 +365,7 @@ =20 predicate =3D predicate.arg((int)Solid::Battery::PrimaryBattery); =20 =2D Solid::DeviceList batteries + QList batteries =3D Solid::Device::listFromType(Solid::DeviceInterface::Battery, predicate); =20 @@ -381,7 +381,7 @@ =20 void HalPower::computeButtons() { =2D Solid::DeviceList buttons + QList buttons =3D Solid::Device::listFromType(Solid::DeviceInterface::Button); =20 foreach (Solid::Device button, buttons) Index: runtime/kioslave/trash/trashimpl.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- runtime/kioslave/trash/trashimpl.cpp (r=C3=A9vision 668407) +++ runtime/kioslave/trash/trashimpl.cpp (copie de travail) @@ -747,7 +747,7 @@ return m_lastId; #endif =20 =2D const Solid::DeviceList lst =3D Solid::Device::listFromQuery("Storag= eVolume.mounted =3D=3D true AND StorageVolume.mountPoint =3D=3D '"+mountPoi= nt+"'"); + const QList lst =3D Solid::Device::listFromQuery("Stora= geVolume.mounted =3D=3D true AND StorageVolume.mountPoint =3D=3D '"+mountPo= int+"'"); if ( lst.isEmpty() ) // not a device. Maybe some tmpfs mount for insta= nce. return 0; // use the home trash instead // Pretend we got exactly one... @@ -766,8 +766,8 @@ =20 void TrashImpl::scanTrashDirectories() const { =2D const Solid::DeviceList lst =3D Solid::Device::listFromQuery("Storag= eVolume.mounted =3D=3D true"); =2D for ( Solid::DeviceList::ConstIterator it =3D lst.begin() ; it !=3D = lst.end() ; ++it ) { + const QList lst =3D Solid::Device::listFromQuery("Stora= geVolume.mounted =3D=3D true"); + for ( QList::ConstIterator it =3D lst.begin() ; it !=3D= lst.end() ; ++it ) { QString topdir =3D (*it).as()->mountPoint(); QString trashDir =3D trashForMountPoint( topdir, false ); if ( !trashDir.isEmpty() ) { --Boundary-01=_1oKWGEgSmbeb0Ro Content-Type: text/x-diff; charset="iso-8859-15"; name="kdelibs_no_Solid_DeviceList.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="kdelibs_no_Solid_DeviceList.patch" Index: kio/kfile/kdevicelistmodel.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- kio/kfile/kdevicelistmodel.cpp (r=C3=A9vision 668407) +++ kio/kfile/kdevicelistmodel.cpp (copie de travail) @@ -228,9 +228,9 @@ =20 // Use allDevices() from the manager if the predicate is not valid // otherwise the returned list is empty =2D const Solid::DeviceList &deviceList =3D predicate.isValid()? =2D Solid::Device::listFromQuery(p= redicate) =2D : Solid::Device::allDevices(); + const QList &deviceList =3D predicate.isValid()? + Solid::Device::listFromQuery(= predicate) + : Solid::Device::allDevices(); =20 foreach(Solid::Device device, deviceList) { Index: solid/tests/solidhwtest.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- solid/tests/solidhwtest.cpp (r=C3=A9vision 668407) +++ solid/tests/solidhwtest.cpp (copie de travail) @@ -53,7 +53,7 @@ =20 void SolidHwTest::testAllDevices() { =2D Solid::DeviceList devices =3D Solid::Device::allDevices(); + QList devices =3D Solid::Device::allDevices(); =20 // Verify that the framework reported correctly the devices available // in the backend. @@ -308,7 +308,7 @@ QCOMPARE((int)Solid::DeviceInterface::stringToType("blup"), -1); } =20 =2Dstatic QSet to_string_set(const Solid::DeviceList &list) +static QSet to_string_set(const QList &list) { QSet res; =20 @@ -381,7 +381,7 @@ =20 parentUdi =3D QString(); ifaceType =3D Solid::DeviceInterface::Unknown; =2D Solid::DeviceList list; + QList list; =20 list =3D Solid::Device::listFromQuery(p1, parentUdi); QCOMPARE(list.size(), 2); Index: solid/solid/device.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- solid/solid/device.h (r=C3=A9vision 668407) +++ solid/solid/device.h (copie de travail) @@ -239,8 +239,6 @@ QExplicitlySharedDataPointer d; friend class DeviceManagerPrivate; }; =2D =2D typedef QList DeviceList; } =20 #endif --Boundary-01=_1oKWGEgSmbeb0Ro Content-Type: text/x-diff; charset="iso-8859-15"; name="solid_isDeviceInterface.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="solid_isDeviceInterface.patch" Index: kio/kfile/kdevicelistmodel.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- kio/kfile/kdevicelistmodel.cpp (r=C3=A9vision 668407) +++ kio/kfile/kdevicelistmodel.cpp (copie de travail) @@ -109,27 +109,27 @@ } else { =2D if (device.queryDeviceInterface(Solid::DeviceInterface::Opti= calDrive)) + if (device.isDeviceInterface(Solid::DeviceInterface::OpticalDr= ive)) { iconName =3D "cdrom-unmount"; } =2D else if (device.queryDeviceInterface(Solid::DeviceInterface:= :PortableMediaPlayer)) + else if (device.isDeviceInterface(Solid::DeviceInterface::Port= ableMediaPlayer)) { iconName =3D "ipod-unmount"; } =2D else if (device.queryDeviceInterface(Solid::DeviceInterface:= :Camera)) + else if (device.isDeviceInterface(Solid::DeviceInterface::Came= ra)) { iconName =3D "camera-unmount"; } =2D else if(device.queryDeviceInterface(Solid::DeviceInterface::= Processor)) + else if(device.isDeviceInterface(Solid::DeviceInterface::Proce= ssor)) { iconName =3D "ksim-cpu"; } =2D else if (device.queryDeviceInterface(Solid::DeviceInterface:= :StorageDrive)) + else if (device.isDeviceInterface(Solid::DeviceInterface::Stor= ageDrive)) { iconName =3D "hdd-unmount"; } =2D else if (device.queryDeviceInterface(Solid::DeviceInterface:= :Block)) + else if (device.isDeviceInterface(Solid::DeviceInterface::Bloc= k)) { iconName =3D "blockdevice"; } Index: solid/tests/solidhwtest.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- solid/tests/solidhwtest.cpp (r=C3=A9vision 668407) +++ solid/tests/solidhwtest.cpp (copie de travail) @@ -106,12 +106,12 @@ =20 =20 // Query device interfaces =2D QCOMPARE(valid_dev.queryDeviceInterface(Solid::DeviceInterface::Stor= ageDrive), true); =2D QCOMPARE(valid_dev.queryDeviceInterface(Solid::DeviceInterface::Opti= calDrive), true); =2D QCOMPARE(valid_dev.queryDeviceInterface(Solid::DeviceInterface::Stor= ageVolume), false); + QCOMPARE(valid_dev.isDeviceInterface(Solid::DeviceInterface::StorageDr= ive), true); + QCOMPARE(valid_dev.isDeviceInterface(Solid::DeviceInterface::OpticalDr= ive), true); + QCOMPARE(valid_dev.isDeviceInterface(Solid::DeviceInterface::StorageVo= lume), false); =20 =2D QCOMPARE(invalid_dev.queryDeviceInterface(Solid::DeviceInterface::Un= known), false); =2D QCOMPARE(invalid_dev.queryDeviceInterface(Solid::DeviceInterface::St= orageDrive), false); + QCOMPARE(invalid_dev.isDeviceInterface(Solid::DeviceInterface::Unknown= ), false); + QCOMPARE(invalid_dev.isDeviceInterface(Solid::DeviceInterface::Storage= Drive), false); =20 =20 // Query parent @@ -235,7 +235,7 @@ Solid::DeviceInterface *iface =3D cpu.asDeviceInterface(Solid::DeviceI= nterface::Processor); Solid::Processor *processor =3D cpu.as(); =20 =2D QVERIFY(cpu.queryDeviceInterface(Solid::DeviceInterface::Processor)); + QVERIFY(cpu.isDeviceInterface(Solid::DeviceInterface::Processor)); QVERIFY(iface!=3D0); QCOMPARE(iface, processor); =20 Index: solid/solid/predicate.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- solid/solid/predicate.cpp (r=C3=A9vision 668407) +++ solid/solid/predicate.cpp (copie de travail) @@ -213,7 +213,7 @@ break; } case Private::IsType: =2D return device.queryDeviceInterface(d->ifaceType); + return device.isDeviceInterface(d->ifaceType); } =20 return false; Index: solid/solid/device.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- solid/solid/device.h (r=C3=A9vision 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 otherw= ise */ =2D bool queryDeviceInterface(const DeviceInterface::Type &type) con= st; + bool isDeviceInterface(const DeviceInterface::Type &type) const; =20 /** * Retrieves a specialized interface to interact with the device c= orresponding to @@ -232,7 +232,7 @@ */ template bool is() const { =2D return queryDeviceInterface(DevIface::deviceInterfaceType()); + return isDeviceInterface(DevIface::deviceInterfaceType()); } =20 private: Index: solid/solid/device.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- solid/solid/device.cpp (r=C3=A9vision 668407) +++ solid/solid/device.cpp (copie de travail) @@ -120,7 +120,7 @@ return_SOLID_CALL(Ifaces::Device *, d->backendObject(), QString(), pro= duct()); } =20 =2Dbool Solid::Device::queryDeviceInterface(const DeviceInterface::Type &ty= pe) const +bool Solid::Device::isDeviceInterface(const DeviceInterface::Type &type) c= onst { return_SOLID_CALL(Ifaces::Device *, d->backendObject(), false, queryDe= viceInterface(type)); } --Boundary-01=_1oKWGEgSmbeb0Ro-- --nextPart1461087.mGP7SrsKxv Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBGWKo/B0u7y43syeIRAtEMAJoDgUbzdWTl7YXpJwZq4RgNTt/lXACfWyKH z7AUvfAgb8YZUrW4DMs++FE= =+epm -----END PGP SIGNATURE----- --nextPart1461087.mGP7SrsKxv--