本文整理汇总了C++中DCOPClient类的典型用法代码示例。如果您正苦于以下问题:C++ DCOPClient类的具体用法?C++ DCOPClient怎么用?C++ DCOPClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DCOPClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kdDebug
int KPrinterImpl::dcopPrint(const TQString& cmd, const TQStringList& files, bool removeflag)
{
kdDebug(500) << "tdeprint: print command: " << cmd << endl;
int result = 0;
DCOPClient *dclient = kapp->dcopClient();
if (!dclient || (!dclient->isAttached() && !dclient->attach()))
{
return result;
}
TQByteArray data, replyData;
TQCString replyType;
TQDataStream arg( data, IO_WriteOnly );
arg << cmd;
arg << files;
arg << removeflag;
if (dclient->call( "kded", "tdeprintd", "print(TQString,TQStringList,bool)", data, replyType, replyData ))
{
if (replyType == "int")
{
TQDataStream _reply_stream( replyData, IO_ReadOnly );
_reply_stream >> result;
}
}
示例2: sendCommand
void DictApplet::sendCommand(const QCString &fun, const QString &data)
{
if (waiting > 0) {
waiting = 1;
delayedFunc = fun.copy();
delayedData = data;
return;
}
DCOPClient *client = kapp->dcopClient();
if (!client->isApplicationRegistered("kdict")) {
KApplication::startServiceByDesktopName("kdict");
waiting = 1;
delayedFunc = fun.copy();
delayedData = data;
QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
return;
} else {
QCStringList list = client->remoteObjects("kdict");
if (list.findIndex("KDictIface")==-1) {
waiting = 1;
delayedFunc = fun.copy();
delayedData = data;
QTimer::singleShot(100, this, SLOT(sendDelayedCommand()));
return;
}
}
client->send("kdict","default",fun,data);
}
示例3: qWarning
DCOPReply DCOPRef::callInternal(const QCString &fun, const QCString &args, const QByteArray &data, EventLoopFlag useEventLoop, int timeout)
{
DCOPReply reply;
if(isNull())
{
qWarning("DCOPRef: call '%s' on null reference error", STR(fun));
return reply;
}
QCString sig = fun;
if(fun.find('(') == -1)
{
sig += args;
if(args.find("<unknown") != -1)
qWarning(
"DCOPRef: unknown type error "
"<\"%s\",\"%s\">::call(\"%s\",%s",
STR(m_app), STR(m_obj), STR(fun), args.data() + 1);
}
DCOPClient *dc = dcopClient();
if(!dc || !dc->isAttached())
{
qWarning("DCOPRef::call(): no DCOP client or client not attached error");
return reply;
}
dc->call(m_app, m_obj, sig, data, reply.type, reply.data, useEventLoop == UseEventLoop, timeout);
return reply;
}
示例4: main
int main(int argc, char **argv)
{
bool ok;
KApplication app(argc, argv, "kmobile_client", false);
// get our DCOP client and attach so that we may use it
DCOPClient *client = app.dcopClient();
client->attach();
QByteArray data;
QDataStream ds(data, IO_WriteOnly);
// ds << QString("a");
QCString replyType;
QByteArray replyData;
ok = client->call("kmobile", "kmobileIface", "deviceNames()", data, replyType, replyData);
QDataStream reply(replyData, IO_ReadOnly);
QStringList deviceNames;
reply >> deviceNames;
kdDebug() << QString("%1\n").arg(ok?"Ok":"Failure");
kdDebug() << QString("Number of currently registered drivers: %1\n").arg(deviceNames.count());
for (int i=0; i<deviceNames.count(); i++)
kdDebug() << QString("Device %1: %2\n").arg(i+1).arg(deviceNames[i]);
// return app.exec();
}
示例5: isKDesktopLockRunning
// the code was taken from pilotDaemon.cc in KPilot
// static
OSDWidget::KDesktopLockStatus OSDWidget::isKDesktopLockRunning()
{
if (!Preferences::oSDCheckDesktopLock())
return NotLocked;
DCOPClient *dcopptr = KApplication::kApplication()->dcopClient();
// Can't tell, very weird
if (!dcopptr || !dcopptr->isAttached())
{
kdWarning() << k_funcinfo << ": Could not make DCOP connection." << endl;
return DCOPError;
}
QByteArray data,returnValue;
QCString returnType;
if (!dcopptr->call("kdesktop","KScreensaverIface","isBlanked()",
data,returnType,returnValue,true))
{
// KDesktop is not running. Maybe we are in a KDE4 desktop...
kdDebug() << k_funcinfo << ": Check for screensaver failed." << endl;
return DCOPError;
}
if (returnType == "bool")
{
bool b;
QDataStream reply(returnValue,IO_ReadOnly);
reply >> b;
return (b ? Locked : NotLocked);
}
示例6: updateObjects
void AddAction::updateObjects()
{
QStringList names;
theObjects->clear();
uniqueProgramMap.clear();
nameProgramMap.clear();
DCOPClient *theClient = KApplication::kApplication()->dcopClient();
QCStringList theApps = theClient->registeredApplications();
for(QCStringList::iterator i = theApps.begin(); i != theApps.end(); ++i)
{
if(!QString(*i).find("anonymous")) continue;
if(!QString(*i).find(i18n( "anonymous" ))) continue;
QRegExp r("(.*)-[0-9]+");
QString name = r.exactMatch(QString(*i)) ? r.cap(1) : *i;
if(names.contains(name)) continue;
names += name;
KListViewItem *a = new KListViewItem(theObjects, name);
uniqueProgramMap[a] = name == QString(*i);
nameProgramMap[a] = *i;
QCStringList theObjects = theClient->remoteObjects(*i);
for(QCStringList::iterator j = theObjects.begin(); j != theObjects.end(); ++j)
if(*j != "ksycoca" && *j != "qt")// && getFunctions(*i, *j).count())
new KListViewItem(a, *j);
}
updateFunctions();
}
示例7: KPanelApplet
QuickLauncher::QuickLauncher(const TQString& configFile, Type type, int actions,
TQWidget *parent, const char *name) :
KPanelApplet(configFile, type, actions, parent, name)
{
DCOPObject::setObjId("QuickLauncherApplet");
DEBUGSTR << endl << endl << endl << "------------" << flush;
DEBUGSTR << "QuickLauncher::QuickLauncher(" << configFile << ",...)" <<
endl << flush;
m_settings = new Prefs(sharedConfig());
m_settings->readConfig();
m_needsSave = false;
m_needsRefresh = false;
m_refreshEnabled = false;
m_configDialog = 0;
m_popup = 0;
m_appletPopup = 0;
m_removeAppsMenu = 0;
m_dragAccepted = false;
m_buttons = new ButtonGroup;
m_manager = new FlowGridManager;
m_newButtons = 0;
m_oldButtons = 0;
m_dragButtons = 0;
m_configAction = new TDEAction(i18n("Configure Quicklauncher..."), "configure", TDEShortcut(),
TQT_TQOBJECT(this), TQT_SLOT(slotConfigure()), TQT_TQOBJECT(this));
m_saveTimer = new TQTimer(this, "m_saveTimer");
connect(m_saveTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(saveConfig()));
m_popularity = new PopularityStatistics();
setBackgroundOrigin(AncestorOrigin);
loadConfig();
buildPopupMenu();
m_minPanelDim = std::max(16, m_settings->iconDimChoices()[1]);
refreshContents();
setRefreshEnabled(true);
setAcceptDrops(true);
//TQToolTip::add(this, i18n("Drop applications here"));
DEBUGSTR << " QuickLauncher::QuickLauncher(" << configFile <<
",...) END" << endl << flush;
DCOPClient *dcopClient = TDEApplication::dcopClient();
dcopClient->connectDCOPSignal(0, "appLauncher",
"serviceStartedByStorageId(TQString,TQString)",
"QuickLauncherApplet",
"serviceStartedByStorageId(TQString,TQString)",
false);
kdDebug() << "Quicklauncher registered DCOP signal" << endl;
}
示例8: ping
void ping(int) {
DCOPClient *client = KApplication::dcopClient();
if (!client->registeredApplications().contains(kstName)) {
printf("%s", _T("Kst application process has terminated.\n"));
rl_cleanup_after_signal();
exit(ERR_KST_TERMINATED);
}
}
示例9: WallpaperDlg
Wallpaper::Wallpaper( QWidget *parent, const char* name )
: WallpaperDlg( parent, name )
{
changePaper = true;
selectedPaper = "";
QStringList lst = KGlobal::dirs()->findAllResources("wallpaper", "*.desktop", false /* no recursion */, true /* unique files */ );
QString line,lname,lang,langCode;
// FIXME: What about other languages?
lang = QString(getenv("LC_ALL"));
if (lang == "tr_TR.UTF-8")
langCode="Name[tr]";
else
langCode="Name";
for(QStringList::Iterator it = lst.begin(); it != lst.end(); ++it)
{
if(!(*it).endsWith(".svgz.desktop"))
{
QFile desktopFile(*it);
QTextStream stream(&desktopFile);
desktopFile.open(IO_ReadOnly);
bool foundName = false;
while(!foundName && (line = stream.readLine()))
{
if (line.startsWith(langCode))
{
lname = line.section("=",1,1);
foundName=true;
}
}
papers.insert(lname, (*it).remove(".desktop"));
desktopFile.close();
}
}
QMap<QString, QString>::ConstIterator it = papers.begin();
for(; it != papers.constEnd(); ++it)
wallpaperBox->insertItem(it.key());
connect(testButton, SIGNAL(clicked()), this , SLOT(testWallpaper()));
connect(wallpaperBox, SIGNAL(activated(int)), this, SLOT(paperSelected(int)));
connect(changeCheck, SIGNAL(toggled(bool)), this, SLOT(optionChanged(bool)));
emit paperSelected(0);
// Backup old walpaper name
DCOPClient *client = kapp->dcopClient();
QByteArray replyData;
QCString replyType;
client->call("kdesktop", "KBackgroundIface", "currentWallpaper(int)", 6, replyType, replyData);
QDataStream reply(replyData, IO_ReadOnly);
reply >> oldWallpaper;
}
示例10: file
void Style::testStyle()
{
// Read entire XML into DOM Tree
QFile file(selectedStyle);
file.open(IO_ReadOnly);
dom.setContent(file.readAll());
file.close();
// attach to dcop
DCOPClient *client = kapp->dcopClient();
if (!client->isAttached())
client->attach();
// kicker settings
KConfig *kickerConf = new KConfig("kickerrc");
kickerConf->setGroup("General");
QDomElement Kicker = dom.elementsByTagName("kicker").item(0).toElement();
kickerConf->writeEntry("LegacyKMenu", !checkKickoff->isChecked());
kickerConf->writeEntry("Transparent", getProperty(Kicker, "Transparent", "value"));
kickerConf->writeEntry("SizePercentage", getProperty(Kicker, "SizePercentage", "value"));
kickerConf->writeEntry("CustomSize", getProperty(Kicker, "CustomSize", "value"));
kickerConf->writeEntry("Position", getProperty(Kicker, "Position", "value"));
kickerConf->writeEntry("Alignment", getProperty(Kicker, "Alignment", "value"));
kickerConf->sync();
delete kickerConf;
// restart kicker
client->send("kicker", "kicker", "restart()", "");
// kwin settings
KConfig *kwinConf = new KConfig("kwinrc");
kwinConf->setGroup("Style");
QDomElement KWin = dom.elementsByTagName("kwin").item(0).toElement();
kwinConf->writeEntry("PluginLib", getProperty(KWin, "PluginLib", "value"));
kwinConf->sync();
delete kwinConf;
// restart kwin
client->send("kwin", "KWinInterface", "reconfigure()", "");
// widget settings
KConfig *globalConf = new KConfig("kdeglobals");
globalConf->setGroup("General");
QDomElement Widget = dom.elementsByTagName("widget").item(0).toElement();
globalConf->writeEntry("widgetStyle", getProperty(Widget, "widgetStyle", "value"));
globalConf->sync();
delete globalConf;
KIPC::sendMessageAll(KIPC::StyleChanged);
}
示例11: holdSlave
Slave* Slave::holdSlave( const QString &protocol, const KURL& url )
{
//kdDebug(7002) << "holdSlave '" << protocol << "' for " << url.prettyURL() << endl;
// Firstly take into account all special slaves
if (protocol == "data")
return 0;
DCOPClient *client = kapp->dcopClient();
if (!client->isAttached())
client->attach();
QString prefix = locateLocal("socket", KGlobal::instance()->instanceName());
KTempFile socketfile(prefix, QString::fromLatin1(".slave-socket"));
if ( socketfile.status() != 0 )
return 0;
#ifdef __CYGWIN__
socketfile.close();
socketfile.unlink();
#endif
#ifndef Q_WS_WIN
KServerSocket *kss = new KServerSocket(QFile::encodeName(socketfile.name()));
Slave *slave = new Slave(kss, protocol, socketfile.name());
#else
Slave *slave = 0;
#endif
QByteArray params, reply;
QCString replyType;
QDataStream stream(params, IO_WriteOnly);
stream << url << socketfile.name();
QCString launcher = KApplication::launcher();
if (!client->call(launcher, launcher, "requestHoldSlave(KURL,QString)",
params, replyType, reply)) {
delete slave;
return 0;
}
QDataStream stream2(reply, IO_ReadOnly);
pid_t pid;
stream2 >> pid;
if (!pid)
{
delete slave;
return 0;
}
#ifndef Q_WS_WIN
slave->setPID(pid);
QTimer::singleShot(1000*SLAVE_CONNECTION_TIMEOUT_MIN, slave, SLOT(timeout()));
#endif
return slave;
}
示例12: wake_laptop_daemon
KDE_EXPORT void
wake_laptop_daemon()
{
DCOPClient *dclient = kapp->dcopClient();
if (!dclient || (!dclient->isAttached() && !dclient->attach()))
return;
TQByteArray data;
TQDataStream arg( data, IO_WriteOnly );
(void) dclient->send( "kded", "klaptopdaemon", "restart()", data );
}
示例13: updateDCOPObjects
void EditAction::updateDCOPObjects()
{
theDCOPObjects->clear();
DCOPClient *theClient = TDEApplication::kApplication()->dcopClient();
if(theDCOPApplications->currentText().isNull() || theDCOPApplications->currentText().isEmpty()) return;
QCStringList theObjects = theClient->remoteObjects(nameProgramMap[theDCOPApplications->currentText()].utf8());
if(!theObjects.size() && theDCOPApplications->currentText() == (*theAction).program()) theDCOPObjects->insertItem((*theAction).object());
for(QCStringList::iterator j = theObjects.begin(); j != theObjects.end(); ++j)
if(*j != "tdesycoca" && *j != "qt" && AddAction::getFunctions(nameProgramMap[theDCOPApplications->currentText()], *j).count())
theDCOPObjects->insertItem(TQString::fromUtf8(*j));
updateDCOPFunctions();
}
示例14: f_dcop
static ParseNode f_dcop(Parser*, const ParameterList& params)
{
QCString appId = params[0].toString().latin1();
QCString object = params[1].toString().latin1();
QString function = params[2].toString().section('(', 0, 0);
QStringList items = QStringList::split(",", params[2].toString().section('(', 1, 1).section(')', 0, 0));
QByteArray byteData;
QDataStream byteDataStream(byteData, IO_WriteOnly);
if (items.count() != params.count() - 3)
{
qDebug("Wrong number of parameters");
return ParseNode();
}
int i = 3;
for (QStringList::Iterator it = items.begin(); it != items.end(); ++it)
{
*it = (*it).stripWhiteSpace();
if (*it == "int")
byteDataStream << params[i++].toInt();
else if (*it == "long")
byteDataStream << params[i++].toInt();
else if (*it == "float")
byteDataStream << params[i++].toDouble();
else if (*it == "double")
byteDataStream << params[i++].toDouble();
else if (*it == "bool")
byteDataStream << (bool)params[i++].toInt();
else if (*it == "QStringList")
if (params[i].toString().find('\n') != -1)
byteDataStream << QStringList::split("\n", params[i++].toString(), true);
else
byteDataStream << QStringList::split("\\n", params[i++].toString(), true);
else
byteDataStream << params[i++].toString();
}
function.append(QString("(%1)").arg(items.join(",")));
QCString replyType, byteReply;
DCOPClient* cl = KApplication::dcopClient();
if (!cl || !cl->call(appId, object, function.latin1(),
byteData, replyType, byteReply))
{
qDebug("DCOP failure");
return ParseNode();
}
QDataStream byteReplyStream(byteReply, IO_ReadOnly);
if (replyType == "QString")
{
QString text;
byteReplyStream >> text;
return text;
}
示例15: getFunctions
const QStringList AddAction::getFunctions(const QString app, const QString obj)
{
QStringList ret;
DCOPClient *theClient = KApplication::kApplication()->dcopClient();
QCStringList theApps = theClient->remoteFunctions(app.utf8(), obj.utf8());
for(QCStringList::iterator i = theApps.begin(); i != theApps.end(); ++i)
if( *i != "QCStringList interfaces()" &&
*i != "QCStringList functions()" &&
*i != "QCStringList objects()" &&
*i != "QCStringList find(QCString)" )
ret += QString::fromUtf8(*i);
return ret;
}