29 #include <tqtextstream.h>
33 #include "kconfigbackend.h"
34 #include "kapplication.h"
35 #include "kstandarddirs.h"
36 #include "kmountpoint.h"
37 #include "kcatalogue.h"
40 #include "kdesktopfile.h"
41 #include "kdesktopfile.moc"
45 :
KConfig(TQString::fromLatin1(
""), bReadOnly, false)
64 if (path.endsWith(
".directory"))
67 if (!TQDir::isRelativePath(local))
73 if (TQDir::isRelativePath(local))
82 if (!TQDir::isRelativePath(local))
86 local = path.mid(path.findRev(
'/')+1);
93 if (TQDir::isRelativePath(path))
102 if (!TQDir::isRelativePath(local))
105 local = path.mid(path.findRev(
'/')+1);
115 int len = path.length();
117 if(len > 8 && path.right(8) == TQString::fromLatin1(
".desktop"))
119 else if(len > 7 && path.right(7) == TQString::fromLatin1(
".kdelnk"))
127 if (!kapp || kapp->authorize(
"run_desktop_files"))
133 if (TQDir::isRelativePath(path))
146 kdWarning() <<
"Access to '" << path <<
"' denied because of 'run_desktop_files' restriction." <<
endl;
150 TQString KDesktopFile::translatedEntry(
const char* key)
const
152 if (hasTranslatedKey(key))
158 fName = fName.mid(fName.findRev(
'/')+1);
159 TQString po_lookup_key = TQString::fromLatin1(key) +
"(" + fName +
"): " + value;
162 if (po_value == po_lookup_key)
168 return TQString::null;
183 return translatedEntry(
"Name");
188 return translatedEntry(
"Comment");
193 return translatedEntry(
"GenericName");
212 for(KMountPoint::List::ConstIterator it = mountPoints.begin();
213 it != mountPoints.end(); ++it)
223 return TQString::null;
226 if ( !url.isEmpty() && !TQDir::isRelativePath(url) )
244 setGroup(TQString::fromLatin1(
"Desktop Action ") + group);
249 return hasGroup(TQString::fromLatin1(
"Desktop Action ") + group);
254 return readEntry(
"Type") == TQString::fromLatin1(
"Link");
259 return readEntry(
"Type") == TQString::fromLatin1(
"Application");
264 return readEntry(
"Type") == TQString::fromLatin1(
"MimeType");
269 return readEntry(
"Type") == TQString::fromLatin1(
"FSDev") ||
270 readEntry(
"Type") == TQString::fromLatin1(
"FSDevice");
279 if (!TQDir::isRelativePath(te)) {
280 if (::access(TQFile::encodeName(te), X_OK))
286 TQStringList dirs = TQStringList::split(
':', TQFile::decodeName(::getenv(
"PATH")));
287 TQStringList::Iterator it(dirs.begin());
289 for (; it != dirs.end(); ++it) {
290 TQString fName = *it +
"/" + te;
291 if (::access(TQFile::encodeName(fName), X_OK) == 0)
303 if (kapp && !list.isEmpty())
305 for(TQStringList::ConstIterator it = list.begin();
309 if (!kapp->authorize((*it).stripWhiteSpace()))
318 TQString user =
readEntry(
"X-KDE-Username");
320 user = ::getenv(
"ADMIN_ACCOUNT");
323 if (!kapp->authorize(
"user/"+user))
348 void KDesktopFile::virtual_hook(
int id,
void* data )
349 { KConfig::virtual_hook(
id, data ); }