• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • services
kservice.cpp
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 * Copyright (C) 1999 - 2001 Waldo Bastian <bastian@kde.org>
3 * Copyright (C) 1999 - 2005 David Faure <faure@kde.org>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License version 2 as published by the Free Software Foundation;
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#include "kservice.h"
21#include "kservice_p.h"
22#include "kmimetypefactory.h"
23#include "kmimetyperepository_p.h"
24
25#include <sys/types.h>
26#include <sys/stat.h>
27
28#include <stddef.h>
29#include <unistd.h>
30#include <stdlib.h>
31
32#include <QtCore/QCharRef>
33#include <QtCore/QFile>
34#include <QtCore/QDir>
35#include <QtCore/QMap>
36
37#include <kauthorized.h>
38#include <kdebug.h>
39#include <kdesktopfile.h>
40#include <kglobal.h>
41#include <kconfiggroup.h>
42#include <kstandarddirs.h>
43
44#include "kservicefactory.h"
45#include "kservicetypefactory.h"
46
47int servicesDebugArea() {
48 static int s_area = KDebug::registerArea("kdecore (services)");
49 return s_area;
50}
51
52QDataStream &operator<<(QDataStream &s, const KService::ServiceTypeAndPreference &st)
53{
54 s << st.preference << st.serviceType;
55 return s;
56}
57QDataStream &operator>>(QDataStream &s, KService::ServiceTypeAndPreference &st)
58{
59 s >> st.preference >> st.serviceType;
60 return s;
61}
62
63void KServicePrivate::init( const KDesktopFile *config, KService* q )
64{
65 const QString entryPath = q->entryPath();
66 bool absPath = !QDir::isRelativePath(entryPath);
67
68 // TODO: it makes sense to have a KConstConfigGroup I guess
69 const KConfigGroup desktopGroup = const_cast<KDesktopFile*>(config)->desktopGroup();
70 QMap<QString, QString> entryMap = desktopGroup.entryMap();
71
72 entryMap.remove(QLatin1String("Encoding")); // reserved as part of Desktop Entry Standard
73 entryMap.remove(QLatin1String("Version")); // reserved as part of Desktop Entry Standard
74
75 q->setDeleted( desktopGroup.readEntry("Hidden", false) );
76 entryMap.remove(QLatin1String("Hidden"));
77 if ( q->isDeleted() ) {
78 m_bValid = false;
79 return;
80 }
81
82 m_strName = config->readName();
83 entryMap.remove(QLatin1String("Name"));
84 if ( m_strName.isEmpty() )
85 {
86 // Try to make up a name.
87 m_strName = entryPath;
88 int i = m_strName.lastIndexOf(QLatin1Char('/'));
89 m_strName = m_strName.mid(i+1);
90 i = m_strName.lastIndexOf(QLatin1Char('.'));
91 if (i != -1)
92 m_strName = m_strName.left(i);
93 }
94
95 m_strType = config->readType();
96 entryMap.remove(QLatin1String("Type"));
97 if ( m_strType.isEmpty() )
98 {
99 /*kWarning(servicesDebugArea()) << "The desktop entry file " << entryPath
100 << " has no Type=... entry."
101 << " It should be \"Application\" or \"Service\"" << endl;
102 m_bValid = false;
103 return;*/
104 m_strType = QString::fromLatin1("Application");
105 } else if (m_strType != QLatin1String("Application") && m_strType != QLatin1String("Service")) {
106 kWarning(servicesDebugArea()) << "The desktop entry file " << entryPath
107 << " has Type=" << m_strType
108 << " instead of \"Application\" or \"Service\"" << endl;
109 m_bValid = false;
110 return;
111 }
112
113 // NOT readPathEntry, it is not XDG-compliant. Path entries written by
114 // KDE4 will be still treated as such, though.
115 m_strExec = desktopGroup.readEntry( "Exec", QString() );
116 entryMap.remove(QLatin1String("Exec"));
117
118 if (m_strType == QLatin1String("Application")) {
119 // It's an application? Should have an Exec line then, otherwise we can't run it
120 if (m_strExec.isEmpty()) {
121 kWarning(servicesDebugArea()) << "The desktop entry file " << entryPath
122 << " has Type=" << m_strType
123 << " but no Exec line" << endl;
124 m_bValid = false;
125 return;
126 }
127 }
128
129 // In case Try Exec is set, check if the application is available
130 if (!config->tryExec()) {
131 q->setDeleted( true );
132 m_bValid = false;
133 return;
134 }
135
136 const QByteArray resource = config->resource();
137
138 if ( (m_strType == QLatin1String("Application")) &&
139 (!resource.isEmpty()) &&
140 (resource != "apps") &&
141 !absPath)
142 {
143 kWarning(servicesDebugArea()) << "The desktop entry file " << entryPath
144 << " has Type=" << m_strType << " but is located under \"" << resource
145 << "\" instead of \"apps\"" << endl;
146 m_bValid = false;
147 return;
148 }
149
150 if ( (m_strType == QLatin1String("Service")) &&
151 (!resource.isEmpty()) &&
152 (resource != "services") &&
153 !absPath)
154 {
155 kWarning(servicesDebugArea()) << "The desktop entry file " << entryPath
156 << " has Type=" << m_strType << " but is located under \"" << resource
157 << "\" instead of \"services\"";
158 m_bValid = false;
159 return;
160 }
161
162 QString _name = entryPath;
163 int pos = _name.lastIndexOf(QLatin1Char('/'));
164 if (pos != -1)
165 _name = _name.mid(pos+1);
166 pos = _name.indexOf(QLatin1Char('.'));
167 if (pos != -1)
168 _name = _name.left(pos);
169
170 m_strIcon = config->readIcon();
171 entryMap.remove(QLatin1String("Icon"));
172 m_bTerminal = desktopGroup.readEntry( "Terminal", false); // should be a property IMHO
173 entryMap.remove(QLatin1String("Terminal"));
174 m_strTerminalOptions = desktopGroup.readEntry( "TerminalOptions" ); // should be a property IMHO
175 entryMap.remove(QLatin1String("TerminalOptions"));
176 m_strPath = config->readPath();
177 entryMap.remove(QLatin1String("Path"));
178 m_strComment = config->readComment();
179 entryMap.remove(QLatin1String("Comment"));
180 m_strGenName = config->readGenericName();
181 entryMap.remove(QLatin1String("GenericName"));
182 QString _untranslatedGenericName = desktopGroup.readEntryUntranslated( "GenericName" );
183 if (!_untranslatedGenericName.isEmpty())
184 entryMap.insert(QLatin1String("UntranslatedGenericName"), _untranslatedGenericName);
185
186 m_lstKeywords = desktopGroup.readXdgListEntry("Keywords", QStringList());
187 entryMap.remove(QLatin1String("Keywords"));
188 m_lstKeywords += desktopGroup.readEntry("X-KDE-Keywords", QStringList());
189 entryMap.remove(QLatin1String("X-KDE-Keywords"));
190 categories = desktopGroup.readXdgListEntry("Categories");
191 entryMap.remove(QLatin1String("Categories"));
192 // TODO KDE5: only care for X-KDE-Library in Type=Service desktop files
193 // This will prevent people defining a part and an app in the same desktop file
194 // which makes user-preference handling difficult.
195 m_strLibrary = desktopGroup.readEntry( "X-KDE-Library" );
196 entryMap.remove(QLatin1String("X-KDE-Library"));
197 if (!m_strLibrary.isEmpty() && m_strType == QLatin1String("Application")) {
198 kWarning(servicesDebugArea()) << "The desktop entry file" << entryPath
199 << "has Type=" << m_strType
200 << "but also has a X-KDE-Library key. This works for now,"
201 " but makes user-preference handling difficult, so support for this might"
202 " be removed at some point. Consider splitting it into two desktop files.";
203 }
204
205 QStringList lstServiceTypes = desktopGroup.readEntry( "ServiceTypes", QStringList() );
206 entryMap.remove(QLatin1String("ServiceTypes"));
207 lstServiceTypes += desktopGroup.readEntry( "X-KDE-ServiceTypes", QStringList() );
208 entryMap.remove(QLatin1String("X-KDE-ServiceTypes"));
209 lstServiceTypes += desktopGroup.readXdgListEntry( "MimeType" );
210 entryMap.remove(QLatin1String("MimeType"));
211
212 if ( m_strType == QLatin1String("Application") && !lstServiceTypes.contains(QLatin1String("Application")) )
213 // Applications implement the service type "Application" ;-)
214 lstServiceTypes += QString::fromLatin1("Application");
215
216 m_initialPreference = desktopGroup.readEntry( "InitialPreference", 1 );
217 entryMap.remove(QLatin1String("InitialPreference"));
218
219 // Assign the "initial preference" to each mimetype/servicetype
220 // (and to set such preferences in memory from kbuildsycoca)
221 m_serviceTypes.reserve(lstServiceTypes.size());
222 QListIterator<QString> st_it(lstServiceTypes);
223 while ( st_it.hasNext() ) {
224 const QString st = st_it.next();
225 if (st.isEmpty()) {
226 kWarning(servicesDebugArea()) << "The desktop entry file" << entryPath
227 << "has an empty mimetype!";
228 continue;
229 }
230 int initialPreference = m_initialPreference;
231 if ( st_it.hasNext() ) {
232 // TODO better syntax - separate group with mimetype=number entries?
233 bool isNumber;
234 const int val = st_it.peekNext().toInt(&isNumber);
235 if (isNumber) {
236 initialPreference = val;
237 st_it.next();
238 }
239 }
240 m_serviceTypes.push_back(KService::ServiceTypeAndPreference(initialPreference, st));
241 }
242
243 if (entryMap.contains(QLatin1String("Actions"))) {
244 parseActions(config, q);
245 }
246
247 QString dbusStartupType = desktopGroup.readEntry("X-DBUS-StartupType").toLower();
248 entryMap.remove(QLatin1String("X-DBUS-StartupType"));
249 if (dbusStartupType == QLatin1String("unique"))
250 m_DBUSStartusType = KService::DBusUnique;
251 else if (dbusStartupType == QLatin1String("multi"))
252 m_DBUSStartusType = KService::DBusMulti;
253 else if (dbusStartupType == QLatin1String("wait"))
254 m_DBUSStartusType = KService::DBusWait;
255 else
256 m_DBUSStartusType = KService::DBusNone;
257
258 m_strDesktopEntryName = _name.toLower();
259
260 m_bAllowAsDefault = desktopGroup.readEntry("AllowDefault", true);
261 entryMap.remove(QLatin1String("AllowDefault"));
262
263 // allow plugin users to translate categories without needing a separate key
264 QMap<QString,QString>::Iterator entry = entryMap.find(QString::fromLatin1("X-KDE-PluginInfo-Category"));
265 if (entry != entryMap.end()) {
266 const QString& key = entry.key();
267 m_mapProps.insert(key, QVariant(desktopGroup.readEntryUntranslated(key)));
268 m_mapProps.insert(key + QLatin1String("-Translated"), QVariant(*entry));
269 entryMap.erase(entry);
270 }
271
272 // Store all additional entries in the property map.
273 // A QMap<QString,QString> would be easier for this but we can't
274 // break BC, so we have to store it in m_mapProps.
275// qDebug("Path = %s", entryPath.toLatin1().constData());
276 QMap<QString,QString>::ConstIterator it = entryMap.constBegin();
277 for( ; it != entryMap.constEnd();++it) {
278 const QString key = it.key();
279 // do not store other translations like Name[fr]; kbuildsycoca will rerun if we change languages anyway
280 if (!key.contains(QLatin1Char('['))) {
281 //kDebug(servicesDebugArea()) << " Key =" << key << " Data =" << *it;
282 m_mapProps.insert(key, QVariant(*it));
283 }
284 }
285}
286
287void KServicePrivate::parseActions(const KDesktopFile *config, KService* q)
288{
289 const QStringList keys = config->readActions();
290 if (keys.isEmpty())
291 return;
292
293 QStringList::ConstIterator it = keys.begin();
294 const QStringList::ConstIterator end = keys.end();
295 for ( ; it != end; ++it ) {
296 const QString group = *it;
297 if (group == QLatin1String("_SEPARATOR_")) {
298 m_actions.append(KServiceAction(group, QString(), QString(), QString(), false));
299 continue;
300 }
301
302 if (config->hasActionGroup(group)) {
303 const KConfigGroup cg = config->actionGroup(group);
304 if ( !cg.hasKey( "Name" ) || !cg.hasKey( "Exec" ) ) {
305 kWarning(servicesDebugArea()) << "The action" << group << "in the desktop file" << q->entryPath()
306 << "has no Name or no Exec key";
307 } else {
308 m_actions.append(KServiceAction(group,
309 cg.readEntry("Name"),
310 cg.readEntry("Icon"),
311 cg.readEntry("Exec"),
312 cg.readEntry("NoDisplay", false)));
313 }
314 } else {
315 kWarning(servicesDebugArea()) << "The desktop file" << q->entryPath()
316 << "references the action" << group << "but doesn't define it";
317 }
318 }
319}
320
321void KServicePrivate::load(QDataStream& s)
322{
323 qint8 def, term;
324 qint8 dst, initpref;
325 QStringList dummyList; // KDE4: you can reuse this for another QStringList. KDE5: remove
326
327 // WARNING: THIS NEEDS TO REMAIN COMPATIBLE WITH PREVIOUS KDE 4.x VERSIONS!
328 // !! This data structure should remain binary compatible at all times !!
329 // You may add new fields at the end. Make sure to update the version
330 // number in ksycoca.h
331 s >> m_strType >> m_strName >> m_strExec >> m_strIcon
332 >> term >> m_strTerminalOptions
333 >> m_strPath >> m_strComment >> dummyList >> def >> m_mapProps
334 >> m_strLibrary
335 >> dst
336 >> m_strDesktopEntryName
337 >> initpref
338 >> m_lstKeywords >> m_strGenName
339 >> categories >> menuId >> m_actions >> m_serviceTypes;
340
341 m_bAllowAsDefault = (bool)def;
342 m_bTerminal = (bool)term;
343 m_DBUSStartusType = (KService::DBusStartupType) dst;
344 m_initialPreference = initpref;
345
346 m_bValid = true;
347}
348
349void KServicePrivate::save(QDataStream& s)
350{
351 KSycocaEntryPrivate::save( s );
352 qint8 def = m_bAllowAsDefault, initpref = m_initialPreference;
353 qint8 term = m_bTerminal;
354 qint8 dst = (qint8) m_DBUSStartusType;
355
356 // WARNING: THIS NEEDS TO REMAIN COMPATIBLE WITH PREVIOUS KDE 4.x VERSIONS!
357 // !! This data structure should remain binary compatible at all times !!
358 // You may add new fields at the end. Make sure to update the version
359 // number in ksycoca.h
360 s << m_strType << m_strName << m_strExec << m_strIcon
361 << term << m_strTerminalOptions
362 << m_strPath << m_strComment << QStringList() << def << m_mapProps
363 << m_strLibrary
364 << dst
365 << m_strDesktopEntryName
366 << initpref
367 << m_lstKeywords << m_strGenName
368 << categories << menuId << m_actions << m_serviceTypes;
369}
370
372
373KService::KService( const QString & _name, const QString &_exec, const QString &_icon)
374 : KSycocaEntry(*new KServicePrivate(QString()))
375{
376 Q_D(KService);
377 d->m_strType = QString::fromLatin1("Application");
378 d->m_strName = _name;
379 d->m_strExec = _exec;
380 d->m_strIcon = _icon;
381 d->m_bTerminal = false;
382 d->m_bAllowAsDefault = true;
383 d->m_initialPreference = 10;
384}
385
386
387KService::KService( const QString & _fullpath )
388 : KSycocaEntry(*new KServicePrivate(_fullpath))
389{
390 Q_D(KService);
391
392 KDesktopFile config( _fullpath );
393 d->init(&config, this);
394}
395
396KService::KService( const KDesktopFile *config )
397 : KSycocaEntry(*new KServicePrivate(config->fileName()))
398{
399 Q_D(KService);
400
401 d->init(config, this);
402}
403
404KService::KService( QDataStream& _str, int _offset )
405 : KSycocaEntry(*new KServicePrivate(_str, _offset))
406{
407}
408
409KService::~KService()
410{
411}
412
413bool KService::hasServiceType( const QString& serviceType ) const
414{
415 Q_D(const KService);
416
417 if (!d->m_bValid) return false; // (useless) safety test
418 const KServiceType::Ptr ptr = KServiceType::serviceType( serviceType );
419 if (!ptr)
420 return false;
421 const int serviceOffset = offset();
422 // doesn't seem to work:
423 //if ( serviceOffset == 0 )
424 // serviceOffset = serviceByStorageId( storageId() );
425 if ( serviceOffset )
426 return KServiceFactory::self()->hasOffer( ptr->offset(), ptr->serviceOffersOffset(), serviceOffset );
427
428 // fall-back code for services that are NOT from ksycoca
429 // For each service type we are associated with, if it doesn't
430 // match then we try its parent service types.
431 QVector<ServiceTypeAndPreference>::ConstIterator it = d->m_serviceTypes.begin();
432 for( ; it != d->m_serviceTypes.end(); ++it ) {
433 const QString& st = (*it).serviceType;
434 //kDebug(servicesDebugArea()) << " has " << (*it);
435 if ( st == ptr->name() )
436 return true;
437 // also the case of parent servicetypes
438 KServiceType::Ptr p = KServiceType::serviceType( st );
439 if ( p && p->inherits( ptr->name() ) )
440 return true;
441 }
442 return false;
443}
444
445#ifndef KDE_NO_DEPRECATED
446bool KService::hasMimeType( const KServiceType* ptr ) const
447{
448 if (!ptr) return false;
449
450 return hasMimeType(ptr->name());
451}
452#endif
453
454bool KService::hasMimeType(const QString& mimeType) const
455{
456 Q_D(const KService);
457 const QString mime = KMimeTypeRepository::self()->canonicalName(mimeType);
458 int serviceOffset = offset();
459 if ( serviceOffset ) {
460 KMimeTypeFactory *factory = KMimeTypeFactory::self();
461 const int mimeOffset = factory->entryOffset(mime);
462 const int serviceOffersOffset = factory->serviceOffersOffset(mime);
463 if (serviceOffersOffset == -1)
464 return false;
465 return KServiceFactory::self()->hasOffer(mimeOffset, serviceOffersOffset, serviceOffset);
466 }
467
468 // fall-back code for services that are NOT from ksycoca
469 QVector<ServiceTypeAndPreference>::ConstIterator it = d->m_serviceTypes.begin();
470 for( ; it != d->m_serviceTypes.end(); ++it ) {
471 const QString& st = (*it).serviceType;
472 //kDebug(servicesDebugArea()) << " has " << (*it);
473 if ( st == mime )
474 return true;
475 // TODO: should we handle inherited mimetypes here?
476 // KMimeType was in kio when this code was written, this is the only reason it's not done.
477 // But this should matter only in a very rare case, since most code gets KServices from ksycoca.
478 // Warning, change hasServiceType if you implement this here (and check kbuildservicefactory).
479 }
480 return false;
481}
482
483QVariant KServicePrivate::property( const QString& _name) const
484{
485 return property( _name, QVariant::Invalid);
486}
487
488// Return a string QVariant if string isn't null, and invalid variant otherwise
489// (the variant must be invalid if the field isn't in the .desktop file)
490// This allows trader queries like "exist Library" to work.
491static QVariant makeStringVariant( const QString& string )
492{
493 // Using isEmpty here would be wrong.
494 // Empty is "specified but empty", null is "not specified" (in the .desktop file)
495 return string.isNull() ? QVariant() : QVariant( string );
496}
497
498QVariant KService::property( const QString& _name, QVariant::Type t ) const
499{
500 Q_D(const KService);
501 return d->property(_name, t);
502}
503
504QVariant KServicePrivate::property( const QString& _name, QVariant::Type t ) const
505{
506 if ( _name == QLatin1String("Type") )
507 return QVariant( m_strType ); // can't be null
508 else if ( _name == QLatin1String("Name") )
509 return QVariant( m_strName ); // can't be null
510 else if ( _name == QLatin1String("Exec") )
511 return makeStringVariant( m_strExec );
512 else if ( _name == QLatin1String("Icon") )
513 return makeStringVariant( m_strIcon );
514 else if ( _name == QLatin1String("Terminal") )
515 return QVariant( m_bTerminal );
516 else if ( _name == QLatin1String("TerminalOptions") )
517 return makeStringVariant( m_strTerminalOptions );
518 else if ( _name == QLatin1String("Path") )
519 return makeStringVariant( m_strPath );
520 else if ( _name == QLatin1String("Comment") )
521 return makeStringVariant( m_strComment );
522 else if ( _name == QLatin1String("GenericName") )
523 return makeStringVariant( m_strGenName );
524 else if ( _name == QLatin1String("ServiceTypes") )
525 return QVariant( serviceTypes() );
526 else if ( _name == QLatin1String("AllowAsDefault") )
527 return QVariant( m_bAllowAsDefault );
528 else if ( _name == QLatin1String("InitialPreference") )
529 return QVariant( m_initialPreference );
530 else if ( _name == QLatin1String("Library") )
531 return makeStringVariant( m_strLibrary );
532 else if ( _name == QLatin1String("DesktopEntryPath") ) // can't be null
533 return QVariant( path );
534 else if ( _name == QLatin1String("DesktopEntryName"))
535 return QVariant( m_strDesktopEntryName ); // can't be null
536 else if ( _name == QLatin1String("Categories"))
537 return QVariant( categories );
538 else if ( _name == QLatin1String("Keywords"))
539 return QVariant( m_lstKeywords );
540
541 // Ok we need to convert the property from a QString to its real type.
542 // Maybe the caller helped us.
543 if (t == QVariant::Invalid)
544 {
545 // No luck, let's ask KServiceTypeFactory what the type of this property
546 // is supposed to be.
547 t = KServiceTypeFactory::self()->findPropertyTypeByName(_name);
548 if (t == QVariant::Invalid)
549 {
550 kDebug(servicesDebugArea()) << "Request for unknown property '" << _name << "'\n";
551 return QVariant(); // Unknown property: Invalid variant.
552 }
553 }
554
555 QMap<QString,QVariant>::ConstIterator it = m_mapProps.find( _name );
556 if ( (it == m_mapProps.end()) || (!it->isValid()))
557 {
558 //kDebug(servicesDebugArea()) << "Property not found " << _name;
559 return QVariant(); // No property set.
560 }
561
562 switch(t)
563 {
564 case QVariant::String:
565 return *it; // no conversion necessary
566 default:
567 // All others
568 // For instance properties defined as StringList, like MimeTypes.
569 // XXX This API is accessible only through a friend declaration.
570 return KConfigGroup::convertToQVariant(_name.toUtf8().constData(), it->toString().toUtf8(), t);
571 }
572}
573
574QStringList KServicePrivate::propertyNames() const
575{
576 QStringList res;
577
578 QMap<QString,QVariant>::ConstIterator it = m_mapProps.begin();
579 for( ; it != m_mapProps.end(); ++it )
580 res.append( it.key() );
581
582 res.append( QString::fromLatin1("Type") );
583 res.append( QString::fromLatin1("Name") );
584 res.append( QString::fromLatin1("Comment") );
585 res.append( QString::fromLatin1("GenericName") );
586 res.append( QString::fromLatin1("Icon") );
587 res.append( QString::fromLatin1("Exec") );
588 res.append( QString::fromLatin1("Terminal") );
589 res.append( QString::fromLatin1("TerminalOptions") );
590 res.append( QString::fromLatin1("Path") );
591 res.append( QString::fromLatin1("ServiceTypes") );
592 res.append( QString::fromLatin1("AllowAsDefault") );
593 res.append( QString::fromLatin1("InitialPreference") );
594 res.append( QString::fromLatin1("Library") );
595 res.append( QString::fromLatin1("DesktopEntryPath") );
596 res.append( QString::fromLatin1("DesktopEntryName") );
597 res.append( QString::fromLatin1("Keywords") );
598 res.append( QString::fromLatin1("Categories") );
599
600 return res;
601}
602
603KService::List KService::allServices()
604{
605 return KServiceFactory::self()->allServices();
606}
607
608#ifndef KDE_NO_DEPRECATED
609KService::Ptr KService::serviceByName( const QString& _name )
610{
611 return KServiceFactory::self()->findServiceByName( _name );
612}
613#endif
614
615KService::Ptr KService::serviceByDesktopPath( const QString& _name )
616{
617 return KServiceFactory::self()->findServiceByDesktopPath( _name );
618}
619
620KService::Ptr KService::serviceByDesktopName( const QString& _name )
621{
622 // Prefer kde4-konsole over kde-konsole, if both are available
623 QString name = _name.toLower();
624 KService::Ptr s;
625 if (!_name.startsWith(QLatin1String("kde4-")))
626 s = KServiceFactory::self()->findServiceByDesktopName(QString::fromLatin1("kde4-") + name);
627 if (!s)
628 s = KServiceFactory::self()->findServiceByDesktopName( name );
629
630 return s;
631}
632
633KService::Ptr KService::serviceByMenuId( const QString& _name )
634{
635 return KServiceFactory::self()->findServiceByMenuId( _name );
636}
637
638KService::Ptr KService::serviceByStorageId( const QString& _storageId )
639{
640 KService::Ptr service = KService::serviceByMenuId( _storageId );
641 if (service)
642 return service;
643
644 service = KService::serviceByDesktopPath(_storageId);
645 if (service)
646 return service;
647
648 if (!QDir::isRelativePath(_storageId) && QFile::exists(_storageId))
649 return KService::Ptr(new KService(_storageId));
650
651 QString tmp = _storageId;
652 tmp = tmp.mid(tmp.lastIndexOf(QLatin1Char('/'))+1); // Strip dir
653
654 if (tmp.endsWith(QLatin1String(".desktop")))
655 tmp.truncate(tmp.length()-8);
656
657 if (tmp.endsWith(QLatin1String(".kdelnk")))
658 tmp.truncate(tmp.length()-7);
659
660 service = KService::serviceByDesktopName(tmp);
661
662 return service;
663}
664
665bool KService::substituteUid() const {
666 QVariant v = property(QLatin1String("X-KDE-SubstituteUID"), QVariant::Bool);
667 return v.isValid() && v.toBool();
668}
669
670QString KService::username() const {
671 // See also KDesktopFile::tryExec()
672 QString user;
673 QVariant v = property(QLatin1String("X-KDE-Username"), QVariant::String);
674 user = v.isValid() ? v.toString() : QString();
675 if (user.isEmpty())
676 user = QString::fromLocal8Bit(qgetenv("ADMIN_ACCOUNT"));
677 if (user.isEmpty())
678 user = QString::fromLatin1("root");
679 return user;
680}
681
682bool KService::showInKDE() const
683{
684 Q_D(const KService);
685
686 QMap<QString,QVariant>::ConstIterator it = d->m_mapProps.find( QString::fromLatin1("OnlyShowIn") );
687 if ( (it != d->m_mapProps.end()) && (it->isValid()))
688 {
689 const QStringList aList = it->toString().split(QLatin1Char(';'));
690 if (!aList.contains(QString::fromLatin1("KDE")))
691 return false;
692 }
693
694 it = d->m_mapProps.find( QString::fromLatin1("NotShowIn") );
695 if ( (it != d->m_mapProps.end()) && (it->isValid()))
696 {
697 const QStringList aList = it->toString().split(QLatin1Char(';'));
698 if (aList.contains(QString::fromLatin1("KDE")))
699 return false;
700 }
701 return true;
702}
703
704bool KService::noDisplay() const {
705 if ( qvariant_cast<bool>(property(QString::fromLatin1("NoDisplay"), QVariant::Bool)) )
706 return true;
707
708 if (!showInKDE())
709 return true;
710
711 if (!KAuthorized::authorizeControlModule( storageId() ) )
712 return true;
713
714 return false;
715}
716
717QString KService::untranslatedGenericName() const {
718 QVariant v = property(QString::fromLatin1("UntranslatedGenericName"), QVariant::String);
719 return v.isValid() ? v.toString() : QString();
720}
721
722QString KService::parentApp() const {
723 Q_D(const KService);
724 QMap<QString,QVariant>::ConstIterator it = d->m_mapProps.find(QLatin1String("X-KDE-ParentApp"));
725 if ( (it == d->m_mapProps.end()) || (!it->isValid()))
726 {
727 return QString();
728 }
729
730 return it->toString();
731}
732
733QString KService::pluginKeyword() const
734{
735 Q_D(const KService);
736 QMap<QString,QVariant>::ConstIterator it = d->m_mapProps.find(QString::fromLatin1("X-KDE-PluginKeyword"));
737 if ((it == d->m_mapProps.end()) || (!it->isValid())) {
738 return QString();
739 }
740
741 return it->toString();
742}
743
744QString KService::docPath() const
745{
746 Q_D(const KService);
747 QMap<QString,QVariant>::ConstIterator it = d->m_mapProps.find(QLatin1String("X-DocPath"));
748 if ((it == d->m_mapProps.end()) || (!it->isValid())) {
749 it = d->m_mapProps.find(QString::fromLatin1("DocPath"));
750 if ((it == d->m_mapProps.end()) || (!it->isValid())) {
751 return QString();
752 }
753 }
754
755 return it->toString();
756}
757
758bool KService::allowMultipleFiles() const {
759 Q_D(const KService);
760 // Can we pass multiple files on the command line or do we have to start the application for every single file ?
761 return (d->m_strExec.contains( QLatin1String("%F") ) || d->m_strExec.contains( QLatin1String("%U") ) ||
762 d->m_strExec.contains( QLatin1String("%N") ) || d->m_strExec.contains( QLatin1String("%D") ));
763}
764
765QStringList KService::categories() const
766{
767 Q_D(const KService);
768 return d->categories;
769}
770
771QString KService::menuId() const
772{
773 Q_D(const KService);
774 return d->menuId;
775}
776
777void KService::setMenuId(const QString &_menuId)
778{
779 Q_D(KService);
780 d->menuId = _menuId;
781}
782
783QString KService::storageId() const
784{
785 Q_D(const KService);
786 return d->storageId();
787}
788
789QString KService::locateLocal() const
790{
791 Q_D(const KService);
792 if (d->menuId.isEmpty() || entryPath().startsWith(QLatin1String(".hidden")) ||
793 (QDir::isRelativePath(entryPath()) && d->categories.isEmpty()))
794 return KDesktopFile::locateLocal(entryPath());
795
796 return KStandardDirs::locateLocal("xdgdata-apps", d->menuId);
797}
798
799QString KService::newServicePath(bool showInMenu, const QString &suggestedName,
800 QString *menuId, const QStringList *reservedMenuIds)
801{
802 Q_UNUSED(showInMenu); // TODO KDE5: remove argument
803
804 QString base = suggestedName;
805 QString result;
806 for(int i = 1; true; i++)
807 {
808 if (i == 1)
809 result = base + QString::fromLatin1(".desktop");
810 else
811 result = base + QString::fromLatin1("-%1.desktop").arg(i);
812
813 if (reservedMenuIds && reservedMenuIds->contains(result))
814 continue;
815
816 // Lookup service by menu-id
817 KService::Ptr s = serviceByMenuId(result);
818 if (s)
819 continue;
820
821 if (!KStandardDirs::locate("xdgdata-apps", result).isEmpty())
822 continue;
823
824 break;
825 }
826 if (menuId)
827 *menuId = result;
828
829 return KStandardDirs::locateLocal("xdgdata-apps", result);
830}
831
832bool KService::isApplication() const
833{
834 Q_D(const KService);
835 return d->m_strType == QLatin1String("Application");
836}
837
838#ifndef KDE_NO_DEPRECATED
839QString KService::type() const
840{
841 Q_D(const KService);
842 return d->m_strType;
843}
844#endif
845
846QString KService::exec() const
847{
848 Q_D(const KService);
849 if (d->m_strType == QLatin1String("Application") && d->m_strExec.isEmpty())
850 {
851 kWarning(servicesDebugArea()) << "The desktop entry file " << entryPath()
852 << " has Type=" << d->m_strType << " but has no Exec field." << endl;
853 }
854 return d->m_strExec;
855}
856
857QString KService::library() const
858{
859 Q_D(const KService);
860 return d->m_strLibrary;
861}
862
863QString KService::icon() const
864{
865 Q_D(const KService);
866 return d->m_strIcon;
867}
868
869QString KService::terminalOptions() const
870{
871 Q_D(const KService);
872 return d->m_strTerminalOptions;
873}
874
875bool KService::terminal() const
876{
877 Q_D(const KService);
878 return d->m_bTerminal;
879}
880
881// KDE5: remove and port code to entryPath?
882#ifndef KDE_NO_DEPRECATED
883QString KService::desktopEntryPath() const
884{
885 return entryPath();
886}
887#endif
888
889QString KService::desktopEntryName() const
890{
891 Q_D(const KService);
892 return d->m_strDesktopEntryName;
893}
894
895KService::DBusStartupType KService::dbusStartupType() const
896{
897 Q_D(const KService);
898 return d->m_DBUSStartusType;
899}
900
901QString KService::path() const
902{
903 Q_D(const KService);
904 return d->m_strPath;
905}
906
907QString KService::comment() const
908{
909 Q_D(const KService);
910 return d->m_strComment;
911}
912
913QString KService::genericName() const
914{
915 Q_D(const KService);
916 return d->m_strGenName;
917}
918
919QStringList KService::keywords() const
920{
921 Q_D(const KService);
922 return d->m_lstKeywords;
923}
924
925QStringList KServicePrivate::serviceTypes() const
926{
927 QStringList ret;
928 QVector<KService::ServiceTypeAndPreference>::const_iterator it = m_serviceTypes.begin();
929 for ( ; it < m_serviceTypes.end(); ++it ) {
930 Q_ASSERT(!(*it).serviceType.isEmpty());
931 ret.append((*it).serviceType);
932 }
933 return ret;
934}
935
936QStringList KService::serviceTypes() const
937{
938 Q_D(const KService);
939 return d->serviceTypes();
940}
941
942QStringList KService::mimeTypes() const
943{
944 Q_D(const KService);
945 QStringList ret;
946 QVector<KService::ServiceTypeAndPreference>::const_iterator it = d->m_serviceTypes.begin();
947 for ( ; it < d->m_serviceTypes.end(); ++it ) {
948 const QString sv = (*it).serviceType;
949 if (KMimeType::mimeType(sv)) // keep only mimetypes, filter out servicetypes
950 ret.append(sv);
951 }
952 return ret;
953}
954
955bool KService::allowAsDefault() const
956{
957 Q_D(const KService);
958 return d->m_bAllowAsDefault;
959}
960
961int KService::initialPreference() const
962{
963 Q_D(const KService);
964 return d->m_initialPreference;
965}
966
967void KService::setTerminal(bool b)
968{
969 Q_D(KService);
970 d->m_bTerminal = b;
971}
972
973void KService::setTerminalOptions(const QString &options)
974{
975 Q_D(KService);
976 d->m_strTerminalOptions = options;
977}
978
979void KService::setExec(const QString& exec)
980{
981 Q_D(KService);
982
983 if (!exec.isEmpty()) {
984 d->m_strExec = exec;
985 d->path.clear();
986 }
987}
988
989QVector<KService::ServiceTypeAndPreference> & KService::_k_accessServiceTypes()
990{
991 Q_D(KService);
992 return d->m_serviceTypes;
993}
994
995QList<KServiceAction> KService::actions() const
996{
997 Q_D(const KService);
998 return d->m_actions;
999}
KConfigGroup
A class for one specific group in a KConfig object.
Definition: kconfiggroup.h:54
KConfigGroup::readEntry
T readEntry(const QString &key, const T &aDefault) const
Reads the value of an entry specified by pKey in the current group.
Definition: kconfiggroup.h:248
KConfigGroup::hasKey
bool hasKey(const QString &key) const
Checks whether the key has an entry in this group.
Definition: kconfiggroup.cpp:1155
KConfigGroup::entryMap
QMap< QString, QString > entryMap() const
Returns a map (tree) of entries for all entries in this group.
Definition: kconfiggroup.cpp:603
KConfigGroup::readXdgListEntry
QStringList readXdgListEntry(const QString &pKey, const QStringList &aDefault=QStringList()) const
Reads a list of strings from the config object, following XDG desktop entry spec separator semantics.
Definition: kconfiggroup.cpp:741
KConfigGroup::readEntryUntranslated
QString readEntryUntranslated(const QString &pKey, const QString &aDefault=QString()) const
Reads an untranslated string entry.
Definition: kconfiggroup.cpp:637
KDebug::registerArea
static int registerArea(const QByteArray &areaName, bool enabled=true)
Definition: kdebug.cpp:856
KDesktopFile
KDE Desktop File Management.
Definition: kdesktopfile.h:39
KDesktopFile::locateLocal
static QString locateLocal(const QString &path)
Returns the location where changes for the .desktop file path should be written to.
Definition: kdesktopfile.cpp:79
KMimeTypeFactory
Definition: kmimetypefactory.h:40
KMimeTypeFactory::entryOffset
int entryOffset(const QString &mimeTypeName)
Returns the possible offset for a given mimetype entry.
Definition: kmimetypefactory.cpp:46
KMimeTypeFactory::self
static KMimeTypeFactory * self()
Definition: kmimetypefactory.cpp:41
KMimeTypeFactory::serviceOffersOffset
int serviceOffersOffset(const QString &mimeTypeName)
Returns the offset into the service offers for a given mimetype.
Definition: kmimetypefactory.cpp:55
KMimeTypeRepository::canonicalName
QString canonicalName(const QString &mime)
Resolve mime if it's an alias, and return it otherwise.
Definition: kmimetyperepository.cpp:90
KMimeTypeRepository::self
static KMimeTypeRepository * self()
Definition: kmimetyperepository.cpp:35
KMimeType::mimeType
static Ptr mimeType(const QString &name, FindByNameOption options=ResolveAliases)
Retrieve a pointer to the mime type name.
Definition: kmimetype.cpp:58
KServiceAction
Represents an action in a .desktop file Actions are defined with the config key Actions in the [Deskt...
Definition: kserviceaction.h:35
KServiceFactory::hasOffer
bool hasOffer(int serviceTypeOffset, int serviceOffersOffset, int testedServiceOffset)
Test if a specific service is associated with a specific servicetype.
Definition: kservicefactory.cpp:280
KServiceFactory::findServiceByDesktopPath
virtual KService::Ptr findServiceByDesktopPath(const QString &_name)
Find a service ( by desktop path, e.g.
Definition: kservicefactory.cpp:127
KServiceFactory::allServices
KService::List allServices()
Definition: kservicefactory.cpp:195
KServiceFactory::self
static KServiceFactory * self()
Definition: kservicefactory.cpp:81
KServiceFactory::findServiceByMenuId
virtual KService::Ptr findServiceByMenuId(const QString &_menuId)
Find a service ( by menu id, e.g.
Definition: kservicefactory.cpp:154
KServiceFactory::findServiceByDesktopName
virtual KService::Ptr findServiceByDesktopName(const QString &_name)
Find a service (by desktop file name, e.g.
Definition: kservicefactory.cpp:107
KServiceFactory::findServiceByName
KService::Ptr findServiceByName(const QString &_name)
Find a service (by translated name, e.g.
Definition: kservicefactory.cpp:86
KServicePrivate
Definition: kservice_p.h:30
KServicePrivate::serviceTypes
QStringList serviceTypes() const
Definition: kservice.cpp:925
KServicePrivate::m_bAllowAsDefault
bool m_bAllowAsDefault
Definition: kservice_p.h:95
KServicePrivate::init
void init(const KDesktopFile *config, KService *q)
Definition: kservice.cpp:63
KServicePrivate::m_DBUSStartusType
KService::DBusStartupType m_DBUSStartusType
Definition: kservice_p.h:90
KServicePrivate::m_strPath
QString m_strPath
Definition: kservice_p.h:81
KServicePrivate::m_strDesktopEntryName
QString m_strDesktopEntryName
Definition: kservice_p.h:89
KServicePrivate::parseActions
void parseActions(const KDesktopFile *config, KService *q)
Definition: kservice.cpp:287
KServicePrivate::menuId
QString menuId
Definition: kservice_p.h:75
KServicePrivate::m_strLibrary
QString m_strLibrary
Definition: kservice_p.h:83
KServicePrivate::save
virtual void save(QDataStream &)
Definition: kservice.cpp:349
KServicePrivate::m_lstKeywords
QStringList m_lstKeywords
Definition: kservice_p.h:92
KServicePrivate::load
void load(QDataStream &)
Definition: kservice.cpp:321
KServicePrivate::m_strType
QString m_strType
Definition: kservice_p.h:76
KServicePrivate::m_strGenName
QString m_strGenName
Definition: kservice_p.h:93
KServicePrivate::m_strTerminalOptions
QString m_strTerminalOptions
Definition: kservice_p.h:80
KServicePrivate::m_strExec
QString m_strExec
Definition: kservice_p.h:78
KServicePrivate::m_strComment
QString m_strComment
Definition: kservice_p.h:82
KServicePrivate::m_bTerminal
bool m_bTerminal
Definition: kservice_p.h:96
KServicePrivate::m_strIcon
QString m_strIcon
Definition: kservice_p.h:79
KServicePrivate::categories
QStringList categories
Definition: kservice_p.h:74
KServicePrivate::m_initialPreference
int m_initialPreference
Definition: kservice_p.h:85
KServicePrivate::m_serviceTypes
QVector< KService::ServiceTypeAndPreference > m_serviceTypes
Definition: kservice_p.h:87
KServicePrivate::m_actions
QList< KServiceAction > m_actions
Definition: kservice_p.h:94
KServicePrivate::m_mapProps
QMap< QString, QVariant > m_mapProps
Definition: kservice_p.h:91
KServicePrivate::propertyNames
virtual QStringList propertyNames() const
Definition: kservice.cpp:574
KServicePrivate::m_bValid
bool m_bValid
Definition: kservice_p.h:97
KServicePrivate::m_strName
QString m_strName
Definition: kservice_p.h:77
KServicePrivate::property
virtual QVariant property(const QString &name) const
Definition: kservice.cpp:483
KServiceTypeFactory::findPropertyTypeByName
QVariant::Type findPropertyTypeByName(const QString &_name)
Find a the property type of a named property.
Definition: kservicetypefactory.cpp:85
KServiceTypeFactory::self
static KServiceTypeFactory * self()
Definition: kservicetypefactory.cpp:63
KServiceType
A service type is, well, a type of service, where a service is an application or plugin.
Definition: kservicetype.h:44
KServiceType::inherits
bool inherits(const QString &servTypeName) const
Checks whether this service type is or inherits from servTypeName.
Definition: kservicetype.cpp:137
KServiceType::serviceOffersOffset
int serviceOffersOffset() const
Definition: kservicetype.cpp:226
KServiceType::serviceType
static Ptr serviceType(const QString &_name)
Returns a pointer to the servicetype '_name' or 0L if the service type is unknown.
Definition: kservicetype.cpp:191
KService
Represent a service, like an application or plugin bound to one or several mimetypes (or servicetypes...
Definition: kservice.h:59
KService::categories
QStringList categories() const
Returns a list of VFolder categories.
Definition: kservice.cpp:765
KService::parentApp
QString parentApp() const
Name of the application this service belongs to.
Definition: kservice.cpp:722
KService::mimeTypes
QStringList mimeTypes() const
Returns the list of mime types that this service supports.
Definition: kservice.cpp:942
KService::serviceByStorageId
static Ptr serviceByStorageId(const QString &_storageId)
Find a service by its storage-id or desktop-file path.
Definition: kservice.cpp:638
KService::setExec
void setExec(const QString &exec)
Overrides the "Exec=" line of the service.
Definition: kservice.cpp:979
KService::Ptr
KSharedPtr< KService > Ptr
Definition: kservice.h:61
KService::storageId
QString storageId() const
Returns a normalized ID suitable for storing in configuration files.
Definition: kservice.cpp:783
KService::desktopEntryName
QString desktopEntryName() const
Returns the filename of the service desktop entry without any extension.
Definition: kservice.cpp:889
KService::keywords
QStringList keywords() const
Returns a list of descriptive keywords the service, if there are any.
Definition: kservice.cpp:919
KService::setTerminalOptions
void setTerminalOptions(const QString &options)
Definition: kservice.cpp:973
KService::actions
QList< KServiceAction > actions() const
Returns the actions defined in this desktop file.
Definition: kservice.cpp:995
KService::serviceByName
static Ptr serviceByName(const QString &_name)
Find a service by name, i.e.
Definition: kservice.cpp:609
KService::allowMultipleFiles
bool allowMultipleFiles() const
Checks whether this service can handle several files as startup arguments.
Definition: kservice.cpp:758
KService::genericName
QString genericName() const
Returns the generic name for the service, if there is one (e.g.
Definition: kservice.cpp:913
KService::substituteUid
bool substituteUid() const
Checks whether the service runs with a different user id.
Definition: kservice.cpp:665
KService::dbusStartupType
DBusStartupType dbusStartupType() const
Returns the DBUSStartupType supported by this service.
Definition: kservice.cpp:895
KService::desktopEntryPath
QString desktopEntryPath() const
Returns the path to the location where the service desktop entry is stored.
Definition: kservice.cpp:883
KService::terminal
bool terminal() const
Checks whethe the service should be run in a terminal.
Definition: kservice.cpp:875
KService::terminalOptions
QString terminalOptions() const
Returns any options associated with the terminal the service runs in, if it requires a terminal.
Definition: kservice.cpp:869
KService::hasServiceType
bool hasServiceType(const QString &serviceTypePtr) const
Checks whether the service supports this service type.
Definition: kservice.cpp:413
KService::serviceTypes
QStringList serviceTypes() const
Returns the service types that this service supports.
Definition: kservice.cpp:936
KService::showInKDE
bool showInKDE() const
Whether the service should be shown in KDE at all (including in context menus).
Definition: kservice.cpp:682
KService::allServices
static List allServices()
Returns the whole list of services.
Definition: kservice.cpp:603
KService::KService
KService(const QString &name, const QString &exec, const QString &icon)
Construct a temporary service with a given name, exec-line and icon.
Definition: kservice.cpp:373
KService::noDisplay
bool noDisplay() const
Whether the entry should be suppressed in the K menu.
Definition: kservice.cpp:704
KService::username
QString username() const
Returns the user name, if the service runs with a different user id.
Definition: kservice.cpp:670
KService::locateLocal
QString locateLocal() const
Returns a path that can be used for saving changes to this service.
Definition: kservice.cpp:789
KService::serviceByDesktopName
static Ptr serviceByDesktopName(const QString &_name)
Find a service by the name of its desktop file, not depending on its actual location (as long as it's...
Definition: kservice.cpp:620
KService::DBusStartupType
DBusStartupType
Describes the DBUS Startup type of the service.
Definition: kservice.h:212
KService::DBusNone
@ DBusNone
Definition: kservice.h:212
KService::DBusUnique
@ DBusUnique
Definition: kservice.h:212
KService::DBusMulti
@ DBusMulti
Definition: kservice.h:212
KService::DBusWait
@ DBusWait
Definition: kservice.h:212
KService::menuId
QString menuId() const
Returns the menu ID of the service desktop entry.
Definition: kservice.cpp:771
KService::type
QString type() const
Returns the type of the service.
Definition: kservice.cpp:839
KService::property
QVariant property(const QString &_name, QVariant::Type t) const
Returns the requested property.
Definition: kservice.cpp:498
KService::exec
QString exec() const
Returns the executable.
Definition: kservice.cpp:846
KService::setTerminal
void setTerminal(bool b)
Definition: kservice.cpp:967
KService::comment
QString comment() const
Returns the descriptive comment for the service, if there is one.
Definition: kservice.cpp:907
KService::untranslatedGenericName
QString untranslatedGenericName() const
Returns the untranslated (US English) generic name for the service, if there is one (e....
Definition: kservice.cpp:717
KService::initialPreference
int initialPreference() const
What preference to associate with this service initially (before the user has had any chance to defin...
Definition: kservice.cpp:961
KService::icon
QString icon() const
Returns the name of the icon.
Definition: kservice.cpp:863
KService::_k_accessServiceTypes
QVector< ServiceTypeAndPreference > & _k_accessServiceTypes()
Definition: kservice.cpp:989
KService::library
QString library() const
Returns the name of the service's library.
Definition: kservice.cpp:857
KService::pluginKeyword
QString pluginKeyword() const
The keyword to be used when constructing the plugin using KPluginFactory.
Definition: kservice.cpp:733
KService::setMenuId
void setMenuId(const QString &menuId)
Definition: kservice.cpp:777
KService::docPath
QString docPath() const
The path to the documentation for this service.
Definition: kservice.cpp:744
KService::~KService
virtual ~KService()
Definition: kservice.cpp:409
KService::serviceByMenuId
static Ptr serviceByMenuId(const QString &_menuId)
Find a service by its menu-id.
Definition: kservice.cpp:633
KService::allowAsDefault
bool allowAsDefault() const
Set to true if it is allowed to use this service as the default (main) action for the files it suppor...
Definition: kservice.cpp:955
KService::newServicePath
static QString newServicePath(bool showInMenu, const QString &suggestedName, QString *menuId=0, const QStringList *reservedMenuIds=0)
Returns a path that can be used to create a new KService based on suggestedName.
Definition: kservice.cpp:799
KService::hasMimeType
bool hasMimeType(const KServiceType *mimeTypePtr) const
Checks whether the service supports this mime type.
Definition: kservice.cpp:446
KService::path
QString path() const
Returns the working directory to run the program in.
Definition: kservice.cpp:901
KService::isApplication
bool isApplication() const
Services are either applications (executables) or dlopened libraries (plugins).
Definition: kservice.cpp:832
KService::serviceByDesktopPath
static Ptr serviceByDesktopPath(const QString &_path)
Find a service based on its path as returned by entryPath().
Definition: kservice.cpp:615
KSharedPtr< KServiceType >
KStandardDirs::locateLocal
static QString locateLocal(const char *type, const QString &filename, const KComponentData &cData=KGlobal::mainComponent())
This function is much like locate.
Definition: kstandarddirs.cpp:2097
KStandardDirs::locate
static QString locate(const char *type, const QString &filename, const KComponentData &cData=KGlobal::mainComponent())
This function is just for convenience.
Definition: kstandarddirs.cpp:2091
KSycocaEntryPrivate::path
QString path
Definition: ksycocaentry_p.h:77
KSycocaEntryPrivate::save
virtual void save(QDataStream &s)
Definition: ksycocaentry.cpp:139
KSycocaEntry
Base class for all Sycoca entries.
Definition: ksycocaentry.h:42
KSycocaEntry::offset
int offset() const
Definition: ksycocaentry.cpp:133
KSycocaEntry::name
QString name() const
Definition: ksycocaentry.cpp:157
KSycocaEntry::isDeleted
bool isDeleted() const
Definition: ksycocaentry.cpp:116
KSycocaEntry::entryPath
QString entryPath() const
Definition: ksycocaentry.cpp:104
KSycocaEntry::setDeleted
void setDeleted(bool deleted)
Sets whether or not this service is deleted.
Definition: ksycocaentry.cpp:122
QList< Ptr >
QMap
QStringList
QString
QVariant
bool
kDebug
#define kDebug
Definition: kdebug.h:316
kWarning
#define kWarning
Definition: kdebug.h:322
kauthorized.h
kconfiggroup.h
kdebug.h
kdesktopfile.h
kglobal.h
servicesDebugArea
int servicesDebugArea()
Definition: kservice.cpp:47
kmimetypefactory.h
kmimetyperepository_p.h
makeStringVariant
static QVariant makeStringVariant(const QString &string)
Definition: kservice.cpp:491
operator<<
QDataStream & operator<<(QDataStream &s, const KService::ServiceTypeAndPreference &st)
Definition: kservice.cpp:52
operator>>
QDataStream & operator>>(QDataStream &s, KService::ServiceTypeAndPreference &st)
Definition: kservice.cpp:57
servicesDebugArea
int servicesDebugArea()
Definition: kservice.cpp:47
kservice.h
kservice_p.h
kservicefactory.h
kservicetypefactory.h
kstandarddirs.h
KAuthorized::authorizeControlModule
bool authorizeControlModule(const QString &menuId)
Returns whether access to a certain control module is authorized.
Definition: kauthorized.cpp:237
KService::ServiceTypeAndPreference
Definition: kservice.h:686
KService::ServiceTypeAndPreference::serviceType
QString serviceType
Definition: kservice.h:692
KService::ServiceTypeAndPreference::preference
int preference
Definition: kservice.h:691
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal