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

KDECore

  • sources
  • kde-4.12
  • kdelibs
  • kdecore
  • services
kservicetypetrader.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000 Torben Weis <[email protected]>
3  Copyright (C) 2006 David Faure <[email protected]>
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 #ifndef __kservicetypetrader_h__
20 #define __kservicetypetrader_h__
21 
22 #include "kservice.h"
23 
70 class KDECORE_EXPORT KServiceTypeTrader
71 {
72 public:
76  ~KServiceTypeTrader();
77 
104  KService::List query( const QString& servicetype,
105  const QString& constraint = QString() ) const;
106 
113  KService::List defaultOffers( const QString& serviceType,
114  const QString& constraint = QString() ) const;
121  KService::Ptr preferredService( const QString & serviceType ) const;
122 
131  static KServiceTypeTrader* self();
132 
152  template <class T>
153  static T *createInstanceFromQuery(const QString &serviceType,
154  const QString &constraint = QString(), QObject *parent = 0,
155  const QVariantList &args = QVariantList(), QString *error = 0)
156  {
157  return createInstanceFromQuery<T>(serviceType, 0, parent, constraint, args, error);
158  }
159 
177  template <class T>
178  static T *createInstanceFromQuery(const QString &serviceType,
179  QWidget *parentWidget, QObject *parent, const QString &constraint = QString(),
180  const QVariantList &args = QVariantList(), QString *error = 0)
181  {
182  const KService::List offers = self()->query(serviceType, constraint);
183  if (error)
184  error->clear();
185  Q_FOREACH (const KService::Ptr &ptr, offers) {
186  T *component = ptr->template createInstance<T>(parentWidget, parent, args, error);
187  if (component) {
188  return component;
189  }
190  }
191  if (error && error->isEmpty())
192  *error = i18n("No service matching the requirements was found");
193  return 0;
194  }
195 
201 #ifndef KDE_NO_DEPRECATED
202  template <class T>
203  static KDE_DEPRECATED T *createInstanceFromQuery(const QString &serviceType, const QString &constraint,
204  QObject *parent, const QStringList &args, int *error = 0)
205  {
206  const KService::List offers = KServiceTypeTrader::self()->query(serviceType, constraint);
207  if (offers.isEmpty()) {
208  if (error) {
209  *error = KLibLoader::ErrNoServiceFound;
210  }
211  return 0;
212  }
213 
214  return KService::createInstance<T>(offers.begin(), offers.end(), parent, args, error);
215  }
216 #endif
217 
218 
222  static void applyConstraints( KService::List& lst,
223  const QString& constraint );
224 
225 private:
229  KServiceTypeTrader();
230 
231  // dissalow copy ctor and assignment operator
232  KServiceTypeTrader( const KServiceTypeTrader& other );
233  KServiceTypeTrader& operator=( const KServiceTypeTrader& rhs );
234 
235  class Private;
236  Private * const d;
237 };
238 
239 #endif
i18n
QString i18n(const char *text)
Returns a localized version of a string.
Definition: klocalizedstring.h:630
KSharedPtr< KService >
KLibLoader::ErrNoServiceFound
Definition: klibloader.h:170
T
#define T
KServiceTypeTrader::self
static KServiceTypeTrader * self()
This is a static pointer to the KServiceTypeTrader singleton.
Definition: kservicetypetrader.cpp:37
QString
QObject
QStringList
kservice.h
KServiceTypeTrader::query
KService::List query(const QString &servicetype, const QString &constraint=QString()) const
The main function in the KServiceTypeTrader class.
Definition: kservicetypetrader.cpp:134
KServiceTypeTrader
KDE's trader interface (similar to the CORBA Trader), which provides a way to query the KDE infrastru...
Definition: kservicetypetrader.h:70
KServiceTypeTrader::createInstanceFromQuery
static T * createInstanceFromQuery(const QString &serviceType, const QString &constraint=QString(), QObject *parent=0, const QVariantList &args=QVariantList(), QString *error=0)
Get a plugin from a trader query.
Definition: kservicetypetrader.h:153
KServiceTypeTrader::createInstanceFromQuery
static T * createInstanceFromQuery(const QString &serviceType, QWidget *parentWidget, QObject *parent, const QString &constraint=QString(), const QVariantList &args=QVariantList(), QString *error=0)
Get a plugin from a trader query.
Definition: kservicetypetrader.h:178
KServiceTypeTrader::createInstanceFromQuery
static T * createInstanceFromQuery(const QString &serviceType, const QString &constraint, QObject *parent, const QStringList &args, int *error=0)
Definition: kservicetypetrader.h:203
QList< Ptr >
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:09 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



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