blob: a1802ebaf0beb25124e46b33ba98b86bc3b3a071 (
plain)
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
|
This patch is an attempt to make KDE find desktop files
and other stuff when /usr or anything else in the file
path is a symlink.
--- a/kdecore/services/kservicefactory.cpp
+++ b/kdecore/services/kservicefactory.cpp
@@ -124,22 +124,16 @@ KService::Ptr KServiceFactory::findServi
return newService;
}
-KService::Ptr KServiceFactory::findServiceByDesktopPath(const QString &_name)
+KService::Ptr KServiceFactory::serviceFromPath(const QString &_name)
{
- if (!m_relNameDict) return KService::Ptr(); // Error!
-
- // Warning : this assumes we're NOT building a database
- // KBuildServiceFactory reimplements it for the case where we are building one
-
int offset = m_relNameDict->find_string( _name );
if (!offset) {
- //kDebug(servicesDebugArea()) << "findServiceByDesktopPath:" << _name << "not found";
return KService::Ptr(); // Not found
}
KService::Ptr newService(createEntry(offset));
if (!newService) {
- kDebug(servicesDebugArea()) << "findServiceByDesktopPath: createEntry failed!";
+ kDebug(servicesDebugArea()) << "serviceFromPath: createEntry failed!";
}
// Check whether the dictionary was right
// It's ok that it's wrong, for the case where we're looking up an unknown service,
@@ -150,6 +144,27 @@ KService::Ptr KServiceFactory::findServi
}
return newService;
}
+
+KService::Ptr KServiceFactory::findServiceByDesktopPath(const QString &_name)
+{
+ if (!m_relNameDict) return KService::Ptr(); // Error!
+
+ // Warning : this assumes we're NOT building a database
+ // KBuildServiceFactory reimplements it for the case where we are building one
+
+ KService::Ptr newService(serviceFromPath(_name));
+ if (!newService) {
+ // We might have been given a symlink or non-canonical path of some sort.
+ // Therefore try looking up KStandardDirs::realFilePath'ed path too.
+ newService = serviceFromPath(KStandardDirs::realFilePath(_name));
+ }
+
+ if (!newService) {
+ kDebug(servicesDebugArea()) << _name << "not found";
+ return KService::Ptr(); // Not found
+ }
+ return newService;
+}
KService::Ptr KServiceFactory::findServiceByMenuId(const QString &_menuId)
{
--- a/kdecore/services/kservicefactory.h
+++ b/kdecore/services/kservicefactory.h
@@ -121,6 +121,8 @@ protected:
virtual void virtual_hook( int id, void* data );
private:
class KServiceFactoryPrivate* d;
+
+ KService::Ptr serviceFromPath(const QString &_name);
};
#endif
|