void runKbuildsycoca() { if (KSycoca::isAvailable()) { QDBusInterface dbus("org.kde.kded", "/kbuildsycoca", "org.kde.kbuildsycoca"); dbus.call(QDBus::NoBlock, "recreate"); } }
// --------------------------------------------------------------------------------- bool detail::service_to_register_with_dbus::at_system_bus() { QDBusConnection con = dbus().system_bus(); if ( !con.isConnected() ) { qWarning() << "not connected to system bus"; return false; } if ( _M_op == REGISTER ) { bool result = con.registerService ( _M_service ); if ( result == false ) { qDebug() << "something went wrong when trying to register the DBUS service: " << _M_service; qDebug() << con.lastError(); return false; } return true; } else { if ( con.interface()->isServiceRegistered ( _M_service ) ) { return con.unregisterService ( _M_service ); } } return true; }
void CJobRunner::checkInterface() { if(itsIt==itsUrls.constBegin() && !FontInst::isStarted(dbus())) { setPage(PAGE_ERROR, i18n("Unable to start backend.")); itsActionLabel->stopAnimation(); itsIt=itsEnd; } }
bool X11ScreenModeChecker::isScreensaverActive() { // org.freedesktop.ScreenSaver { QDBusInterface dbus( "org.freedesktop.ScreenSaver", "/ScreenSaver", "org.freedesktop.ScreenSaver", QDBusConnection::sessionBus()); if (dbus.isValid()) { QDBusReply<bool> reply = dbus.call("GetActive"); if (reply.isValid() && reply.value()) return true; } } // org.kde.screensaver { QDBusInterface dbus( "org.kde.screensaver", "/ScreenSaver", "org.freedesktop.ScreenSaver", QDBusConnection::sessionBus()); if (dbus.isValid()) { QDBusReply<bool> reply = dbus.call("GetActive"); if (reply.isValid() && reply.value()) return true; } } // org.gnome.ScreenSaver { QDBusInterface dbus("org.gnome.ScreenSaver", "/", "org.gnome.ScreenSaver", QDBusConnection::sessionBus()); if (dbus.isValid()) { QDBusReply<bool> reply = dbus.call("GetActive"); if (reply.isValid() && reply.value()) return true; } } return false; }
void DesktopNotificationsFactory::nativeNotificationPreview() { #if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS) QDBusInterface dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()); QVariantList args; args.append(QLatin1String("qupzilla")); args.append(m_uint); args.append(QString()); args.append(QObject::tr("Native System Notification")); args.append(QString()); args.append(QStringList()); args.append(QVariantMap()); args.append(m_timeout); dbus.callWithCallback("Notify", args, this, SLOT(updateLastId(QDBusMessage)), SLOT(error(QDBusError))); #endif }
// --------------------------------------------------------------------------------- bool detail::service_to_register_with_dbus::at_session_bus() { QDBusConnection con = dbus().session_bus(); if ( !con.isConnected() ) { qWarning() << "not connected to session bus"; return false; } if ( _M_op == REGISTER ) { return con.registerService ( _M_service ); } if ( con.interface()->isServiceRegistered ( _M_service ) ) { return con.unregisterService ( _M_service ); } return true; }
void DesktopNotificationsFactory::showNotifications(const QPixmap &icon, const QString &heading, const QString &text) { if (!m_enabled) { return; } switch (m_notifType) { case PopupWidget: if (!m_desktopNotif) { m_desktopNotif = new DesktopNotification(); } m_desktopNotif.data()->setPixmap(icon); m_desktopNotif.data()->setHeading(heading); m_desktopNotif.data()->setText(text); m_desktopNotif.data()->setTimeout(m_timeout); m_desktopNotif.data()->move(m_position); m_desktopNotif.data()->show(); break; case DesktopNative: #ifdef Q_WS_X11 QFile tmp(QDir::tempPath() + "/qupzilla_notif.png"); tmp.open(QFile::WriteOnly); icon.save(tmp.fileName()); QDBusInterface dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()); QVariantList args; args.append("qupzilla"); args.append(m_uint); args.append(tmp.fileName()); args.append(heading); args.append(text); args.append(QStringList()); args.append(QVariantMap()); args.append(m_timeout); QDBusMessage message = dbus.callWithArgumentList(QDBus::Block, "Notify", args); QVariantList list = message.arguments(); if (list.count() > 0) { m_uint = list.at(0).toInt(); } #endif break; } }
int main(int argc, char *argv[]) { std::cout << "Starting twmnd version " << VERSION << std::endl; qInstallMessageHandler(logOutput); QApplication a(argc, argv); QApplication::setQuitOnLastWindowClosed(true); QApplication::setApplicationName("twmn"); QPalette p = a.palette(); p.setBrush(QPalette::Link, QBrush(QColor("black"))); a.setPalette(p); QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); const char* wname = "twmn"; if (argc > 1) { wname = argv[1]; } DBusInterface dbus(&a); Widget w(wname); w.connectToDBus(dbus); return a.exec(); }
void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QString &heading, const QString &text) { if (!m_enabled) { return; } switch (m_notifType) { case PopupWidget: if (!m_desktopNotif) { m_desktopNotif = new DesktopNotification(); } m_desktopNotif.data()->setPixmap(icon); m_desktopNotif.data()->setHeading(heading); m_desktopNotif.data()->setText(text); m_desktopNotif.data()->setTimeout(m_timeout); m_desktopNotif.data()->move(m_position); m_desktopNotif.data()->show(); break; case DesktopNative: #if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS) QFile tmp(DataPaths::path(DataPaths::Temp) + QLatin1String("/qupzilla_notif.png")); tmp.open(QFile::WriteOnly); icon.save(tmp.fileName()); QDBusInterface dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()); QVariantList args; args.append(QLatin1String("qupzilla")); args.append(m_uint); args.append(tmp.fileName()); args.append(heading); args.append(text); args.append(QStringList()); args.append(QVariantMap()); args.append(m_timeout); dbus.callWithCallback("Notify", args, this, SLOT(updateLastId(QDBusMessage)), SLOT(error(QDBusError))); #endif break; } }
void DesktopNotificationsFactory::nativeNotificationPreview() { #ifdef Q_WS_X11 QFile tmp(QDir::tempPath() + "/qupzilla_notif.png"); tmp.open(QFile::WriteOnly); QPixmap(":icons/preferences/stock_dialog-question.png").save(tmp.fileName()); QDBusInterface dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()); QVariantList args; args.append("qupzilla"); args.append(m_uint); args.append(tmp.fileName()); args.append(QObject::tr("Native System Notification")); args.append(""); args.append(QStringList()); args.append(QVariantMap()); args.append(m_timeout); QDBusMessage message = dbus.callWithArgumentList(QDBus::Block, "Notify", args); QVariantList list = message.arguments(); if (list.count() > 0) { m_uint = list.at(0).toInt(); } #endif }
void runKbuildsycoca() { QDBusInterface dbus("org.kde.kded", "/kbuildsycoca", "org.kde.kbuildsycoca"); dbus.call(QDBus::NoBlock, "recreate"); }
int main(int argc, char *argv[]) { readEnvFile(); QApplication application(argc, argv); QTranslator qtTranslator; qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); application.installTranslator(&qtTranslator); QTranslator translator; translator.load(QString("%1/boomaga_%2.qm").arg(TRANSLATIONS_DIR, QLocale::system().name())); application.installTranslator(&translator); QStringList files; QStringList titles; bool autoRemove = false; QStringList args = application.arguments(); for (int i=1; i < args.count(); ++i) { QString arg = args.at(i); //************************************************* if (arg == "-h" || arg == "--help") { printHelp(); return 0; } //************************************************* if (arg == "-V" || arg == "--version") { printVersion(); return 0; } //************************************************* if (arg == "-t" || arg == "--title") { if (i+1 < args.count()) { titles << args.at(i+1); i++; continue; } else { return printError("'title' is missing."); } } //************************************************* if (arg == "--autoremove") { autoRemove = true; continue; } //************************************************* files << args.at(i); } BoomagaDbus dbus("org.boomaga", "/boomaga"); MainWindow mainWindow; mainWindow.show(); application.processEvents(); project->load(files, titles, "", autoRemove); return application.exec(); }
void CJobRunner::doNext() { if(itsIt==itsEnd/* || CMD_UPDATE==itsCmd*/) { if(itsModified) { // Force reconfig if command was already set to update... dbus()->reconfigure(getpid(), CMD_UPDATE==itsCmd); itsCmd=CMD_UPDATE; itsStatusLabel->setText(i18n("Updating font configuration. Please wait...")); itsProgress->setValue(itsProgress->maximum()); emit configuring(); } else { itsActionLabel->stopAnimation(); if(PAGE_ERROR!=itsStack->currentIndex()) reject(); } } else { Misc::TFont font; bool system; switch(itsCmd) { case CMD_INSTALL: { itsCurrentFile=fileName((*itsIt).url()); if(itsCurrentFile.isEmpty()) // Failed to download... dbusStatus(getpid(), constDownloadFailed); else { // Create AFM if this is a PFM, and the previous was not the AFM for this font... bool createAfm=Item::TYPE1_PFM==(*itsIt).type && (itsPrev==itsEnd || (*itsIt).fileName!=(*itsPrev).fileName || Item::TYPE1_AFM!=(*itsPrev).type); dbus()->install(itsCurrentFile, createAfm, itsDestIsSystem, getpid(), false); } break; } case CMD_DELETE: decode(*itsIt, font, system); dbus()->uninstall(font.family, font.styleInfo, system, getpid(), false); break; case CMD_ENABLE: decode(*itsIt, font, system); dbus()->enable(font.family, font.styleInfo, system, getpid(), false); break; case CMD_DISABLE: decode(*itsIt, font, system); dbus()->disable(font.family, font.styleInfo, system, getpid(), false); break; case CMD_MOVE: decode(*itsIt, font, system); // To 'Move' a disabled font, we first need to enable it. To accomplish this, JobRunner creates a 'fake' entry // with the filename "--" if((*itsIt).fileName==QLatin1String("--")) { setCaption(i18n("Enabling")); dbus()->enable(font.family, font.styleInfo, system, getpid(), false); } else { if(itsPrev!=itsEnd && (*itsPrev).fileName==QLatin1String("--")) setCaption(i18n("Moving")); dbus()->move(font.family, font.styleInfo, itsDestIsSystem, getpid(), false); } break; case CMD_REMOVE_FILE: decode(*itsIt, font, system); dbus()->removeFile(font.family, font.styleInfo, (*itsIt).fileName, system, getpid(), false); break; default: break; } itsStatusLabel->setText(CMD_INSTALL==itsCmd ? (*itsIt).prettyUrl() : FC::createName(FC::decode(*itsIt))); itsProgress->setValue(itsProgress->value()+1); // Keep copy of this iterator - so that can check whether AFM should be created. itsPrev=itsIt; } }
void ExtensionManager::initialize() { // kDebug(1210) << "ExtensionManager::loadContainerConfig()"; KSharedConfig::Ptr config = KGlobal::config(); PluginManager* pm = PluginManager::self(); // set up the "main" panel if (config->hasGroup("Main Panel")) { KConfigGroup cg(config,"Main Panel"); if (cg.hasKey("DesktopFile")) { m_mainPanel = pm->createExtensionContainer(cg.readPathEntry("DesktopFile", false), true, cg.readPathEntry("ConfigFile", false), "Main Panel"); } } if (!m_mainPanel) { // fall back to a regular ol' PanelExtension m_mainPanel = pm->createExtensionContainer( "childpanelextension.desktop", true, QString(KGlobal::mainComponent().aboutData()->appName()) + "rc", "Main Panel"); } if (!m_mainPanel) { KMessageBox::error(0, i18n("The KDE panel (kicker) could not load the main panel " "due to a problem with your installation. "), i18n("Fatal Error")); exit(1); } configureMenubar(true); m_mainPanel->readConfig(); m_mainPanel->show(); kapp->processEvents(); // read extension list KConfigGroup cg2(config, "General"); QStringList elist = cg2.readEntry("Extensions2", QStringList() ); // now restore the extensions foreach (QString extensionId, elist) { // create a matching applet container if (extensionId.indexOf("Extension") == -1) { continue; } // is there a config group for this extension? if (!config->hasGroup(extensionId)) { continue; } // set config group KConfigGroup cg3(config, extensionId); ExtensionContainer* e = pm->createExtensionContainer(cg3.readPathEntry("DesktopFile", false), true, // is startup cg3.readPathEntry("ConfigFile", false), extensionId); if (e) { addContainer(e); e->readConfig(); e->show(); kapp->processEvents(); } } pm->clearUntrustedLists(); connect(Kicker::self(), SIGNAL(configurationChanged()), SLOT(configurationChanged())); QDBusInterface dbus("org.kde.ksmserver", "/ksmserver"); dbus.call("resumeStartup", "kicker"); }
// --------------------------------------------------------------------------------- void detail::object_to_unregister_from_dbus::from_system_bus() { from ( dbus().system_bus() ); }
// --------------------------------------------------------------------------------- void detail::object_to_unregister_from_dbus::from_session_bus() { from ( dbus().session_bus() ); }