Esempio n. 1
0
void SystemMenu::onShowHideDock()
{
	//qDebug() << "SYSMENU SHOW/HIDE DOCK";
	int f = 0;
	QAction *action = qobject_cast<QAction *>(sender());
	if (app->dock->dockState == Dockbar::Normal) {
		action->setText("Turn Hiding Off");
		app->dock->setAutoHide(true);
		f = 1;
	} else if (app->dock->dockState == Dockbar::Hidden) {
		//app->dock->animateShow();
		app->dock->setAutoHide(false);
		action->setText("Turn Hiding On");
		f = 0;
	}
	
	// Notify AnticoDeluxe WM for changing dock size
	QDBusInterface *iface = new QDBusInterface("org.freedesktop.AnticoPref", 
		"/", "org.freedesktop.AnticoPref.WMCtrl",
		QDBusConnection::sessionBus(), this);
	if (!iface->isValid())
		qDebug() << "NOT VALID INTERFACE" << qPrintable(QDBusConnection::sessionBus().lastError().message());
	else 
		iface->call("callFunction", 30, f);
}
Esempio n. 2
0
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;
    }
}
Esempio n. 3
0
void sendLinkToEngine (QString link, int cat, QObject* obj, int debugChannel)
{
	QDBusConnection bus = QDBusConnection::sessionBus();
	QDBusInterface *interface = new QDBusInterface("org.amule.engine", "/Link", "org.amule.engine", bus, obj);
	interface->call("engine_add_link", link, cat);
	kDebug(debugChannel) << "Sent Link " << link << "with cat " << cat;
}
Esempio n. 4
0
KCookiesMain::KCookiesMain (QWidget* parent, const QVariantList&)
    : KCModule (KioConfigFactory::componentData(), parent)
{
    management = 0;
    bool managerOK = true;

    QDBusInterface kded ("org.kde.kded", "/kded", "org.kde.kded");
    QDBusReply<bool> reply = kded.call ("loadModule", QString ("kcookiejar"));

    if (!reply.isValid()) {
        managerOK = false;
        kDebug (7103) << "kcm_kio: KDED could not load KCookiejar!";
        KMessageBox::sorry (0, i18n ("Unable to start the cookie handler service.\n"
                                     "You will not be able to manage the cookies that "
                                     "are stored on your computer."));
    }

    QVBoxLayout* layout = new QVBoxLayout (this);
    tab = new QTabWidget (this);
    layout->addWidget (tab);

    policies = new KCookiesPolicies (componentData(), this);
    tab->addTab (policies, i18n ("&Policy"));
    connect (policies, SIGNAL (changed (bool)), SIGNAL (changed (bool)));

    if (managerOK) {
        management = new KCookiesManagement (componentData(), this);
        tab->addTab (management, i18n ("&Management"));
        connect (management, SIGNAL (changed (bool)), SIGNAL (changed (bool)));
    }
}
void UnrestrictedModel::restartSysuid()
{
        QDBusInterface *unrestricted = new QDBusInterface("com.nokia.unrestricted", "/menuwindow", "com.nokia.unrestricted",
                                                          QDBusConnection::sessionBus(), this);
        unrestricted->call("resetMenuWidget");
        delete unrestricted;
}
void
ResetApplet::userGuide ()
{
    QDBusInterface userguide ("com.nokia.userguide", "/",
                              "com.nokia.UserGuideIf");
    userguide.call ("pageByPath", "tips.cfg");
    SYS_DEBUG ("");
}
void
ThemeWidget::oviActivated ()
{
    static const char OviIf[] = "com.nokia.OviStoreClient";
    QDBusInterface OviStore (OviIf, "/", OviIf);

    OviStore.call ("LaunchWithKeyword", QString ("themes"));
}
Esempio n. 8
0
void UPower::ChangeState (State state)
{
    QDBusInterface face ("org.freedesktop.UPower",
                         "/org/freedesktop/UPower",
                         "org.freedesktop.UPower",
                         QDBusConnection::systemBus ());

    face.call (QDBus::NoBlock, State2Method (state));
}
Esempio n. 9
0
void TestContactsd::importTest()
{
    const QString host("com.nokia.contactsd");
    QDBusConnection bus = QDBusConnection::sessionBus();
    QDBusInterface *interface = new QDBusInterface("com.nokia.contactsd",
            "/","com.nokia.contacts.importprogress",bus,this);
    QDBusReply<QStringList> result = interface->call("hasActiveImports");
    QVERIFY2(result.isValid() == true, result.error().message().toLatin1());
    QCOMPARE(result.value().count(), 0);
}
Esempio n. 10
0
void Profile::showProfileDialog()
{

  QDBusInterface launcher ("com.nokia.DuiControlPanel", "/",
                                  "com.nokia.DuiControlPanelIf");
  launcher.call ("appletPage", "Profile");
  // Hide the status indicator menu
  if(MStatusIndicatorMenuInterface *menu = plugin->statusIndicatorMenuInterface()) {
        menu->hideStatusIndicatorMenu();
  }
}
Esempio n. 11
0
QVariant QUPowerInterface::getProperty(const QString &property)
{
    QVariant var;
    QDBusInterface *interface = new QDBusInterface(UPOWER_SERVICE, UPOWER_PATH,
                                             "org.freedesktop.DBus.Properties",
                                             QDBusConnection::systemBus());
    if (interface && interface->isValid()) {
        QDBusReply<QVariant> r = interface->call("Get", UPOWER_PATH, property);
        var = r.value();
    }
    return var;
}
Esempio n. 12
0
void SoundPref::onChangeDevices()
{
	// Notify AnticoDeluxe WM for changing sound devices
	QDBusInterface *iface = new QDBusInterface("org.freedesktop.AnticoDeluxe",
		"/", "org.freedesktop.AnticoDeluxe.WMCtrl",
		QDBusConnection::sessionBus(), this);
	if (!iface->isValid())
		qDebug() << "NOT VALID INTERFACE" << qPrintable(QDBusConnection::sessionBus().lastError().message());
	else {
		iface->call("changeSoundDevices", mixerCard, mixerDevice);
	}
}
Esempio n. 13
0
QVariant QUDisksDeviceInterface::getProperty(const QString &property)
{
    QVariant var;
    QDBusInterface *iface = new QDBusInterface(UDISKS_SERVICE, path,
                                               "org.freedesktop.DBus.Properties",
                                               QDBusConnection::systemBus());
    if (iface && iface->isValid()) {
        QDBusReply<QVariant> r = iface->call("Get", path, property);
        var = r.value();
    }
    return var;
}
Esempio n. 14
0
void SoundPref::onVolumeFeedback()
{
	// Notify AnticoDeluxe WM for playing volume feedback
	QDBusInterface *iface = new QDBusInterface("org.freedesktop.AnticoDeluxe",
		"/", "org.freedesktop.AnticoDeluxe.WMCtrl",
		QDBusConnection::sessionBus(), this);
	if (!iface->isValid())
		qDebug() << "NOT VALID INTERFACE" << qPrintable(QDBusConnection::sessionBus().lastError().message());
	else {
		iface->call("soundVolumeFeedback", ui.sndVolFeedbackChk->isChecked());
	}
	saveSettings();
}
Esempio n. 15
0
static QDBusInterface* searchSkypeDBusInterface()
{
  const QLatin1String service( "com.Skype.API" );
  const QLatin1String path( "/com/Skype" );

  QDBusInterface *interface = new QDBusInterface( service, path, QString(), QDBusConnection::systemBus() );
  if ( !interface->isValid() ) {
    delete interface;
    interface = new QDBusInterface( service, path, QString(), Akonadi::DBusConnectionPool::threadConnection() );
  }

  return interface;
}
Esempio n. 16
0
void SoundPref::onShowHideVolumeCtrl()
{
	// Notify AnticoDeluxe WM for show / hide volume control
	QDBusInterface *iface = new QDBusInterface("org.freedesktop.AnticoDeluxe",
		"/", "org.freedesktop.AnticoDeluxe.WMCtrl",
		QDBusConnection::sessionBus(), this);
	if (!iface->isValid())
		qDebug() << "NOT VALID INTERFACE" << qPrintable(QDBusConnection::sessionBus().lastError().message());
	else {
		iface->call("showSoundVolumeCtrl", ui.showCtrlChk->isChecked());
	}
	saveSettings();
}
static void release_QDBusInterface(void *sipCppV,int)
{
    QDBusInterface *sipCpp = reinterpret_cast<QDBusInterface *>(sipCppV);

    Py_BEGIN_ALLOW_THREADS

    if (QThread::currentThread() == sipCpp->thread())
        delete sipCpp;
    else
        sipCpp->deleteLater();

    Py_END_ALLOW_THREADS
}
Esempio n. 18
0
static QDBusInterface *searchSkypeDBusInterface()
{
    const QString service(QStringLiteral("com.Skype.API"));
    const QString path(QStringLiteral("/com/Skype"));

    QDBusInterface *interface = new QDBusInterface(service, path, QString(), QDBusConnection::sessionBus());
    if (!interface->isValid()) {
        delete interface;
        interface = new QDBusInterface(service, path, QString(), KDBusConnectionPool::threadConnection());
    }

    return interface;
}
Esempio n. 19
0
void ResourceView::editResource()
{
  bool ok = false;
  ResourceItem *item = currentItem();
  if ( !item ) {
    return;
  }
  ResourceCalendar *resource = item->resource();

  if ( item->isSubresource() ) {
    if ( resource->type() == "imap" ) {
      QString identifier = item->resourceIdentifier();
      const QString newResourceName =
        KInputDialog::getText( i18n( "Rename Calendar Folder" ),
                               i18n( "Please enter a new name for the calendar folder" ),
                               item->text(0),
                               &ok, this );
      if ( !ok ) {
        return;
      }

      QDBusConnection bus = QDBusConnection::sessionBus();
      QDBusInterface *interface =
        new QDBusInterface( "org.kde.kmail",
                            "/Groupware",
                            "org.kde.kmail.groupware",
                            bus,
                            this );

      QDBusReply<int> reply =
        interface->call( "changeResourceUIName", identifier, newResourceName );
      if ( !reply.isValid() ) {
        kDebug() << "DBUS Call changeResourceUIName() failed ";
      }
    } else {
      const QString subResourceName = resource->labelForSubresource( item->resourceIdentifier() );
      KMessageBox::sorry( this,
                          i18n ( "<qt>Cannot edit the calendar folder <b>%1</b>.</qt>",
                                 subResourceName ) );
    }
  } else {
    QPointer<KRES::ConfigDialog> dlg =
      new KRES::ConfigDialog( this, QString( "calendar" ), resource );
    if ( dlg->exec() ) {
      item->setText( 0, resource->resourceName() );
      mCalendar->resourceManager()->change( resource );
    }
    delete dlg;
  }
  emitResourcesChanged();
}
Esempio n. 20
0
QFuture<Platform::QueryChangeStateResult> UPower::CanChangeState (State state)
{
    return QtConcurrent::run ([state] () -> QueryChangeStateResult
    {
        QDBusInterface face ("org.freedesktop.UPower",
        "/org/freedesktop/UPower",
        "org.freedesktop.UPower",
        QDBusConnection::systemBus ());
        if (!face.isValid ())
            return { false, tr ("Cannot connect to UPower daemon.") };

        return { face.property ("Can" + State2Method (state)).toBool (), {} };
    });
}
Esempio n. 21
0
void DataHandler::startDaemon()
{
    QDBusInterface* interface = new QDBusInterface("org.kde.kdenow", "/KDENow");

    //Call a method, to start the kdenowd daemon if it hasn't yet started
    QDBusReply< QString > reply = interface->call("startDaemon");
    if (reply.isValid()) {
        qDebug() << "Valid Reply received from org.kde.kdenow /KDENow";
        qDebug() << reply.value();
    }
    else {
        qDebug() << "Did not receive a valid reply from org.kde.kdenow /KDENow";
        return;
    }
}
Esempio n. 22
0
ActionReply Helper::dbusaction(const QVariantMap& args)
{
  ActionReply reply;
  QDBusMessage dbusreply;
  
  // Get arguments to method call
  QString service = args["service"].toString();
  QString path = args["path"].toString();
  QString interface = args["interface"].toString();
  QString method = args["method"].toString();
  QList<QVariant> argsForCall = args["argsForCall"].toList();
  
  QDBusConnection systembus = QDBusConnection::systemBus();  
  QDBusInterface *iface = new QDBusInterface (service,
					      path,
					      interface,
					      systembus,
					      this);
  if (iface->isValid())
    dbusreply = iface->callWithArgumentList(QDBus::AutoDetect, method, argsForCall);
  delete iface;
  
  // Error handling
  if (method != "Reexecute")
  {
    if (dbusreply.type() == QDBusMessage::ErrorMessage)
    {
      reply.setErrorCode(ActionReply::DBusError);
      reply.setErrorDescription(dbusreply.errorMessage());
    }
  }

  // Reload systemd daemon to update the enabled/disabled status
  if (method == "EnableUnitFiles" || method == "DisableUnitFiles" || method == "MaskUnitFiles" || method == "UnmaskUnitFiles")
  {
    // systemd does not update properties when these methods are called so we
    // need to reload the systemd daemon.
    iface = new QDBusInterface ("org.freedesktop.systemd1",
				"/org/freedesktop/systemd1",
				"org.freedesktop.systemd1.Manager",
				systembus,
				this);
    dbusreply = iface->call(QDBus::AutoDetect, "Reload");
    delete iface;
  }
  // return a reply
  return reply;
}
void GnomeSessionClient::connectToSessionManager()
{
    QString startupId = QString::fromLocal8Bit(qgetenv("DESKTOP_AUTOSTART_ID"));

    QDBusInterface* managerIface = new QDBusInterface(
        SM_DBUS_SERVICE,
        SM_DBUS_PATH,
        SM_DBUS_INTERFACE,
        QDBusConnection::sessionBus(),
        this);

    QDBusPendingCall call = managerIface->asyncCall("RegisterClient", d->m_applicationId, startupId);
    QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(call, this);
    connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
        SLOT(slotRegisterClientFinished(QDBusPendingCallWatcher*)));
}
void addConnection(QDBusInterface& interface, const QString& connectionName) {
    qDBusRegisterMetaType<Connection>();

    // Create a new connection object
    Connection connection;

    // Build up the 'connection' Setting
    connection["connection"]["uuid"] = QUuid::createUuid().toString().remove('{').remove('}');
    connection["connection"]["id"] = connectionName;
    connection["connection"]["type"] = "802-3-ethernet";

    // Build up the '802-3-ethernet' Setting
    connection["802-3-ethernet"];

    // Build up the 'ipv4' Setting
    connection["ipv4"]["method"] = "auto";

    // Call AddConnection
    QDBusReply<QDBusObjectPath> result = interface.call("AddConnection", QVariant::fromValue(connection));
    if (!result.isValid()) {
        qDebug() << QString("Error adding connection: %1 %2").arg(result.error().name()).arg(result.error().message());
    } else {
        qDebug() << QString("Added: %1").arg(result.value().path());
    }
}
Esempio n. 25
0
void TaskWindowJob::start()
{
    const QString operation = operationName();
    if (operation == "cascade") {
        QDBusInterface  *kwinInterface = new QDBusInterface("org.kde.kwin", "/KWin", "org.kde.KWin");
        QDBusPendingCall pcall = kwinInterface->asyncCall("cascadeDesktop");
       // kDebug() << " connected to kwin interface! ";
        setResult(true);
        return;
    } else if (operation == "unclutter") {
        QDBusInterface  *kwinInterface = new QDBusInterface("org.kde.kwin", "/KWin", "org.kde.KWin");
        QDBusPendingCall pcall = kwinInterface->asyncCall("unclutterDesktop");
      //  kDebug() << "connected to kwin interface! ";
        setResult(true);
        return;
    } 
}
Esempio n. 26
0
	void DBusConnector::enumerateDevices()
	{
		QDBusInterface face ("org.freedesktop.UPower",
				"/org/freedesktop/UPower",
				"org.freedesktop.UPower",
				SB_);

		auto res = face.call ("EnumerateDevices");
		for (const auto& argument : res.arguments ())
		{
			auto arg = argument.value<QDBusArgument> ();
			QList<QDBusObjectPath> paths;
			arg >> paths;
			for (const auto& path : paths)
				requeryDevice (path.path ());
		}
	}
Esempio n. 27
0
int main(int argc, char* argv[])
{
    QApplication::setAttribute(Qt::AA_X11InitThreads, true);
    QApplication app(argc, argv);

    if(QDBusConnection::sessionBus().registerService(DBUS_NAME)){

        QmlLoader* qmlLoader = new QmlLoader();
        qmlLoader->rootContext->setContextProperty("mainObject", qmlLoader);
        qmlLoader->load(QUrl("qrc:///views/Main.qml"));
        QObject::connect(qmlLoader->engine, SIGNAL(quit()), QApplication::instance(), SLOT(quit()));

        if(argc == 2){
            QString order = argv[1];
            if(order == "show"){
                qmlLoader->show();
            }
            else if(order == "toggle"){
                qmlLoader->toggle();
            }
            else {
                qmlLoader->showModule(order);
            }
        }

        return app.exec();
    } else {
        qWarning() << "dde control center is running...";
        if(argc == 2){
            QDBusInterface *iface;
            iface = new QDBusInterface(DBUS_NAME, DBUS_PATH, DBUS_NAME, QDBusConnection::sessionBus());
            QString order = argv[1];
            if(order == "show"){
                iface->call("Show");
            }
            else if(order == "toggle"){
                iface->call("Toggle");
            }
            else {
                iface->call("ShowModule", order);
            }
        }
        return 0;
    }
}
Esempio n. 28
0
QString
BTAdaptor::adapterPath ()
{
    // Get the Bluez manager dbus interface
    QDBusInterface mgrIface ("org.bluez", "/", "org.bluez.Manager", QDBusConnection::systemBus ());
    if (!mgrIface.isValid ())
    {
        qWarning() << "Unable to get bluez manager iface";
        return "";
    }

    // Fetch the default bluetooth adapter
    QDBusReply<QDBusObjectPath> reply = mgrIface.call (QLatin1String ("DefaultAdapter"));
    
    QString adapterPath = reply.value ().path ();
    qDebug() << "Bluetooth adapter path:" << adapterPath;
    
    return adapterPath;
}
Esempio n. 29
0
bool QBluetoothPasskeyAgent_Private::unregisterAgent(const QString &localAdapter,
        const QString &addr)
{
    QString bluezAdapter = "/org/bluez";

    if (!localAdapter.isNull()) {
        bluezAdapter.append("/");
        bluezAdapter.append(localAdapter);
    }

    QDBusInterface *iface = new QDBusInterface("org.bluez",
                                               bluezAdapter,
                                               "org.bluez.Security",
                                               QDBusConnection::systemBus());

    if (!iface->isValid())
        return false;

    QString bluezMethod;
    QVariantList args;

    QString path = m_name;
    path.prepend('/');
    args << path;

    if (addr.isNull()) {
        bluezMethod = "UnregisterDefaultPasskeyAgent";
    }
    else {
        bluezMethod = "UnregisterPasskeyAgent";
        args << addr;
    }

    QDBusReply<void> reply = iface->callWithArgumentList(QDBus::Block,
            bluezMethod, args);

    if (!reply.isValid()) {
        handleError(reply.error());
        return false;
    }

    return true;
}
Esempio n. 30
0
// Perform initialization, create the unique KSystemTimeZones instance,
// whose only function is to receive D-Bus signals from KTimeZoned,
// and create the unique KSystemTimeZonesPrivate instance.
KSystemTimeZonesPrivate *KSystemTimeZonesPrivate::instance()
{
    if (!m_instance)
    {
        m_instance = new KSystemTimeZonesPrivate;

        // A KSystemTimeZones instance is required only to catch D-Bus signals.
        m_parent = new KSystemTimeZones;
        // Ensure that the KDED time zones module has initialized. The call loads the module on demand.
        if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String("org.kde.kded")))
            KToolInvocation::klauncher();   // this calls startKdeinit, and blocks until it returns
        const QString dbusIface = QString::fromLatin1(KTIMEZONED_DBUS_IFACE);
        QDBusInterface *ktimezoned = new QDBusInterface(QLatin1String("org.kde.kded"), QLatin1String("/modules/ktimezoned"), dbusIface);
        QDBusReply<void> reply = ktimezoned->call(QLatin1String("initialize"), false);
        m_ktimezonedError = !reply.isValid();
        if (m_ktimezonedError)
            kError(161) << "KSystemTimeZones: ktimezoned initialize() D-Bus call failed: " << reply.error().message() << endl;
kDebug(161)<<"instance(): ... initialised";
        delete ktimezoned;

        // Read the time zone config written by ktimezoned
        readConfig(true);

        // Go read the database.
#ifdef Q_OS_WIN
        // On Windows, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones
        // is the place to look. The TZI binary value is the TIME_ZONE_INFORMATION structure.
        m_instance->updateTimezoneInformation(false);
#else
        // For Unix, read zone.tab.
        if (!m_zonetab.isEmpty())
            m_instance->readZoneTab(false);
#endif
        setLocalZone();
        if (!m_localZone.isValid())
            m_localZone = KTimeZone::utc();   // ensure a time zone is always returned

        qAddPostRoutine(KSystemTimeZonesPrivate::cleanup);
    }
    return m_instance;
}