Changeset View
Changeset View
Standalone View
Standalone View
src/solid/devices/backends/shared/udevqtclient.cpp
Show First 20 Lines • Show All 209 Lines • ▼ Show 20 Line(s) | |||||
210 | DeviceList Client::devicesBySubsystem(const QString &subsystem) | 210 | DeviceList Client::devicesBySubsystem(const QString &subsystem) | ||
211 | { | 211 | { | ||
212 | struct udev_enumerate *en = udev_enumerate_new(d->udev); | 212 | struct udev_enumerate *en = udev_enumerate_new(d->udev); | ||
213 | 213 | | |||
214 | udev_enumerate_add_match_subsystem(en, subsystem.toLatin1().constData()); | 214 | udev_enumerate_add_match_subsystem(en, subsystem.toLatin1().constData()); | ||
215 | return d->deviceListFromEnumerate(en); | 215 | return d->deviceListFromEnumerate(en); | ||
216 | } | 216 | } | ||
217 | 217 | | |||
218 | DeviceList Client::devicesBySubsystemsAndProperties(const QStringList &subsystems, const QVariantMap &properties) | ||||
219 | { | ||||
220 | struct udev_enumerate *en = udev_enumerate_new(d->udev); | ||||
221 | | ||||
222 | for (const QString &subsystem : subsystems) { | ||||
223 | udev_enumerate_add_match_subsystem(en, subsystem.toLatin1().constData()); | ||||
bruns: Nitpick - the existing code uses `toLatin1()`, and for the ASCII subset it doesn't matter, but… | |||||
This is just copied from the other code. I can fixup all of them separately later if you want. broulik: This is just copied from the other code. I can fixup all of them separately later if you want. | |||||
Yes, thats completely fine for me - I was just looking through the code and picking up everything that should be fixed. bruns: Yes, thats completely fine for me - I was just looking through the code and picking up… | |||||
224 | } | ||||
225 | | ||||
226 | for (auto it = properties.begin(), end = properties.end(); it != end; ++it) { | ||||
227 | if (it.value().isValid()) { | ||||
228 | udev_enumerate_add_match_property(en, it.key().toLatin1().constData(), it.value().toString().toLatin1().constData()); | ||||
229 | } else { | ||||
230 | udev_enumerate_add_match_property(en, it.key().toLatin1().constData(), nullptr); | ||||
231 | } | ||||
232 | } | ||||
233 | | ||||
234 | return d->deviceListFromEnumerate(en); | ||||
235 | } | ||||
236 | | ||||
218 | Device Client::deviceByDeviceFile(const QString &deviceFile) | 237 | Device Client::deviceByDeviceFile(const QString &deviceFile) | ||
219 | { | 238 | { | ||
220 | QT_STATBUF sb; | 239 | QT_STATBUF sb; | ||
221 | 240 | | |||
222 | if (QT_STAT(deviceFile.toLatin1().constData(), &sb) != 0) { | 241 | if (QT_STAT(deviceFile.toLatin1().constData(), &sb) != 0) { | ||
223 | return Device(); | 242 | return Device(); | ||
224 | } | 243 | } | ||
225 | 244 | | |||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |
Nitpick - the existing code uses toLatin1(), and for the ASCII subset it doesn't matter, but I am quite sure properties and values are UTF8 in general.
I have no strong proof, but the udev changelog has: