• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
TDETrader Class Reference

#include <ktrader.h>

Inherits TQObject.

Public Types

typedef TQValueList
< KService::Ptr > 
OfferList
 
typedef TQValueListIterator
< KService::Ptr > 
OfferListIterator
 

Public Member Functions

virtual ~TDETrader ()
 
virtual OfferList query (const TQString &servicetype, const TQString &constraint=TQString::null, const TQString &preferences=TQString::null) const
 
OfferList query (const TQString &servicetype, const TQString &genericServiceType, const TQString &constraint, const TQString &preferences) const
 

Static Public Member Functions

static TDETrader * self ()
 

Protected Member Functions

virtual void virtual_hook (int id, void *data)
 

Detailed Description

A Trader interface, similar to the CORBA Trader.

Basically, it provides a way for an application to query all KDE services (that is, applications and components) that match a specific set of requirements. This allows you to find an application in real-time without you having to hard-code the name and/or path of the application.

Examples

A few examples will make this a lot more clear.

Say you have an application that will display HTML. In this example, you don't want to link to tdehtml... and furthermore, you really don't care if the HTML browser is ours or not, as long as it works. The way that you formulate your query as well as the way that you execute the browser depends on whether or not you want the browser to run stand-alone or embedded.

If you want the browser to run standalone, then you will limit the query to search for all services that handle 'text/html' and, furthermore, they must be applications (Type=Application). You then will use KRun::run() to invoke the application. In "trader-speak", this looks like this:

TDETrader::OfferList offers = TDETrader::self()->query("text/html", "Type == 'Application'");
KService::Ptr ptr = offers.first();
KURL::List lst;
lst.append("http://www.kde.org/index.html");
KRun::run(*ptr, lst);

Now, say that you want to list all KParts component that can handle HTML.

TDETrader::OfferList offers = TDETrader::self()->query("text/html", "KParts/ReadOnlyPart");

If you want to get the preferred KParts component for text/html you could use KServiceTypeProfile::preferredService("text/html", "KParts/ReadOnlyPart"), although if this is about loading that component you would rather use KParts::ComponentFactory directly.

Please note that when including property names containing arithmetic operators like - or +, then you have to put brackets around the property name, in order to correctly separate arithmetic operations from the name. So for example a constraint expression like X-TDE-Blah < 4 needs to be written as [X-TDE-Blah] < 4 otherwise it could also be interpreted as Substract the numeric value of the property "KDE" and "Blah" from the property "X" and make sure it is less than 4. Instead of the other meaning, make sure that the numeric value of "X-TDE-Blah" is less than 4.

See also the formal syntax defined in Trader Syntax .

Provides a way to query the KDE infrastructure for specific applications or components.

Author
Torben Weis weis@.nosp@m.kde..nosp@m.org

Definition at line 85 of file ktrader.h.

Member Typedef Documentation

typedef TQValueList<KService::Ptr> TDETrader::OfferList

A list of services.

Definition at line 92 of file ktrader.h.

Constructor & Destructor Documentation

TDETrader::~TDETrader ( )
virtual

Standard destructor.

Definition at line 102 of file ktrader.cpp.

Member Function Documentation

TDETrader::OfferList TDETrader::query ( const TQString &  servicetype,
const TQString &  constraint = TQString::null,
const TQString &  preferences = TQString::null 
) const
virtual

The main function in the TDETrader class.

It will return a list of services that match your specifications. The only required parameter is the service type. This is something like 'text/plain' or 'text/html'. The constraint parameter is used to limit the possible choices returned based on the constraints you give it.

The constraint language is rather full. The most common keywords are AND, OR, NOT, IN, and EXIST, all used in an almost spoken-word form. An example is:

(Type == 'Service') and (('KParts/ReadOnlyPart' in ServiceTypes) or (exist Exec))

The keys used in the query (Type, ServiceType, Exec) are all fields found in the .desktop files.

Parameters
servicetypeA service type like 'text/plain', 'text/html', or 'KOfficePlugin'.
constraintA constraint to limit the choices returned, TQString::null to get all services of the given servicetype
preferencesIndicates a particular preference to return, TQString::null to ignore. Uses an expression in the constraint language that must return a number
Returns
A list of services that satisfy the query
See also
http://developer.kde.org/documentation/library/3.5-api/tdelibs-apidocs/tdeio/tdeio/html/tradersyntax.html

Definition at line 106 of file ktrader.cpp.

TDETrader::OfferList TDETrader::query ( const TQString &  servicetype,
const TQString &  genericServiceType,
const TQString &  constraint,
const TQString &  preferences 
) const

A variant of query(), that takes two service types as an input.

It is not exactly the same as adding the second service type in the constraints of the other query call, because this one takes into account user preferences for this combination of service types.

Example usage: To get list of applications that can handle a given mimetype, set servicetype to the mimetype and genericServiceType is "Application". To get list of embeddable components that can handle a given mimetype, set servicetype to the mimetype and genericServiceType is "KParts/ReadOnlyPart".

Parameters
servicetypeA service type like 'text/plain', 'text/html', or 'KOfficePlugin'.
genericServiceTypea basic service type, like 'KParts/ReadOnlyPart' or 'Application'
constraintA constraint to limit the choices returned, TQString::null to get all services of the given servicetype
preferencesIndicates a particular preference to return, TQString::null to ignore. Uses an expression in the constraint language that must return a number
Returns
A list of services that satisfy the query
See also
http://developer.kde.org/documentation/library/kdeqt/tradersyntax.html

Definition at line 112 of file ktrader.cpp.

TDETrader * TDETrader::self ( )
static

This is a static pointer to a TDETrader instance.

You will need to use this to access the TDETrader functionality since the constuctors are protected.

Returns
Static TDETrader instance

Definition at line 90 of file ktrader.cpp.


The documentation for this class was generated from the following files:
  • ktrader.h
  • ktrader.cpp

tdeio/tdeio

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

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.8.8
This website is maintained by Timothy Pearson.