本文整理汇总了C++中QDBusConnectionInterface类的典型用法代码示例。如果您正苦于以下问题:C++ QDBusConnectionInterface类的具体用法?C++ QDBusConnectionInterface怎么用?C++ QDBusConnectionInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDBusConnectionInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fillinRunningKateAppInstances
bool fillinRunningKateAppInstances(KateRunningInstanceMap *map)
{
QDBusConnectionInterface *i = QDBusConnection::sessionBus().interface ();
// look up all running kate instances and there sessions
QDBusReply<QStringList> servicesReply = i->registeredServiceNames ();
QStringList services;
if (servicesReply.isValid())
services = servicesReply.value ();
QString serviceName;
QString my_pid(QString("%1").arg(getpid()).toLatin1());
foreach (const QString &s, services)
{
if (s.startsWith ("org.kde.kate-"))
{
if (s.contains(my_pid)) continue;
KateRunningInstanceInfo* rii=new KateRunningInstanceInfo(s);
if (rii->valid)
{
if (map->contains(rii->sessionName)) return false; //ERROR no two instances may have the same session name
map->insert(rii->sessionName,rii);
//std::cerr<<qPrintable(s)<<"running instance:"<< rii->sessionName.toUtf8().data()<<std::endl;
} else delete rii;
}
}
return true;
}
示例2: defined
/*!
Destroy this QCop service handling object.
*/
QtopiaAbstractService::~QtopiaAbstractService()
{
#if defined(QTOPIA_DBUS_IPC)
QDBusConnection dbc = QDBus::sessionBus();
if (!dbc.isConnected()) {
qWarning() << "Unable to connect to D-BUS:" << dbc.lastError();
return;
}
qLog(Services) << "Unregistering service" << m_data->m_service;
QString path = dbusPathBase;
path.append(m_data->m_service);
dbc.unregisterObject(path);
QDBusConnectionInterface *iface = dbc.interface();
QString service = dbusInterface;
service.append(".");
service.append(m_data->m_service);
iface->unregisterService(service);
#endif
if (m_data)
delete m_data;
}
示例3: sem
bool PollThread::checkDigikamInstancesRunning()
{
QSystemSemaphore sem("DigikamDBSrvAccess", 1, QSystemSemaphore::Open);
sem.acquire();
QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
QDBusReply<QStringList> reply = interface->registeredServiceNames();
if (reply.isValid())
{
QStringList serviceNames = reply.value();
QLatin1String digikamStartupService("org.kde.digikam.startup-");
QLatin1String digikamService("org.kde.digikam-");
QLatin1String digikamKioService("org.kde.digikam.KIO-");
foreach (const QString& service, serviceNames)
{
if (service.startsWith(digikamStartupService) ||
service.startsWith(digikamService) ||
service.startsWith(digikamKioService))
{
kDebug() << "At least service ["<< service <<"] is using the database server";
// At least one digikam/kio service was found
sem.release(1);
return true;
}
}
}
示例4: quitApplicationsOverDBus
void quitApplicationsOverDBus()
{
QDBusConnection connection = QDBusConnection::sessionBus();
QDBusConnectionInterface *bus = connection.interface();
const QStringList services = bus->registeredServiceNames();
foreach (const QString &service, services) {
if (service.startsWith(QLatin1String("org.freedesktop.DBus")) || service.startsWith(QLatin1Char(':'))) {
continue;
}
QDBusInterface *iface = new QDBusInterface(service,
QLatin1String("/MainApplication"),
QLatin1String("org.kde.KApplication"),
connection);
if (!iface->isValid()) {
if (verbose) {
fprintf(stderr, "invalid interface of service %s\n", service.toLatin1().data());
}
continue;
}
iface->call("quit");
if (iface->lastError().isValid()) {
if (verbose) {
fprintf(stderr, "killing %s with result\n", iface->lastError().message().toLatin1().data());
}
}
delete iface;
}
}
示例5: processSession
void processSession(QString arg)
{
QDBusConnection conn = QDBusConnection::sessionBus();
QDBusConnectionInterface* bus = conn.interface();
if(bus->isServiceRegistered("info.dolezel.fatrat"))
{
qDebug() << "FatRat is already running";
if(!arg.isEmpty())
{
qDebug() << "Passing arguments to an existing instance.";
QDBusInterface iface("info.dolezel.fatrat", "/", "info.dolezel.fatrat", conn);
iface.call("addTransfers", arg);
}
else
{
QMessageBox::critical(0, "FatRat", QObject::tr("There is already a running instance.\n"
"If you want to start FatRat anyway, pass --force among arguments."));
}
exit(0);
}
}
示例6: QObject
PowerManager::PowerManager(QObject *parent) : QObject(parent) {
QDBusConnectionInterface *interface = QDBusConnection::systemBus().interface();
// check if login1 interface exists
if (interface->isServiceRegistered(LOGIN1_SERVICE))
m_backends << new Login1Backend();
// check if upower interface exists
if (interface->isServiceRegistered(UPOWER_SERVICE))
m_backends << new UPowerBackend();
}
示例7: listAllNamedAppsInDBus
void listAllNamedAppsInDBus()
{
QDBusConnection connection = QDBusConnection::sessionBus();
QDBusConnectionInterface *bus = connection.interface();
const QStringList services = bus->registeredServiceNames();
foreach (const QString &service, services) {
if (service.startsWith(QLatin1String("org.freedesktop.DBus")) || service.startsWith(QLatin1Char(':'))) {
continue;
}
fprintf(stderr, "%s \n", service.toLatin1().data());
}
}
示例8: defined
QTM_BEGIN_NAMESPACE
#if defined(BACKEND_NM)
static bool NetworkManagerAvailable()
{
QDBusConnection dbusConnection = QDBusConnection::systemBus();
if (dbusConnection.isConnected()) {
QDBusConnectionInterface *dbiface = dbusConnection.interface();
QDBusReply<bool> reply = dbiface->isServiceRegistered("org.freedesktop.NetworkManager");
if (reply.isValid())
return reply.value();
}
return false;
}
示例9: endImport
void KMailCVT::endImport()
{
QDBusConnectionInterface * sessionBus = 0;
sessionBus = QDBusConnection::sessionBus().interface();
if ( sessionBus && !sessionBus->isServiceRegistered( "org.kde.kmail" ) )
KToolInvocation::startServiceByDesktopName( "kmail", QString() ); // Will wait until kmail is started
org::kde::kmail::kmail kmail("org.kde.kmail", "/KMail", QDBusConnection::sessionBus());
QDBusReply<int> reply = kmail.dbusAddMessage(QString(), QString(),QString());
if ( !reply.isValid() ) return;
QDBusReply<void> reply2 = kmail.dbusResetAddMessage();
if ( !reply2.isValid() ) return;
}
示例10: isSflPhoneServiceRegistered
static bool isSflPhoneServiceRegistered()
{
const QString service(QStringLiteral("org.sflphone.SFLphone"));
QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface();
if (interface->isServiceRegistered(service)) {
return true;
}
interface = KDBusConnectionPool::threadConnection().interface();
if (interface->isServiceRegistered(service)) {
return true;
}
return false;
}
示例11: isSkypeServiceRegistered
static bool isSkypeServiceRegistered()
{
const QLatin1String service( "com.Skype.API" );
QDBusConnectionInterface *interface = QDBusConnection::systemBus().interface();
if ( interface->isServiceRegistered( service ) ) {
return true;
}
interface = Akonadi::DBusConnectionPool::threadConnection().interface();
if ( interface->isServiceRegistered( service ) ) {
return true;
}
return false;
}
示例12: isSkypeServiceRegistered
static bool isSkypeServiceRegistered()
{
const QString service(QStringLiteral("com.Skype.API"));
QDBusConnectionInterface *interface = QDBusConnection::sessionBus().interface();
if (interface->isServiceRegistered(service)) {
return true;
}
interface = KDBusConnectionPool::threadConnection().interface();
if (interface->isServiceRegistered(service)) {
return true;
}
return false;
}
示例13: showTaskManager
void KDEDKSysGuard::showTaskManager()
{
QDBusConnection con = QDBusConnection::sessionBus();
QDBusConnectionInterface* interface = con.interface();
if (interface->isServiceRegistered(QStringLiteral("org.kde.systemmonitor"))) {
QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.kde.systemmonitor"),
QStringLiteral("/"),
QStringLiteral("org.qtproject.Qt.QWidget"),
QStringLiteral("close"));
con.asyncCall(msg);
}
else {
QString exe = QStandardPaths::findExecutable(QStringLiteral("systemmonitor"));
QProcess::startDetached(exe);
}
}
示例14: QObject
AbstractDBusServiceMonitor::AbstractDBusServiceMonitor(QString service, QString path,
QString interface, QObject *parent)
: QObject(parent)
, m_service(service)
, m_path(path)
, m_interface(interface)
, m_watcher(new QDBusServiceWatcher(service, QDBusConnection::sessionBus()))
, m_dbusInterface(0)
{
connect(m_watcher, SIGNAL(serviceRegistered(QString)), SLOT(createInterface()));
connect(m_watcher, SIGNAL(serviceUnregistered(QString)), SLOT(destroyInterface()));
// Connect to the service if it's up already
QDBusConnectionInterface* sessionBus = QDBusConnection::sessionBus().interface();
QDBusReply<bool> reply = sessionBus->isServiceRegistered(m_service);
if (reply.isValid() && reply.value()) {
createInterface();
}
}
示例15: dashInterface
void
LauncherView::toggleDash()
{
QDBusInterface dashInterface(DASH_DBUS_SERVICE, DASH_DBUS_PATH, DASH_DBUS_INTERFACE);
QVariant dashActiveResult = dashInterface.property(DASH_DBUS_PROPERTY_ACTIVE);
if (!dashActiveResult.isValid()) {
UQ_WARNING << "Can't read the DBUS Dash property" << DASH_DBUS_PROPERTY_ACTIVE
<< "on" << DASH_DBUS_SERVICE << DASH_DBUS_PATH << DASH_DBUS_INTERFACE;
return;
}
bool dashActive = dashActiveResult.toBool();
if (dashActive) {
if (!dashInterface.setProperty(DASH_DBUS_PROPERTY_ACTIVE, false)) {
UQ_WARNING << "Can't set the DBUS Dash property" << DASH_DBUS_PROPERTY_ACTIVE
<< "on" << DASH_DBUS_SERVICE << DASH_DBUS_PATH << DASH_DBUS_INTERFACE;
}
} else {
/* Check if the spread is active before activating the dash.
We need to do this since the spread can't prevent the launcher from
monitoring the super key and therefore getting to this point if
it's tapped. */
/* Check if the spread is present on DBUS first, as we don't want to have DBUS
activate it if it's not running yet */
QDBusConnectionInterface* sessionBusIFace = QDBusConnection::sessionBus().interface();
QDBusReply<bool> reply = sessionBusIFace->isServiceRegistered(SPREAD_DBUS_SERVICE);
if (reply.isValid() && reply.value() == true) {
QDBusInterface spreadInterface(SPREAD_DBUS_SERVICE, SPREAD_DBUS_PATH,
SPREAD_DBUS_INTERFACE);
QDBusReply<bool> spreadActiveResult = spreadInterface.call(SPREAD_DBUS_METHOD_IS_SHOWN);
if (spreadActiveResult.isValid() && spreadActiveResult.value() == true) {
return;
}
}
dashInterface.asyncCall(DASH_DBUS_METHOD_ACTIVATE_HOME);
}
}