19 #include "kdcopservicestarter.h"
21 #include <kapplication.h>
23 #include <kstaticdeleter.h>
26 #include <dcopclient.h>
28 static KStaticDeleter<KDCOPServiceStarter> dss_sd;
38 KDCOPServiceStarter::KDCOPServiceStarter()
45 KDCOPServiceStarter::~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 );