19#include "kdcopservicestarter.h"
21#include <tdeapplication.h>
23#include <kstaticdeleter.h>
26#include <dcopclient.h>
28static KStaticDeleter<KDCOPServiceStarter> dss_sd;
38KDCOPServiceStarter::KDCOPServiceStarter()
45KDCOPServiceStarter::~KDCOPServiceStarter()
50 const TQString& _constraint,
51 const TQString& preferences,
52 TQString *error, TQCString* pDcopService,
57 TQString constraint = _constraint;
58 if ( !constraint.isEmpty() )
59 constraint +=
" and ";
60 constraint +=
"exist [X-DCOP-ServiceName]";
62 if ( offers.isEmpty() ) {
64 *error = i18n(
"No service implementing %1").arg( serviceType );
65 kdWarning() <<
"KDCOPServiceStarter: No service implementing " << serviceType << endl;
68 KService::Ptr ptr = offers.first();
69 TQCString dcopService = ptr->property(
"X-DCOP-ServiceName").toString().latin1();
71 if ( !kapp->dcopClient()->isApplicationRegistered( dcopService ) )
74 if (
startServiceFor( serviceType, constraint, preferences, &error, &dcopService, flags ) != 0 )
76 kdDebug() <<
"KDCOPServiceStarter: Couldn't start service: " << error << endl;
80 kdDebug() <<
"KDCOPServiceStarter: DCOP service is available now, as " << dcopService << endl;
82 *pDcopService = dcopService;
87 const TQString& constraint,
88 const TQString& preferences,
89 TQString *error, TQCString* dcopService,
int )
92 if ( offers.isEmpty() )
94 KService::Ptr ptr = offers.first();
95 kdDebug() <<
"KDCOPServiceStarter: starting " << ptr->desktopEntryPath() << endl;
96 return kapp->startServiceByDesktopPath( ptr->desktopEntryPath(), TQStringList(), error, dcopService );
A generic DCOP service starter, using TDETrader.
int findServiceFor(const TQString &serviceType, const TQString &constraint=TQString::null, const TQString &preferences=TQString::null, TQString *error=0, TQCString *dcopService=0, int flags=0)
Check if a given DCOP interface is available - from the serviceType it's supposed to implement.
virtual int startServiceFor(const TQString &serviceType, const TQString &constraint=TQString::null, const TQString &preferences=TQString::null, TQString *error=0, TQCString *dcopService=0, int flags=0)
Find an implementation of the given serviceType, and start it, to use its DCOP interface.
virtual OfferList query(const TQString &servicetype, const TQString &constraint=TQString::null, const TQString &preferences=TQString::null) const
The main function in the TDETrader class.
static TDETrader * self()
This is a static pointer to a TDETrader instance.
TQValueList< KService::Ptr > OfferList
A list of services.