• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.11.2 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 
47 int servicesDebugArea() {
48  static int s_area = KDebug::registerArea("kdecore (services)");
49  return s_area;
50 }
51 
52 QDataStream &operator<<(QDataStream &s, const KService::ServiceTypeAndPreference &st)
53 {
54  s << st.preference << st.serviceType;
55  return s;
56 }
57 QDataStream &operator>>(QDataStream &s, KService::ServiceTypeAndPreference &st)
58 {
59  s >> st.preference >> st.serviceType;
60  return s;
61 }
62 
63 void 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 
231  // The following searches through the list for duplicate, inherited mimetypes
232  // For example, if application/rtf and text/plain are both listed application/rtf is removed
233  // since it is inherited from text/plain
234  // This is a reworked fix for revision 871cccc8a88a600c8f850a020d44bfc5f5858caa
235  bool shouldAdd = true;
236  KMimeType::Ptr mimeType1 = KMimeTypeRepository::self()->findMimeTypeByName(st);
237  if (mimeType1) {
238  foreach(const QString mime2, lstServiceTypes) {
239  // Don't compare the mimetype with itself
240  if (st == mime2) {
241  continue;
242  }
243 
244  // is checks for inheritance and aliases, so this should suffice
245  if (mimeType1->is(mime2)) {
246  shouldAdd = false;
247  break;
248  }
249  }
250  }
251 
252  // Only add unique mimetypes
253  if (shouldAdd) {
254  int initialPreference = m_initialPreference;
255  if (st_it.hasNext()) {
256  // TODO better syntax - separate group with mimetype=number entries?
257  bool isNumber;
258  const int val = st_it.peekNext().toInt(&isNumber);
259  if (isNumber) {
260  initialPreference = val;
261  st_it.next();
262  }
263  }
264  m_serviceTypes.push_back(KService::ServiceTypeAndPreference(initialPreference, st));
265  } else {
266  //kDebug(servicesDebugArea())<<"Not adding"<<st<<"from"<<entryPath;
267  }
268  }
269 
270  if (entryMap.contains(QLatin1String("Actions"))) {
271  parseActions(config, q);
272  }
273 
274  QString dbusStartupType = desktopGroup.readEntry("X-DBUS-StartupType").toLower();
275  entryMap.remove(QLatin1String("X-DBUS-StartupType"));
276  if (dbusStartupType == QLatin1String("unique"))
277  m_DBUSStartusType = KService::DBusUnique;
278  else if (dbusStartupType == QLatin1String("multi"))
279  m_DBUSStartusType = KService::DBusMulti;
280  else if (dbusStartupType == QLatin1String("wait"))
281  m_DBUSStartusType = KService::DBusWait;
282  else
283  m_DBUSStartusType = KService::DBusNone;
284 
285  m_strDesktopEntryName = _name.toLower();
286 
287  m_bAllowAsDefault = desktopGroup.readEntry("AllowDefault", true);
288  entryMap.remove(QLatin1String("AllowDefault"));
289 
290  // allow plugin users to translate categories without needing a separate key
291  QMap<QString,QString>::Iterator entry = entryMap.find(QString::fromLatin1("X-KDE-PluginInfo-Category"));
292  if (entry != entryMap.end()) {
293  const QString& key = entry.key();
294  m_mapProps.insert(key, QVariant(desktopGroup.readEntryUntranslated(key)));
295  m_mapProps.insert(key + QLatin1String("-Translated"), QVariant(*entry));
296  entryMap.erase(entry);
297  }
298 
299  // Store all additional entries in the property map.
300  // A QMap<QString,QString> would be easier for this but we can't
301  // break BC, so we have to store it in m_mapProps.
302 // qDebug("Path = %s", entryPath.toLatin1().constData());
303  QMap<QString,QString>::ConstIterator it = entryMap.constBegin();
304  for( ; it != entryMap.constEnd();++it) {
305  const QString key = it.key();
306  // do not store other translations like Name[fr]; kbuildsycoca will rerun if we change languages anyway
307  if (!key.contains(QLatin1Char('['))) {
308  //kDebug(servicesDebugArea()) << " Key =" << key << " Data =" << *it;
309  m_mapProps.insert(key, QVariant(*it));
310  }
311  }
312 }
313 
314 void KServicePrivate::parseActions(const KDesktopFile *config, KService* q)
315 {
316  const QStringList keys = config->readActions();
317  if (keys.isEmpty())
318  return;
319 
320  QStringList::ConstIterator it = keys.begin();
321  const QStringList::ConstIterator end = keys.end();
322  for ( ; it != end; ++it ) {
323  const QString group = *it;
324  if (group == QLatin1String("_SEPARATOR_")) {
325  m_actions.append(KServiceAction(group, QString(), QString(), QString(), false));
326  continue;
327  }
328 
329  if (config->hasActionGroup(group)) {
330  const KConfigGroup cg = config->actionGroup(group);
331  if ( !cg.hasKey( "Name" ) || !cg.hasKey( "Exec" ) ) {
332  kWarning(servicesDebugArea()) << "The action" << group << "in the desktop file" << q->entryPath()
333  << "has no Name or no Exec key";
334  } else {
335  m_actions.append(KServiceAction(group,
336  cg.readEntry("Name"),
337  cg.readEntry("Icon"),
338  cg.readEntry("Exec"),
339  cg.readEntry("NoDisplay", false)));
340  }
341  } else {
342  kWarning(servicesDebugArea()) << "The desktop file" << q->entryPath()
343  << "references the action" << group << "but doesn't define it";
344  }
345  }
346 }
347 
348 void KServicePrivate::load(QDataStream& s)
349 {
350  qint8 def, term;
351  qint8 dst, initpref;
352  QStringList dummyList; // KDE4: you can reuse this for another QStringList. KDE5: remove
353 
354  // WARNING: THIS NEEDS TO REMAIN COMPATIBLE WITH PREVIOUS KDE 4.x VERSIONS!
355  // !! This data structure should remain binary compatible at all times !!
356  // You may add new fields at the end. Make sure to update the version
357  // number in ksycoca.h
358  s >> m_strType >> m_strName >> m_strExec >> m_strIcon
359  >> term >> m_strTerminalOptions
360  >> m_strPath >> m_strComment >> dummyList >> def >> m_mapProps
361  >> m_strLibrary
362  >> dst
363  >> m_strDesktopEntryName
364  >> initpref
365  >> m_lstKeywords >> m_strGenName
366  >> categories >> menuId >> m_actions >> m_serviceTypes;
367 
368  m_bAllowAsDefault = (bool)def;
369  m_bTerminal = (bool)term;
370  m_DBUSStartusType = (KService::DBusStartupType) dst;
371  m_initialPreference = initpref;
372 
373  m_bValid = true;
374 }
375 
376 void KServicePrivate::save(QDataStream& s)
377 {
378  KSycocaEntryPrivate::save( s );
379  qint8 def = m_bAllowAsDefault, initpref = m_initialPreference;
380  qint8 term = m_bTerminal;
381  qint8 dst = (qint8) m_DBUSStartusType;
382 
383  // WARNING: THIS NEEDS TO REMAIN COMPATIBLE WITH PREVIOUS KDE 4.x VERSIONS!
384  // !! This data structure should remain binary compatible at all times !!
385  // You may add new fields at the end. Make sure to update the version
386  // number in ksycoca.h
387  s << m_strType << m_strName << m_strExec << m_strIcon
388  << term << m_strTerminalOptions
389  << m_strPath << m_strComment << QStringList() << def << m_mapProps
390  << m_strLibrary
391  << dst
392  << m_strDesktopEntryName
393  << initpref
394  << m_lstKeywords << m_strGenName
395  << categories << menuId << m_actions << m_serviceTypes;
396 }
397 
399 
400 KService::KService( const QString & _name, const QString &_exec, const QString &_icon)
401  : KSycocaEntry(*new KServicePrivate(QString()))
402 {
403  Q_D(KService);
404  d->m_strType = QString::fromLatin1("Application");
405  d->m_strName = _name;
406  d->m_strExec = _exec;
407  d->m_strIcon = _icon;
408  d->m_bTerminal = false;
409  d->m_bAllowAsDefault = true;
410  d->m_initialPreference = 10;
411 }
412 
413 
414 KService::KService( const QString & _fullpath )
415  : KSycocaEntry(*new KServicePrivate(_fullpath))
416 {
417  Q_D(KService);
418 
419  KDesktopFile config( _fullpath );
420  d->init(&config, this);
421 }
422 
423 KService::KService( const KDesktopFile *config )
424  : KSycocaEntry(*new KServicePrivate(config->fileName()))
425 {
426  Q_D(KService);
427 
428  d->init(config, this);
429 }
430 
431 KService::KService( QDataStream& _str, int _offset )
432  : KSycocaEntry(*new KServicePrivate(_str, _offset))
433 {
434 }
435 
436 KService::~KService()
437 {
438 }
439 
440 bool KService::hasServiceType( const QString& serviceType ) const
441 {
442  Q_D(const KService);
443 
444  if (!d->m_bValid) return false; // (useless) safety test
445  const KServiceType::Ptr ptr = KServiceType::serviceType( serviceType );
446  if (!ptr)
447  return false;
448  const int serviceOffset = offset();
449  // doesn't seem to work:
450  //if ( serviceOffset == 0 )
451  // serviceOffset = serviceByStorageId( storageId() );
452  if ( serviceOffset )
453  return KServiceFactory::self()->hasOffer( ptr->offset(), ptr->serviceOffersOffset(), serviceOffset );
454 
455  // fall-back code for services that are NOT from ksycoca
456  // For each service type we are associated with, if it doesn't
457  // match then we try its parent service types.
458  QVector<ServiceTypeAndPreference>::ConstIterator it = d->m_serviceTypes.begin();
459  for( ; it != d->m_serviceTypes.end(); ++it ) {
460  const QString& st = (*it).serviceType;
461  //kDebug(servicesDebugArea()) << " has " << (*it);
462  if ( st == ptr->name() )
463  return true;
464  // also the case of parent servicetypes
465  KServiceType::Ptr p = KServiceType::serviceType( st );
466  if ( p && p->inherits( ptr->name() ) )
467  return true;
468  }
469  return false;
470 }
471 
472 #ifndef KDE_NO_DEPRECATED
473 bool KService::hasMimeType( const KServiceType* ptr ) const
474 {
475  if (!ptr) return false;
476 
477  return hasMimeType(ptr->name());
478 }
479 #endif
480 
481 bool KService::hasMimeType(const QString& mimeType) const
482 {
483  Q_D(const KService);
484  const QString mime = KMimeTypeRepository::self()->canonicalName(mimeType);
485  int serviceOffset = offset();
486  if ( serviceOffset ) {
487  KMimeTypeFactory *factory = KMimeTypeFactory::self();
488  const int mimeOffset = factory->entryOffset(mime);
489  const int serviceOffersOffset = factory->serviceOffersOffset(mime);
490  if (serviceOffersOffset == -1)
491  return false;
492  return KServiceFactory::self()->hasOffer(mimeOffset, serviceOffersOffset, serviceOffset);
493  }
494 
495  // fall-back code for services that are NOT from ksycoca
496  QVector<ServiceTypeAndPreference>::ConstIterator it = d->m_serviceTypes.begin();
497  for( ; it != d->m_serviceTypes.end(); ++it ) {
498  const QString& st = (*it).serviceType;
499  //kDebug(servicesDebugArea()) << " has " << (*it);
500  if ( st == mime )
501  return true;
502  // TODO: should we handle inherited mimetypes here?
503  // KMimeType was in kio when this code was written, this is the only reason it's not done.
504  // But this should matter only in a very rare case, since most code gets KServices from ksycoca.
505  // Warning, change hasServiceType if you implement this here (and check kbuildservicefactory).
506  }
507  return false;
508 }
509 
510 QVariant KServicePrivate::property( const QString& _name) const
511 {
512  return property( _name, QVariant::Invalid);
513 }
514 
515 // Return a string QVariant if string isn't null, and invalid variant otherwise
516 // (the variant must be invalid if the field isn't in the .desktop file)
517 // This allows trader queries like "exist Library" to work.
518 static QVariant makeStringVariant( const QString& string )
519 {
520  // Using isEmpty here would be wrong.
521  // Empty is "specified but empty", null is "not specified" (in the .desktop file)
522  return string.isNull() ? QVariant() : QVariant( string );
523 }
524 
525 QVariant KService::property( const QString& _name, QVariant::Type t ) const
526 {
527  Q_D(const KService);
528  return d->property(_name, t);
529 }
530 
531 QVariant KServicePrivate::property( const QString& _name, QVariant::Type t ) const
532 {
533  if ( _name == QLatin1String("Type") )
534  return QVariant( m_strType ); // can't be null
535  else if ( _name == QLatin1String("Name") )
536  return QVariant( m_strName ); // can't be null
537  else if ( _name == QLatin1String("Exec") )
538  return makeStringVariant( m_strExec );
539  else if ( _name == QLatin1String("Icon") )
540  return makeStringVariant( m_strIcon );
541  else if ( _name == QLatin1String("Terminal") )
542  return QVariant( m_bTerminal );
543  else if ( _name == QLatin1String("TerminalOptions") )
544  return makeStringVariant( m_strTerminalOptions );
545  else if ( _name == QLatin1String("Path") )
546  return makeStringVariant( m_strPath );
547  else if ( _name == QLatin1String("Comment") )
548  return makeStringVariant( m_strComment );
549  else if ( _name == QLatin1String("GenericName") )
550  return makeStringVariant( m_strGenName );
551  else if ( _name == QLatin1String("ServiceTypes") )
552  return QVariant( serviceTypes() );
553  else if ( _name == QLatin1String("AllowAsDefault") )
554  return QVariant( m_bAllowAsDefault );
555  else if ( _name == QLatin1String("InitialPreference") )
556  return QVariant( m_initialPreference );
557  else if ( _name == QLatin1String("Library") )
558  return makeStringVariant( m_strLibrary );
559  else if ( _name == QLatin1String("DesktopEntryPath") ) // can't be null
560  return QVariant( path );
561  else if ( _name == QLatin1String("DesktopEntryName"))
562  return QVariant( m_strDesktopEntryName ); // can't be null
563  else if ( _name == QLatin1String("Categories"))
564  return QVariant( categories );
565  else if ( _name == QLatin1String("Keywords"))
566  return QVariant( m_lstKeywords );
567 
568  // Ok we need to convert the property from a QString to its real type.
569  // Maybe the caller helped us.
570  if (t == QVariant::Invalid)
571  {
572  // No luck, let's ask KServiceTypeFactory what the type of this property
573  // is supposed to be.
574  t = KServiceTypeFactory::self()->findPropertyTypeByName(_name);
575  if (t == QVariant::Invalid)
576  {
577  kDebug(servicesDebugArea()) << "Request for unknown property '" << _name << "'\n";
578  return QVariant(); // Unknown property: Invalid variant.
579  }
580  }
581 
582  QMap<QString,QVariant>::ConstIterator it = m_mapProps.find( _name );
583  if ( (it == m_mapProps.end()) || (!it->isValid()))
584  {
585  //kDebug(servicesDebugArea()) << "Property not found " << _name;
586  return QVariant(); // No property set.
587  }
588 
589  switch(t)
590  {
591  case QVariant::String:
592  return *it; // no conversion necessary
593  default:
594  // All others
595  // For instance properties defined as StringList, like MimeTypes.
596  // XXX This API is accessible only through a friend declaration.
597  return KConfigGroup::convertToQVariant(_name.toUtf8().constData(), it->toString().toUtf8(), t);
598  }
599 }
600 
601 QStringList KServicePrivate::propertyNames() const
602 {
603  QStringList res;
604 
605  QMap<QString,QVariant>::ConstIterator it = m_mapProps.begin();
606  for( ; it != m_mapProps.end(); ++it )
607  res.append( it.key() );
608 
609  res.append( QString::fromLatin1("Type") );
610  res.append( QString::fromLatin1("Name") );
611  res.append( QString::fromLatin1("Comment") );
612  res.append( QString::fromLatin1("GenericName") );
613  res.append( QString::fromLatin1("Icon") );
614  res.append( QString::fromLatin1("Exec") );
615  res.append( QString::fromLatin1("Terminal") );
616  res.append( QString::fromLatin1("TerminalOptions") );
617  res.append( QString::fromLatin1("Path") );
618  res.append( QString::fromLatin1("ServiceTypes") );
619  res.append( QString::fromLatin1("AllowAsDefault") );
620  res.append( QString::fromLatin1("InitialPreference") );
621  res.append( QString::fromLatin1("Library") );
622  res.append( QString::fromLatin1("DesktopEntryPath") );
623  res.append( QString::fromLatin1("DesktopEntryName") );
624  res.append( QString::fromLatin1("Keywords") );
625  res.append( QString::fromLatin1("Categories") );
626 
627  return res;
628 }
629 
630 KService::List KService::allServices()
631 {
632  return KServiceFactory::self()->allServices();
633 }
634 
635 #ifndef KDE_NO_DEPRECATED
636 KService::Ptr KService::serviceByName( const QString& _name )
637 {
638  return KServiceFactory::self()->findServiceByName( _name );
639 }
640 #endif
641 
642 KService::Ptr KService::serviceByDesktopPath( const QString& _name )
643 {
644  return KServiceFactory::self()->findServiceByDesktopPath( _name );
645 }
646 
647 KService::Ptr KService::serviceByDesktopName( const QString& _name )
648 {
649  // Prefer kde4-konsole over kde-konsole, if both are available
650  QString name = _name.toLower();
651  KService::Ptr s;
652  if (!_name.startsWith(QLatin1String("kde4-")))
653  s = KServiceFactory::self()->findServiceByDesktopName(QString::fromLatin1("kde4-") + name);
654  if (!s)
655  s = KServiceFactory::self()->findServiceByDesktopName( name );
656 
657  return s;
658 }
659 
660 KService::Ptr KService::serviceByMenuId( const QString& _name )
661 {
662  return KServiceFactory::self()->findServiceByMenuId( _name );
663 }
664 
665 KService::Ptr KService::serviceByStorageId( const QString& _storageId )
666 {
667  KService::Ptr service = KService::serviceByMenuId( _storageId );
668  if (service)
669  return service;
670 
671  service = KService::serviceByDesktopPath(_storageId);
672  if (service)
673  return service;
674 
675  if (!QDir::isRelativePath(_storageId) && QFile::exists(_storageId))
676  return KService::Ptr(new KService(_storageId));
677 
678  QString tmp = _storageId;
679  tmp = tmp.mid(tmp.lastIndexOf(QLatin1Char('/'))+1); // Strip dir
680 
681  if (tmp.endsWith(QLatin1String(".desktop")))
682  tmp.truncate(tmp.length()-8);
683 
684  if (tmp.endsWith(QLatin1String(".kdelnk")))
685  tmp.truncate(tmp.length()-7);
686 
687  service = KService::serviceByDesktopName(tmp);
688 
689  return service;
690 }
691 
692 bool KService::substituteUid() const {
693  QVariant v = property(QLatin1String("X-KDE-SubstituteUID"), QVariant::Bool);
694  return v.isValid() && v.toBool();
695 }
696 
697 QString KService::username() const {
698  // See also KDesktopFile::tryExec()
699  QString user;
700  QVariant v = property(QLatin1String("X-KDE-Username"), QVariant::String);
701  user = v.isValid() ? v.toString() : QString();
702  if (user.isEmpty())
703  user = QString::fromLocal8Bit(qgetenv("ADMIN_ACCOUNT"));
704  if (user.isEmpty())
705  user = QString::fromLatin1("root");
706  return user;
707 }
708 
709 bool KService::showInKDE() const
710 {
711  Q_D(const KService);
712 
713  QMap<QString,QVariant>::ConstIterator it = d->m_mapProps.find( QString::fromLatin1("OnlyShowIn") );
714  if ( (it != d->m_mapProps.end()) && (it->isValid()))
715  {
716  const QStringList aList = it->toString().split(QLatin1Char(';'));
717  if (!aList.contains(QString::fromLatin1("KDE")))
718  return false;
719  }
720 
721  it = d->m_mapProps.find( QString::fromLatin1("NotShowIn") );
722  if ( (it != d->m_mapProps.end()) && (it->isValid()))
723  {
724  const QStringList aList = it->toString().split(QLatin1Char(';'));
725  if (aList.contains(QString::fromLatin1("KDE")))
726  return false;
727  }
728  return true;
729 }
730 
731 bool KService::noDisplay() const {
732  if ( qvariant_cast<bool>(property(QString::fromLatin1("NoDisplay"), QVariant::Bool)) )
733  return true;
734 
735  if (!showInKDE())
736  return true;
737 
738  if (!KAuthorized::authorizeControlModule( storageId() ) )
739  return true;
740 
741  return false;
742 }
743 
744 QString KService::untranslatedGenericName() const {
745  QVariant v = property(QString::fromLatin1("UntranslatedGenericName"), QVariant::String);
746  return v.isValid() ? v.toString() : QString();
747 }
748 
749 QString KService::parentApp() const {
750  Q_D(const KService);
751  QMap<QString,QVariant>::ConstIterator it = d->m_mapProps.find(QLatin1String("X-KDE-ParentApp"));
752  if ( (it == d->m_mapProps.end()) || (!it->isValid()))
753  {
754  return QString();
755  }
756 
757  return it->toString();
758 }
759 
760 QString KService::pluginKeyword() const
761 {
762  Q_D(const KService);
763  QMap<QString,QVariant>::ConstIterator it = d->m_mapProps.find(QString::fromLatin1("X-KDE-PluginKeyword"));
764  if ((it == d->m_mapProps.end()) || (!it->isValid())) {
765  return QString();
766  }
767 
768  return it->toString();
769 }
770 
771 QString KService::docPath() const
772 {
773  Q_D(const KService);
774  QMap<QString,QVariant>::ConstIterator it = d->m_mapProps.find(QLatin1String("X-DocPath"));
775  if ((it == d->m_mapProps.end()) || (!it->isValid())) {
776  it = d->m_mapProps.find(QString::fromLatin1("DocPath"));
777  if ((it == d->m_mapProps.end()) || (!it->isValid())) {
778  return QString();
779  }
780  }
781 
782  return it->toString();
783 }
784 
785 bool KService::allowMultipleFiles() const {
786  Q_D(const KService);
787  // Can we pass multiple files on the command line or do we have to start the application for every single file ?
788  return (d->m_strExec.contains( QLatin1String("%F") ) || d->m_strExec.contains( QLatin1String("%U") ) ||
789  d->m_strExec.contains( QLatin1String("%N") ) || d->m_strExec.contains( QLatin1String("%D") ));
790 }
791 
792 QStringList KService::categories() const
793 {
794  Q_D(const KService);
795  return d->categories;
796 }
797 
798 QString KService::menuId() const
799 {
800  Q_D(const KService);
801  return d->menuId;
802 }
803 
804 void KService::setMenuId(const QString &_menuId)
805 {
806  Q_D(KService);
807  d->menuId = _menuId;
808 }
809 
810 QString KService::storageId() const
811 {
812  Q_D(const KService);
813  return d->storageId();
814 }
815 
816 QString KService::locateLocal() const
817 {
818  Q_D(const KService);
819  if (d->menuId.isEmpty() || entryPath().startsWith(QLatin1String(".hidden")) ||
820  (QDir::isRelativePath(entryPath()) && d->categories.isEmpty()))
821  return KDesktopFile::locateLocal(entryPath());
822 
823  return KStandardDirs::locateLocal("xdgdata-apps", d->menuId);
824 }
825 
826 QString KService::newServicePath(bool showInMenu, const QString &suggestedName,
827  QString *menuId, const QStringList *reservedMenuIds)
828 {
829  Q_UNUSED(showInMenu); // TODO KDE5: remove argument
830 
831  QString base = suggestedName;
832  QString result;
833  for(int i = 1; true; i++)
834  {
835  if (i == 1)
836  result = base + QString::fromLatin1(".desktop");
837  else
838  result = base + QString::fromLatin1("-%1.desktop").arg(i);
839 
840  if (reservedMenuIds && reservedMenuIds->contains(result))
841  continue;
842 
843  // Lookup service by menu-id
844  KService::Ptr s = serviceByMenuId(result);
845  if (s)
846  continue;
847 
848  if (!KStandardDirs::locate("xdgdata-apps", result).isEmpty())
849  continue;
850 
851  break;
852  }
853  if (menuId)
854  *menuId = result;
855 
856  return KStandardDirs::locateLocal("xdgdata-apps", result);
857 }
858 
859 bool KService::isApplication() const
860 {
861  Q_D(const KService);
862  return d->m_strType == QLatin1String("Application");
863 }
864 
865 #ifndef KDE_NO_DEPRECATED
866 QString KService::type() const
867 {
868  Q_D(const KService);
869  return d->m_strType;
870 }
871 #endif
872 
873 QString KService::exec() const
874 {
875  Q_D(const KService);
876  if (d->m_strType == QLatin1String("Application") && d->m_strExec.isEmpty())
877  {
878  kWarning(servicesDebugArea()) << "The desktop entry file " << entryPath()
879  << " has Type=" << d->m_strType << " but has no Exec field." << endl;
880  }
881  return d->m_strExec;
882 }
883 
884 QString KService::library() const
885 {
886  Q_D(const KService);
887  return d->m_strLibrary;
888 }
889 
890 QString KService::icon() const
891 {
892  Q_D(const KService);
893  return d->m_strIcon;
894 }
895 
896 QString KService::terminalOptions() const
897 {
898  Q_D(const KService);
899  return d->m_strTerminalOptions;
900 }
901 
902 bool KService::terminal() const
903 {
904  Q_D(const KService);
905  return d->m_bTerminal;
906 }
907 
908 // KDE5: remove and port code to entryPath?
909 #ifndef KDE_NO_DEPRECATED
910 QString KService::desktopEntryPath() const
911 {
912  return entryPath();
913 }
914 #endif
915 
916 QString KService::desktopEntryName() const
917 {
918  Q_D(const KService);
919  return d->m_strDesktopEntryName;
920 }
921 
922 KService::DBusStartupType KService::dbusStartupType() const
923 {
924  Q_D(const KService);
925  return d->m_DBUSStartusType;
926 }
927 
928 QString KService::path() const
929 {
930  Q_D(const KService);
931  return d->m_strPath;
932 }
933 
934 QString KService::comment() const
935 {
936  Q_D(const KService);
937  return d->m_strComment;
938 }
939 
940 QString KService::genericName() const
941 {
942  Q_D(const KService);
943  return d->m_strGenName;
944 }
945 
946 QStringList KService::keywords() const
947 {
948  Q_D(const KService);
949  return d->m_lstKeywords;
950 }
951 
952 QStringList KServicePrivate::serviceTypes() const
953 {
954  QStringList ret;
955  QVector<KService::ServiceTypeAndPreference>::const_iterator it = m_serviceTypes.begin();
956  for ( ; it < m_serviceTypes.end(); ++it ) {
957  Q_ASSERT(!(*it).serviceType.isEmpty());
958  ret.append((*it).serviceType);
959  }
960  return ret;
961 }
962 
963 QStringList KService::serviceTypes() const
964 {
965  Q_D(const KService);
966  return d->serviceTypes();
967 }
968 
969 QStringList KService::mimeTypes() const
970 {
971  Q_D(const KService);
972  QStringList ret;
973  QVector<KService::ServiceTypeAndPreference>::const_iterator it = d->m_serviceTypes.begin();
974  for ( ; it < d->m_serviceTypes.end(); ++it ) {
975  const QString sv = (*it).serviceType;
976  if (KMimeType::mimeType(sv)) // keep only mimetypes, filter out servicetypes
977  ret.append(sv);
978  }
979  return ret;
980 }
981 
982 bool KService::allowAsDefault() const
983 {
984  Q_D(const KService);
985  return d->m_bAllowAsDefault;
986 }
987 
988 int KService::initialPreference() const
989 {
990  Q_D(const KService);
991  return d->m_initialPreference;
992 }
993 
994 void KService::setTerminal(bool b)
995 {
996  Q_D(KService);
997  d->m_bTerminal = b;
998 }
999 
1000 void KService::setTerminalOptions(const QString &options)
1001 {
1002  Q_D(KService);
1003  d->m_strTerminalOptions = options;
1004 }
1005 
1006 void KService::setExec(const QString& exec)
1007 {
1008  Q_D(KService);
1009 
1010  if (!exec.isEmpty()) {
1011  d->m_strExec = exec;
1012  d->path.clear();
1013  }
1014 }
1015 
1016 QVector<KService::ServiceTypeAndPreference> & KService::_k_accessServiceTypes()
1017 {
1018  Q_D(KService);
1019  return d->m_serviceTypes;
1020 }
1021 
1022 QList<KServiceAction> KService::actions() const
1023 {
1024  Q_D(const KService);
1025  return d->m_actions;
1026 }
QVariant
KServiceFactory::findServiceByDesktopPath
virtual KService::Ptr findServiceByDesktopPath(const QString &_name)
Find a service ( by desktop path, e.g.
Definition: kservicefactory.cpp:127
KSharedPtr< KMimeType >
KServiceTypeFactory::findPropertyTypeByName
QVariant::Type findPropertyTypeByName(const QString &_name)
Find a the property type of a named property.
Definition: kservicetypefactory.cpp:85
KServiceType::serviceType
static Ptr serviceType(const QString &_name)
Returns a pointer to the servicetype &#39;_name&#39; or 0L if the service type is unknown.
Definition: kservicetype.cpp:191
KDesktopFile::tryExec
bool tryExec() const
Checks whether the TryExec field contains a binary which is found on the local system.
Definition: kdesktopfile.cpp:278
KServiceFactory::findServiceByDesktopName
virtual KService::Ptr findServiceByDesktopName(const QString &_name)
Find a service (by desktop file name, e.g.
Definition: kservicefactory.cpp:107
KService::pluginKeyword
QString pluginKeyword() const
The keyword to be used when constructing the plugin using KPluginFactory.
Definition: kservice.cpp:760
KServicePrivate::m_strLibrary
QString m_strLibrary
Definition: kservice_p.h:83
KMimeTypeRepository::findMimeTypeByName
KMimeType::Ptr findMimeTypeByName(const QString &_name, KMimeType::FindByNameOption options=KMimeType::DontResolveAlias)
Creates a KMimeType.
Definition: kmimetyperepository.cpp:59
KService::noDisplay
bool noDisplay() const
Whether the entry should be suppressed in the K menu.
Definition: kservice.cpp:731
KFileSystemType::Type
Type
Definition: kfilesystemtype_p.h:28
KServicePrivate::m_bTerminal
bool m_bTerminal
Definition: kservice_p.h:96
KService::setExec
void setExec(const QString &exec)
Overrides the &quot;Exec=&quot; line of the service.
Definition: kservice.cpp:1006
kdebug.h
KService::_k_accessServiceTypes
QVector< ServiceTypeAndPreference > & _k_accessServiceTypes()
Definition: kservice.cpp:1016
KService::DBusNone
Definition: kservice.h:212
KServicePrivate::m_strExec
QString m_strExec
Definition: kservice_p.h:78
KService::locateLocal
QString locateLocal() const
Returns a path that can be used for saving changes to this service.
Definition: kservice.cpp:816
KService::ServiceTypeAndPreference
Definition: kservice.h:685
KServicePrivate::property
virtual QVariant property(const QString &name) const
Definition: kservice.cpp:510
KServicePrivate::m_serviceTypes
QVector< KService::ServiceTypeAndPreference > m_serviceTypes
Definition: kservice_p.h:87
KMacroExpander::group
Definition: kmacroexpander_unix.cpp:34
KServicePrivate::m_strComment
QString m_strComment
Definition: kservice_p.h:82
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&#39;s...
Definition: kservice.cpp:647
kauthorized.h
KDesktopFile::readComment
QString readComment() const
Returns the value of the &quot;Comment=&quot; entry.
Definition: kdesktopfile.cpp:194
KServicePrivate::serviceTypes
QStringList serviceTypes() const
Definition: kservice.cpp:952
KServiceTypeFactory::self
static KServiceTypeFactory * self()
Definition: kservicetypefactory.cpp:63
KServicePrivate::m_initialPreference
int m_initialPreference
Definition: kservice_p.h:85
KService
Represent a service, like an application or plugin bound to one or several mimetypes (or servicetypes...
Definition: kservice.h:58
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:2097
KService::ServiceTypeAndPreference::preference
int preference
Definition: kservice.h:691
KService::mimeTypes
QStringList mimeTypes() const
Returns the list of mime types that this service supports.
Definition: kservice.cpp:969
KService::property
QVariant property(const QString &_name, QVariant::Type t) const
Returns the requested property.
Definition: kservice.cpp:525
KServicePrivate::parseActions
void parseActions(const KDesktopFile *config, KService *q)
Definition: kservice.cpp:314
KMimeTypeFactory
Definition: kmimetypefactory.h:39
kservice_p.h
KService::hasServiceType
bool hasServiceType(const QString &serviceTypePtr) const
Checks whether the service supports this service type.
Definition: kservice.cpp:440
KServicePrivate::propertyNames
virtual QStringList propertyNames() const
Definition: kservice.cpp:601
KService::genericName
QString genericName() const
Returns the generic name for the service, if there is one (e.g.
Definition: kservice.cpp:940
kmimetyperepository_p.h
KServicePrivate::init
void init(const KDesktopFile *config, KService *q)
Definition: kservice.cpp:63
KServiceFactory::allServices
KService::List allServices()
Definition: kservicefactory.cpp:195
servicesDebugArea
int servicesDebugArea()
Definition: kservice.cpp:47
KService::docPath
QString docPath() const
The path to the documentation for this service.
Definition: kservice.cpp:771
KMimeTypeRepository::self
static KMimeTypeRepository * self()
Definition: kmimetyperepository.cpp:35
KServiceType
A service type is, well, a type of service, where a service is an application or plugin.
Definition: kservicetype.h:43
QString
KService::terminalOptions
QString terminalOptions() const
Returns any options associated with the terminal the service runs in, if it requires a terminal...
Definition: kservice.cpp:896
KService::substituteUid
bool substituteUid() const
Checks whether the service runs with a different user id.
Definition: kservice.cpp:692
KService::comment
QString comment() const
Returns the descriptive comment for the service, if there is one.
Definition: kservice.cpp:934
kdesktopfile.h
KServiceAction
Represents an action in a .desktop file Actions are defined with the config key Actions in the [Deskt...
Definition: kserviceaction.h:34
KSycocaEntryPrivate::path
QString path
Definition: ksycocaentry_p.h:77
KService::isApplication
bool isApplication() const
Services are either applications (executables) or dlopened libraries (plugins).
Definition: kservice.cpp:859
KGlobal::config
KSharedConfigPtr config()
Returns the general config object.
Definition: kglobal.cpp:138
KService::DBusWait
Definition: kservice.h:212
KService::exec
QString exec() const
Returns the executable.
Definition: kservice.cpp:873
KService::path
QString path() const
Returns the working directory to run the program in.
Definition: kservice.cpp:928
KServicePrivate::m_bValid
bool m_bValid
Definition: kservice_p.h:97
KDesktopFile::readType
QString readType() const
Returns the value of the &quot;Type=&quot; entry.
Definition: kdesktopfile.cpp:176
kservicefactory.h
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:982
KService::setMenuId
void setMenuId(const QString &menuId)
Definition: kservice.cpp:804
KSycocaEntryPrivate::save
virtual void save(QDataStream &s)
Definition: ksycocaentry.cpp:139
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
kglobal.h
KService::dbusStartupType
DBusStartupType dbusStartupType() const
Returns the DBUSStartupType supported by this service.
Definition: kservice.cpp:922
KService::allServices
static List allServices()
Returns the whole list of services.
Definition: kservice.cpp:630
KSycocaEntry::entryPath
QString entryPath() const
Definition: ksycocaentry.cpp:104
KConfigGroup::readEntryUntranslated
QString readEntryUntranslated(const QString &pKey, const QString &aDefault=QString()) const
Reads an untranslated string entry.
Definition: kconfiggroup.cpp:637
KService::setTerminal
void setTerminal(bool b)
Definition: kservice.cpp:994
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:826
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
kservicetypefactory.h
KServicePrivate::m_strIcon
QString m_strIcon
Definition: kservice_p.h:79
KSycocaEntry
Base class for all Sycoca entries.
Definition: ksycocaentry.h:41
KService::Ptr
KSharedPtr< KService > Ptr
Definition: kservice.h:61
QStringList
KService::~KService
virtual ~KService()
Definition: kservice.cpp:436
KService::menuId
QString menuId() const
Returns the menu ID of the service desktop entry.
Definition: kservice.cpp:798
KDebug::registerArea
static int registerArea(const QByteArray &areaName, bool enabled=true)
Definition: kdebug.cpp:856
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:988
KService::desktopEntryPath
QString desktopEntryPath() const
Returns the path to the location where the service desktop entry is stored.
Definition: kservice.cpp:910
KServicePrivate::m_lstKeywords
QStringList m_lstKeywords
Definition: kservice_p.h:92
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
KServicePrivate::m_strType
QString m_strType
Definition: kservice_p.h:76
KServicePrivate::menuId
QString menuId
Definition: kservice_p.h:75
KSycocaEntry::setDeleted
void setDeleted(bool deleted)
Sets whether or not this service is deleted.
Definition: ksycocaentry.cpp:122
KService::serviceByDesktopPath
static Ptr serviceByDesktopPath(const QString &_path)
Find a service based on its path as returned by entryPath().
Definition: kservice.cpp:642
kservice.h
KService::allowMultipleFiles
bool allowMultipleFiles() const
Checks whether this service can handle several files as startup arguments.
Definition: kservice.cpp:785
KService::username
QString username() const
Returns the user name, if the service runs with a different user id.
Definition: kservice.cpp:697
KService::icon
QString icon() const
Returns the name of the icon.
Definition: kservice.cpp:890
KServiceType::serviceOffersOffset
int serviceOffersOffset() const
Definition: kservicetype.cpp:226
KServicePrivate::m_strTerminalOptions
QString m_strTerminalOptions
Definition: kservice_p.h:80
KService::terminal
bool terminal() const
Checks whethe the service should be run in a terminal.
Definition: kservice.cpp:902
KService::library
QString library() const
Returns the name of the service&#39;s library.
Definition: kservice.cpp:884
KService::serviceByMenuId
static Ptr serviceByMenuId(const QString &_menuId)
Find a service by its menu-id.
Definition: kservice.cpp:660
kWarning
#define kWarning
Definition: kdebug.h:322
KDesktopFile::readActions
QStringList readActions() const
Returns a list of the &quot;Actions=&quot; entries.
Definition: kdesktopfile.cpp:237
KDesktopFile
KDE Desktop File Management.
Definition: kdesktopfile.h:38
KServicePrivate::save
virtual void save(QDataStream &)
Definition: kservice.cpp:376
KConfigGroup::hasKey
bool hasKey(const QString &key) const
Checks whether the key has an entry in this group.
Definition: kconfiggroup.cpp:1156
KServicePrivate::m_actions
QList< KServiceAction > m_actions
Definition: kservice_p.h:94
KConfigGroup
A class for one specific group in a KConfig object.
Definition: kconfiggroup.h:53
KDesktopFile::readGenericName
QString readGenericName() const
Returns the value of the &quot;GenericName=&quot; entry.
Definition: kdesktopfile.cpp:200
KDesktopFile::resource
const char * resource() const
Definition: kdesktopfile.cpp:376
KService::DBusUnique
Definition: kservice.h:212
KServicePrivate::m_strPath
QString m_strPath
Definition: kservice_p.h:81
KService::serviceTypes
QStringList serviceTypes() const
Returns the service types that this service supports.
Definition: kservice.cpp:963
KServicePrivate::m_strName
QString m_strName
Definition: kservice_p.h:77
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:400
KServicePrivate::m_strDesktopEntryName
QString m_strDesktopEntryName
Definition: kservice_p.h:89
KService::serviceByName
static Ptr serviceByName(const QString &_name)
Find a service by name, i.e.
Definition: kservice.cpp:636
KService::desktopEntryName
QString desktopEntryName() const
Returns the filename of the service desktop entry without any extension.
Definition: kservice.cpp:916
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:2103
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
KService::ServiceTypeAndPreference::serviceType
QString serviceType
Definition: kservice.h:692
kstandarddirs.h
KServiceType::inherits
bool inherits(const QString &servTypeName) const
Checks whether this service type is or inherits from servTypeName.
Definition: kservicetype.cpp:137
makeStringVariant
static QVariant makeStringVariant(const QString &string)
Definition: kservice.cpp:518
KServicePrivate
Definition: kservice_p.h:29
KServicePrivate::load
void load(QDataStream &)
Definition: kservice.cpp:348
KService::storageId
QString storageId() const
Returns a normalized ID suitable for storing in configuration files.
Definition: kservice.cpp:810
KServiceFactory::findServiceByName
KService::Ptr findServiceByName(const QString &_name)
Find a service (by translated name, e.g.
Definition: kservicefactory.cpp:86
KSycocaEntry::offset
int offset() const
Definition: ksycocaentry.cpp:133
KServiceFactory::findServiceByMenuId
virtual KService::Ptr findServiceByMenuId(const QString &_menuId)
Find a service ( by menu id, e.g.
Definition: kservicefactory.cpp:154
KSycocaEntry::isDeleted
bool isDeleted() const
Definition: ksycocaentry.cpp:116
bool
KService::type
QString type() const
Returns the type of the service.
Definition: kservice.cpp:866
KAuth::operator>>
QDataStream & operator>>(QDataStream &stream, ActionReply &reply)
Definition: kauthactionreply.cpp:186
KService::categories
QStringList categories() const
Returns a list of VFolder categories.
Definition: kservice.cpp:792
KService::setTerminalOptions
void setTerminalOptions(const QString &options)
Definition: kservice.cpp:1000
KDesktopFile::hasActionGroup
bool hasActionGroup(const QString &group) const
Returns true if the action group exists, false otherwise.
Definition: kdesktopfile.cpp:253
KDesktopFile::readIcon
QString readIcon() const
Returns the value of the &quot;Icon=&quot; entry.
Definition: kdesktopfile.cpp:182
KService::DBusStartupType
DBusStartupType
Describes the DBUS Startup type of the service.
Definition: kservice.h:212
kDebug
#define kDebug
Definition: kdebug.h:316
KMimeType::mimeType
static Ptr mimeType(const QString &name, FindByNameOption options=ResolveAliases)
Retrieve a pointer to the mime type name.
Definition: kmimetype.cpp:58
KDesktopFile::actionGroup
KConfigGroup actionGroup(const QString &group)
Sets the desktop action group.
Definition: kdesktopfile.cpp:243
KService::untranslatedGenericName
QString untranslatedGenericName() const
Returns the untranslated (US English) generic name for the service, if there is one (e...
Definition: kservice.cpp:744
KDesktopFile::readPath
QString readPath() const
Returns the value of the &quot;Path=&quot; entry.
Definition: kdesktopfile.cpp:206
KService::DBusMulti
Definition: kservice.h:212
KServicePrivate::m_mapProps
QMap< QString, QVariant > m_mapProps
Definition: kservice_p.h:91
KService::actions
QList< KServiceAction > actions() const
Returns the actions defined in this desktop file.
Definition: kservice.cpp:1022
KMimeTypeFactory::serviceOffersOffset
int serviceOffersOffset(const QString &mimeTypeName)
Returns the offset into the service offers for a given mimetype.
Definition: kmimetypefactory.cpp:55
KService::keywords
QStringList keywords() const
Returns a list of descriptive keywords the service, if there are any.
Definition: kservice.cpp:946
KMimeTypeRepository::canonicalName
QString canonicalName(const QString &mime)
Resolve mime if it&#39;s an alias, and return it otherwise.
Definition: kmimetyperepository.cpp:90
KService::hasMimeType
bool hasMimeType(const KServiceType *mimeTypePtr) const
Checks whether the service supports this mime type.
Definition: kservice.cpp:473
KServiceFactory::self
static KServiceFactory * self()
Definition: kservicefactory.cpp:81
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
KSycocaEntry::name
QString name() const
Definition: ksycocaentry.cpp:157
KServicePrivate::m_DBUSStartusType
KService::DBusStartupType m_DBUSStartusType
Definition: kservice_p.h:90
KAuthorized::authorizeControlModule
bool authorizeControlModule(const QString &menuId)
Returns whether access to a certain control module is authorized.
Definition: kauthorized.cpp:237
KServicePrivate::m_bAllowAsDefault
bool m_bAllowAsDefault
Definition: kservice_p.h:95
KDesktopFile::readName
QString readName() const
Returns the value of the &quot;Name=&quot; entry.
Definition: kdesktopfile.cpp:188
KServicePrivate::categories
QStringList categories
Definition: kservice_p.h:74
KAuth::operator<<
QDataStream & operator<<(QDataStream &d, const ActionReply &reply)
Definition: kauthactionreply.cpp:181
KService::showInKDE
bool showInKDE() const
Whether the service should be shown in KDE at all (including in context menus).
Definition: kservice.cpp:709
KConfigGroup::entryMap
QMap< QString, QString > entryMap() const
Returns a map (tree) of entries for all entries in this group.
Definition: kconfiggroup.cpp:603
QMap
KServicePrivate::m_strGenName
QString m_strGenName
Definition: kservice_p.h:93
kconfiggroup.h
kmimetypefactory.h
QList< Ptr >
KMimeType::is
bool is(const QString &mimeTypeName) const
Do not use name()==&quot;somename&quot; anymore, to check for a given mimetype.
Definition: kmimetype.cpp:556
KService::parentApp
QString parentApp() const
Name of the application this service belongs to.
Definition: kservice.cpp:749
KService::serviceByStorageId
static Ptr serviceByStorageId(const QString &_storageId)
Find a service by its storage-id or desktop-file path.
Definition: kservice.cpp:665
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Oct 22 2013 09:07:32 by doxygen 1.8.5 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.11.2 API Reference

Skip menu "kdelibs-4.11.2 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