summaryrefslogtreecommitdiff
path: root/x11/kdelibs4/files/patch-git_e405fa9
blob: 64f3b0320dba7c90e319ba3e057eee5ccd228d5e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
commit e405fa978b3c308249a5d553b784d3f8b277fd35
Author: Raphael Kubo da Costa <rakuco@FreeBSD.org>
Date:   Wed Jul 18 22:32:41 2012 -0300

    HAL: Use the filtering code in HalDevice in devicesFromQuery().
    
    Follow what other backends such as the UDisks one do and simply relay
    the required checks for validity to each Device we are interested in.
    
    So far, HalDevice::queryDeviceInterface() performed some checks
    depending on the DeviceInterface type being passed to it, while
    HalManager::devicesFromQuery() did not filter the results it got in
    the same way. What's more, some checks such as the video4linux ones
    were being made in both places, leading to some needless duplication
    in functionality.
    
    As a side-effect, this fixes a bug made visibile by a recent commit to
    libktorrent: retrieving StorageAccess devices with listFromType()
    would simply query HAL for devices with the "volume" capability (which
    includes swap partitions and other non-mountable things), so using
    Device::asDeviceInterface(Solid::DeviceInterface::StorageAccess) would
    sometimes return 0 on a few of those entries retrieved earlier.
    
    Reviewed-by:	Alberto Villa <avilla@FreeBSD.org>
    REVIEW:		105615

diff --git a/solid/solid/backends/hal/halmanager.cpp b/solid/solid/backends/hal/halmanager.cpp
index 2c9c6c0..7238b6a 100644
--- solid/solid/backends/hal/halmanager.cpp
+++ solid/solid/backends/hal/halmanager.cpp
@@ -147,30 +147,27 @@ bool HalManager::deviceExists(const QString &udi)
 QStringList HalManager::devicesFromQuery(const QString &parentUdi,
                                          Solid::DeviceInterface::Type type)
 {
-    if (!parentUdi.isEmpty())
-    {
-        QStringList result = findDeviceStringMatch("info.parent", parentUdi);
+    if ((parentUdi.isEmpty()) && (type == Solid::DeviceInterface::Unknown)) {
+        return allDevices();
+    }
 
-        if (type!=Solid::DeviceInterface::Unknown) {
-            const QStringList matches = result;
-            result.clear();
+    QStringList result;
 
-            foreach (const QString &match, matches) {
-                HalDevice device(match);
+    foreach (const QString &udi, allDevices()) {
+        HalDevice device(udi);
 
-                if (device.queryDeviceInterface(type)) {
-                    result << match;
-                }
-            }
+        if ((!parentUdi.isEmpty()) && (parentUdi != device.parentUdi())) {
+            continue;
         }
 
-        return result;
+        if ((type != Solid::DeviceInterface::Unknown) && (!device.queryDeviceInterface(type))) {
+            continue;
+        }
 
-    } else if (type!=Solid::DeviceInterface::Unknown) {
-        return findDeviceByDeviceInterface(type);
-    } else {
-        return allDevices();
+        result << udi;
     }
+
+    return result;
 }
 
 QObject *HalManager::createDevice(const QString &udi)
@@ -182,63 +179,6 @@ QObject *HalManager::createDevice(const QString &udi)
     }
 }
 
-QStringList HalManager::findDeviceStringMatch(const QString &key, const QString &value)
-{
-    QDBusReply<QStringList> reply = d->manager.call("FindDeviceStringMatch", key, value);
-
-    if (!reply.isValid())
-    {
-        qWarning() << Q_FUNC_INFO << " error: " << reply.error().name() << endl;
-        return QStringList();
-    }
-
-    return reply;
-}
-
-QStringList HalManager::findDeviceByDeviceInterface(Solid::DeviceInterface::Type type)
-{
-    QStringList cap_list = DeviceInterface::toStringList(type);
-    QStringList result;
-
-    foreach (const QString &cap, cap_list)
-    {
-        QDBusReply<QStringList> reply = d->manager.call("FindDeviceByCapability", cap);
-
-        if (!reply.isValid())
-        {
-            qWarning() << Q_FUNC_INFO << " error: " << reply.error().name() << endl;
-            return QStringList();
-        }
-        if ( cap == QLatin1String( "video4linux" ) )
-        {
-            QStringList foundDevices ( reply );
-            QStringList filtered;
-            foreach ( const QString &udi, foundDevices )
-            {
-                QDBusInterface device( "org.freedesktop.Hal", udi, "org.freedesktop.Hal.Device", QDBusConnection::systemBus() );
-                QDBusReply<QString> reply = device.call( "GetProperty", "video4linux.device" );
-                if (!reply.isValid())
-                {
-                    qWarning() << Q_FUNC_INFO << " error getting video4linux.device: " << reply.error().name() << endl;
-                    continue;
-                }
-                if ( !reply.value().contains( "video" ) )
-                {
-                    continue;
-                }
-                filtered.append( udi );
-            }
-            result += filtered;
-        }
-        else
-        {
-            result << reply;
-        }
-    }
-
-    return result;
-}
-
 void HalManager::slotDeviceAdded(const QString &udi)
 {
     d->devicesCache.append(udi);
diff --git a/solid/solid/backends/hal/halmanager.h b/solid/solid/backends/hal/halmanager.h
index ec42fac..377b15d 100644
--- solid/solid/backends/hal/halmanager.h
+++ solid/solid/backends/hal/halmanager.h
@@ -59,9 +59,6 @@ private Q_SLOTS:
     void slotDeviceRemoved(const QString &udi);
 
 private:
-    QStringList findDeviceStringMatch(const QString &key, const QString &value);
-    QStringList findDeviceByDeviceInterface(Solid::DeviceInterface::Type type);
-
     HalManagerPrivate *d;
 };
 }