QString SessionDispatcher::get_current_titlebar_right_qt() { QDBusReply<QString> reply = sessioniface->call("get_current_titlebar_right"); return reply.value(); }
uint QModemManagerGsmNetworkInterface::signalQuality() { QDBusReply<uint > reply = d->connectionInterface->call(QLatin1String("GetSignalQuality")); return reply.value(); }
uint QModemManagerGsmNetworkInterface::networkMode() { QDBusReply<uint > reply = d->connectionInterface->call(QLatin1String("GetNetworkMode")); return reply.value(); }
QNmSettingsMap QNetworkManagerSettingsConnection::getSettings() { QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call(QLatin1String("GetSettings")); d->settingsMap = rep.value(); return d->settingsMap; }
void QWifiManagerPrivateUnix::startScan() { if (wirelessDevice != NULL) { updateAccessPoints(); return; } QDBusInterface networkManager(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, QDBusConnection::systemBus()); if (!networkManager.isValid()) { emit scanFinished(QWifiManager::ERROR_NO_NM); return; } QDBusReply<QList<QDBusObjectPath> > devices = networkManager.call( "GetDevices"); if (!devices.isValid()) { emit scanFinished(QWifiManager::ERROR); return; } bool foundWifi = false; foreach (const QDBusObjectPath& connection, devices.value()) { //qDebug() << connection.path(); QDBusInterface device(NM_DBUS_SERVICE, connection.path(), NM_DBUS_INTERFACE_DEVICE, QDBusConnection::systemBus()); if (!device.isValid()) { emit scanFinished(QWifiManager::ERROR); return; } QVariant deviceType = device.property("DeviceType"); if (!deviceType.isValid()) { emit scanFinished(QWifiManager::ERROR); return; } //qDebug() << deviceType.toUInt(); if (deviceType.toUInt() == NM_DEVICE_TYPE_WIFI) { foundWifi = true; QVariant deviceState = device.property("State"); if (!deviceState.isValid()) { emit scanFinished(QWifiManager::ERROR); return; } if (deviceState.toUInt() <= NM_DEVICE_STATE_UNAVAILABLE) continue; // we are only interested in enabled wifi devices wirelessDevice = new QDBusInterface(NM_DBUS_SERVICE, connection.path(), NM_DBUS_INTERFACE_DEVICE_WIRELESS, QDBusConnection::systemBus()); if (!wirelessDevice->isValid()) { emit scanFinished(QWifiManager::ERROR); return; } QDBusConnection::systemBus().connect(NM_DBUS_SERVICE, connection.path(), NM_DBUS_INTERFACE_DEVICE_WIRELESS, "AccessPointAdded", this, SLOT(updateAccessPoints())); QDBusConnection::systemBus().connect(NM_DBUS_SERVICE, connection.path(), NM_DBUS_INTERFACE_DEVICE_WIRELESS, "AccessPointRemoved", this, SLOT(updateAccessPoints())); QDBusConnection::systemBus().connect(NM_DBUS_SERVICE, connection.path(), NM_DBUS_INTERFACE_DEVICE_WIRELESS, "PropertiesChanged", this, SLOT(updateAccessPoints())); QDBusReply<QList<QDBusObjectPath> > accessPoints = wirelessDevice->call("GetAccessPoints"); if (!accessPoints.isValid()) { emit scanFinished(QWifiManager::ERROR); return; } clearPreviousScanResults(); foreach (const QDBusObjectPath& connection, accessPoints.value()) { //qDebug() << connection.path(); QDBusInterface accessPoint(NM_DBUS_SERVICE, connection.path(), NM_DBUS_INTERFACE_ACCESS_POINT, QDBusConnection::systemBus()); QVariant mac = accessPoint.property("HwAddress"); QVariant ssid = accessPoint.property("Ssid"); QVariant frequency = accessPoint.property("Frequency"); QVariant strengh = accessPoint.property("Strength"); QVariant capabilitiesWPA = accessPoint.property("WpaFlags"); QVariant capabilitiesRSN = accessPoint.property("RsnFlags"); QVariant flags = accessPoint.property("Flags"); if (!ssid.isValid() || !mac.isValid() || !frequency.isValid() || !strengh.isValid() || !capabilitiesRSN.isValid() || !capabilitiesWPA.isValid() || !flags.isValid() ) { emit scanFinished(QWifiManager::ERROR); return; } unsigned int capabilities = capabilitiesWPA.toUInt() | capabilitiesRSN.toUInt() | flags.toUInt(); QString enc; if (capabilities & (NM_802_11_AP_SEC_PAIR_TKIP | NM_802_11_AP_SEC_PAIR_CCMP | NM_802_11_AP_SEC_GROUP_TKIP | NM_802_11_AP_SEC_GROUP_CCMP | NM_802_11_AP_SEC_KEY_MGMT_PSK | NM_802_11_AP_SEC_KEY_MGMT_802_1X)) enc = QWifiManager::PSK; else if (capabilities & (NM_802_11_AP_SEC_PAIR_WEP40 | NM_802_11_AP_SEC_PAIR_WEP104 | NM_802_11_AP_SEC_GROUP_WEP40 | NM_802_11_AP_SEC_GROUP_WEP104)) enc = QWifiManager::WEP; else enc = QWifiManager::OPEN; //qDebug() << ssid.toString() << " " << mac.toString() << " " // << frequency.toString() << "Mhz Strength:" // << strengh.toUInt(); scanResults.append( new QScanResult(ssid.toString(), mac.toString(), enc, frequency.toInt(), strengh.toInt())); } emit scanFinished(QWifiManager::SCAN_OK); return; } }
void ContactsKopete::updateContactData(const QString & contact) { if (d->noOnlineContacts) { load(true); return; } // Retrieving contact name QDBusReply < QString > contactName = d->interface->getDisplayName(contact); if (!contactName.isValid()) { return; } QDBusReply < QVariantMap > contactProperties = d->interface->contactProperties(contact); if (!contactProperties.isValid() || contactProperties.value().size() == 0) { return; } QDBusReply < bool > contactOnline = d->interface->isContactOnline(contact); if (!contactOnline.isValid()) { return; } QString avatarPath = contactProperties.value().value("picture").toString(); avatarPath = KUrl(avatarPath).toLocalFile(); if (avatarPath.isEmpty()) { avatarPath = "user-online"; } kDebug() << "avatarPath" << avatarPath; QString status = contactProperties.value().value("status_message").toString(); if (status.isEmpty()) { status = contactProperties.value().value("status").toString(); } int index; for (index = 0; index < size(); index++) { if (itemAt(index).data == contact) { break; } } if (index >= size()) { // we don't have this contact in the list if (contactOnline.value()) { add( contactProperties.value().value("display_name").toString(), status, KIcon(avatarPath), contact); } } else { // we already have this contact if (contactOnline.value()) { // we are updating the contact set(index, contactProperties.value().value("display_name").toString(), status, KIcon(avatarPath), contact); } else { // we are removing the contact from the list removeAt(index); if (size() == 0) { d->noOnlineContacts = true; add(i18n("No online contacts"), "", KIcon("user-offline"), QVariant()); } } } }
QList <QDBusObjectPath> QNetworkManagerInterfaceDeviceWireless::getAccessPoints() { QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("GetAccessPoints")); return reply.value(); }
void LancelotAppletConfig::setupUi(QWidget * widget) { Ui::LancelotAppletConfigBase::setupUi(widget); qbgIcons = new QButtonGroup(widget); qbgIcons->addButton(radioShowCategories); qbgIcons->addButton(radioShowMenuIconOnly); qbgMenuActivation = new QButtonGroup(widget); qbgMenuActivation->addButton(radioActivationHover); qbgMenuActivation->addButton(radioActivationClick); connect(radioShowCategories, SIGNAL(clicked()), this, SLOT(updateCard())); connect(radioShowMenuIconOnly, SIGNAL(clicked()), this, SLOT(updateCard())); connect(listIcons, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(iconItemClicked())); org::kde::lancelot::App lancelot( "org.kde.lancelot", "/Lancelot", QDBusConnection::sessionBus() ); QDBusReply<QStringList> replyIDs = lancelot.sectionIDs(); QDBusReply<QStringList> replyNames = lancelot.sectionNames(); QDBusReply<QStringList> replyIcons = lancelot.sectionIcons(); // showing icons QListWidgetItem * item; item = new QListWidgetItem( KIcon("lancelot-start"), i18n("Lancelot"), listIcons); icons["lancelot-start"] = item; item = new QListWidgetItem( KIcon("kde"), i18n("KDE Logo"), listIcons); icons["kde"] = item; item = new QListWidgetItem( KIcon("start-here"), i18n("Start here"), listIcons); icons["start-here"] = item; item = new QListWidgetItem( KIcon("unknown"), i18nc("Choose a custom icon", "Custom"), listIcons); icons["custom"] = item; // showing categs if (!replyIDs.isValid() || !replyNames.isValid() || !replyIcons.isValid()) { // Error connecting to Lancelot via d-bus // setFailedToLaunch(true); return; } for (int i = 0; i < replyIDs.value().size(); i++) { QListWidgetItem * item = new QListWidgetItem( KIcon(replyIcons.value().at(i)), replyNames.value().at(i)); item->setData(Qt::UserRole, replyIDs.value().at(i)); categories[replyIDs.value().at(i)] = item; listSections->addItem(item); item->setSelected(true); } connect(radioActivationClick, SIGNAL(clicked(bool)), this, SIGNAL(settingChanged())); connect(radioActivationHover, SIGNAL(clicked(bool)), this, SIGNAL(settingChanged())); connect(radioShowCategories, SIGNAL(clicked(bool)), this, SIGNAL(settingChanged())); connect(radioShowMenuIconOnly, SIGNAL(clicked(bool)), this, SIGNAL(settingChanged())); connect(listIcons, SIGNAL(itemClicked(QListWidgetItem*)), this, SIGNAL(settingChanged())); }
QScriptValue qDBusReplyToScriptValue(QScriptEngine *eng, const QDBusReply<T> &reply) { return QScriptValue(eng, reply.value()); }
QString SessionDispatcher::get_sound_theme_qt() { QDBusReply<QString> reply = sessioniface->call("get_sound_theme"); return reply.value(); }
/** * This method gets problems from abrtd. * When @p allProblems is @c true, gets problems from all users. * * @param allProblems show problems from all users? * * @return List of problems */ QList<ProblemData*>* Dbus::getProblems(bool allProblems) { //get reply from dbus QDBusReply<QStringList> reply = d->m_dInterface->call(allProblems ? "GetAllProblems" : "GetProblems"); if (reply.isValid()) { //attributes for problems QStringList* stats = new QStringList(); const QString statExecutable("executable"); const QString statTime("time"); const QString statCount("count"); const QString statReported_to("reported_to"); const QString statPkg_name("pkg_name"); const QString statPackage("package"); const QString statType("type"); const QString statReason("reason"); stats->append(statExecutable); stats->append(statTime); stats->append(statPkg_name); stats->append(statCount); stats->append(statReported_to); stats->append(statPackage); stats->append(statType); stats->append(statReason); QStringList stringList = reply.value(); QList<ProblemData*>* list = new QList<ProblemData*>(); ProblemData* item; for (int i = 0; i < stringList.size(); ++i) { //calling method GetInfo via dbus QDBusReply<QMap<QString, QString> > replyInfo = d->m_dInterface->call("GetInfo", stringList.at(i), *stats); if (replyInfo.isValid()) { //set all attributes item = new ProblemData(); item->setId(stringList.at(i)); item->setExecutable(replyInfo.value().value(statExecutable)); item->setPkg_name(replyInfo.value().value(statPkg_name)); item->setCount(replyInfo.value().value(statCount)); item->setTime(replyInfo.value().value(statTime)); item->setPackage(replyInfo.value().value(statPackage)); item->setReported_to(replyInfo.value().value(statReported_to)); item->setType(replyInfo.value().value(statType)); item->setReason(replyInfo.value().value(statReason)); list->append(item); //sort by date, new on top //lambda abstraction, c++11 qSort(list->begin(), list->end(), [](ProblemData * left, ProblemData * right) { return left->time() > right->time(); }); } else { kDebug() << qPrintable("replyInfo failed: " + replyInfo.error().message()); } } delete(stats); return list; } else { kError() << "Call failed: " << qPrintable(reply.error().message()); return NULL; } }
bool SessionDispatcher::get_login_music_enable_qt() { QDBusReply<bool> reply = sessioniface->call("get_login_music_enable"); return reply.value(); }
bool SessionDispatcher::get_input_feedback_sounds_enable_qt() { QDBusReply<bool> reply = sessioniface->call("get_input_feedback_sounds_enable"); return reply.value(); }
/*-----------------------------sound of beauty-----------------------------*/ bool SessionDispatcher::get_sound_event_enable_qt() { QDBusReply<bool> reply = sessioniface->call("get_sound_event_enable"); return reply.value(); }
int main(int argc, char **argv) { KAboutData about("syanot", 0, ki18n("Syanot"), version, ki18n(description), KAboutData::License_GPL, ki18n("(C) 2007 Gael de Chalendar"), KLocalizedString(), 0, "*****@*****.**"); about.addAuthor( ki18n("Gael de Chalendar"), KLocalizedString(), "*****@*****.**" ); KCmdLineArgs::init(argc, argv, &about); KCmdLineOptions options; options.add("+[URL]", ki18n( "Dot graph to open" )); options.add("comparewith file", ki18n("URL of a file containing an analysis to compare the main analysis with")); options.add("utterances list", ki18n("List of utterances ids to display")); KCmdLineArgs::addCmdLineOptions( options ); KApplication app; // see if we are starting with session management if (app.isSessionRestored()) { RESTORE(Syanot); } else { // no session.. just start up normally KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); Syanot *widget = 0; if ( args->count() == 0 ) { widget = new Syanot(); new SyanotAdaptor(widget); QDBusConnection::sessionBus().registerObject("/Syanot", widget); widget->show(); } else { QDBusReply<bool> reply = QDBusConnection::sessionBus().interface()->isServiceRegistered( "org.kde.syanot" ); bool instanceExists = reply.value(); for (int i = 0; i < args->count(); i++ ) { if (instanceExists && (KMessageBox::questionYesNo(0, i18n("There is already a Syanot window opened. What's your choice ?"), i18n("Opening in new window confirmation"), KGuiItem("Open in the existing one"), KGuiItem("Open in new window"), "openInNewWindowMode" ) == KMessageBox::Yes) ) { QByteArray tosenddata; QDataStream arg(&tosenddata, QIODevice::WriteOnly); QString strarg = args->arg(i); KUrl url; if (strarg.left(1) == "/") url = KUrl(strarg); else url = KUrl(QDir::currentPath() + '/' + strarg); arg << url; QDBusInterface iface("org.kde.syanot", "/Syanot", "", QDBusConnection::sessionBus()); if (iface.isValid()) { if (args->isSet("utterances")) { QDBusReply<void> reply = iface.call("slotSetUtterances", args->getOption("utterances")); if (reply.isValid()) { kDebug() << "Reply was valid" << endl; } else { kError() << "Call failed: " << reply.error().message() << endl; return 1; } } QDBusReply<void> reply = iface.call("openUrl", url.pathOrUrl()); if (reply.isValid()) { kDebug() << "Reply was valid" << endl; } else { kError() << "Call failed: " << reply.error().message() << endl; return 1; } if (args->isSet("comparewith")) { QString strarg = args->getOption("comparewith"); KUrl url; if (strarg.left(1) == "/") url = KUrl(strarg); else url = KUrl(QDir::currentPath() + '/' + strarg); reply = iface.call("openSecondaryUrl", url.pathOrUrl()); if (reply.isValid()) { kDebug() << "Reply was valid" << endl; } else { kError() << "Call failed: " << reply.error().message() << endl; return 1; } return 0; } } kError() << "Invalid interface" << endl; exit(0); } else { widget = new Syanot; new SyanotAdaptor(widget); QDBusConnection::sessionBus().registerObject("/Syanot", widget); widget->show(); if (args->isSet("utterances")) { widget->slotSetUtterances(args->getOption("utterances")); } widget->openUrl( args->url( i ) ); if (args->isSet("comparewith")) { QString strarg = args->getOption("comparewith"); kDebug() << "comparewith" << args->getOption("comparewith"); KUrl url; if (strarg.left(1) == "/") url = KUrl(strarg); else url = KUrl(QDir::currentPath() + '/' + strarg); kDebug() << "openSecondaryUrl" << url.pathOrUrl(); widget->openSecondaryUrl(url.pathOrUrl()); } } } } args->clear(); } return app.exec(); }
void Bluetooth::init() { QRegExp rx("dun|rfcomm?|nap"); if (rx.indexIn(mService) < 0) { KMessageBox::sorry(0, i18n("We support 'dun' and 'nap' services only.")); kapp->quit(); return; } // kDebug(KDE_DEFAULT_DEBUG_AREA) << "Bdaddr == " << mBdaddr; /* * Find default bluetooth adapter registered in BlueZ. */ QDBusInterface bluez(QLatin1String("org.bluez"), QLatin1String("/"), QLatin1String("org.bluez.Manager"), QDBusConnection::systemBus()); if (!bluez.isValid()) { KMessageBox::error(0, i18n("Could not contact bluetooth manager (BlueZ).")); kapp->quit(); return; } // kDebug(KDE_DEFAULT_DEBUG_AREA) << "Querying default adapter"; QDBusReply<QDBusObjectPath> adapterPath = bluez.call(QLatin1String("DefaultAdapter")); if (!adapterPath.isValid()) { KMessageBox::error(0, i18n("Default bluetooth adapter not found: %1", adapterPath.error().message())); kapp->quit(); return; } // kDebug(KDE_DEFAULT_DEBUG_AREA) << "Default adapter path is " << adapterPath.value().path(); /* * Find device path registered in BlueZ. */ QDBusInterface adapter(QLatin1String("org.bluez"), adapterPath.value().path(), QLatin1String("org.bluez.Adapter"), QDBusConnection::systemBus()); QDBusReply<QDBusObjectPath> devicePath = adapter.call(QLatin1String("FindDevice"), mBdaddr); if (!devicePath.isValid()) { kWarning(KDE_DEFAULT_DEBUG_AREA) << mBdaddr << " is not registered in default bluetooth adapter, it may be in another adapter."; kWarning(KDE_DEFAULT_DEBUG_AREA) << mBdaddr << " waiting for it to be registered in ModemManager"; QTimer::singleShot(60000, kapp, SLOT(quit())); return; } mDevicePath = devicePath.value().path(); kDebug(KDE_DEFAULT_DEBUG_AREA) << "Device path for " << mBdaddr << " is " << mDevicePath; /* * Find name registered in BlueZ. */ // get device properties QDBusInterface device(QLatin1String("org.bluez"), mDevicePath, QLatin1String("org.bluez.Device"), QDBusConnection::systemBus()); QDBusReply<QMap<QString, QVariant> > deviceProperties = device.call(QLatin1String("GetProperties")); if (!deviceProperties.isValid()) { return; } QMap<QString, QVariant> properties = deviceProperties.value(); // kDebug(KDE_DEFAULT_DEBUG_AREA) << "Device properties == " << properties; if (properties.contains("Name")) { kDebug(KDE_DEFAULT_DEBUG_AREA) << "Name for" << mBdaddr << "is" << properties["Name"].toString(); mDeviceName = properties["Name"].toString(); } /* * Check if phone supports the requested service. */ bool dun = false, nap = false; if (properties.contains("UUIDs")) { foreach (const QString &u, properties["UUIDs"].toStringList()) { QUuid uuid(u); if (uuid.data1 == 0x1103) { dun = true; } else if (uuid.data1 == 0x1116) { nap = true; } } }
int main(int argc, char** argv) { QApplication app(argc, argv); bool isRunning = false; if( QDBusConnection::sessionBus().registerService( "org.vokoscreen.screencast" ) ) { isRunning = false; } else { isRunning = true; } QStringList arguments = QApplication::instance()->arguments(); for( int i = 1; i < arguments.count(); ++i ) { if ( ( arguments[ 1 ] == "--help" ) or ( arguments[ 1 ] == "-help" ) or ( arguments[ 1 ] == "-h" ) or ( arguments[ 1 ] == "-?" ) ) { qDebug( " " ); qDebug() << "Usage: vokoscreen [method] [arg]"; qDebug( " " ); qDebug() << "Hint:"; qDebug() << " vokoscreen must running, bevor call method."; qDebug( " " ); qDebug( "Methods:" ); QvkDbus *vkDbus = new QvkDbus(); qDebug().noquote() << " " << vkDbus->showAllMethods(); qDebug( " " ); return close( 0 ); } } if ( ( isRunning == false ) and ( QApplication::instance()->arguments().count() > 1 ) ) { qDebug() << "Please start vokoscreen first, without a method."; return 0; } // DBus option arguments QDBusReply<QString> reply; QDBusConnection bus = QDBusConnection::sessionBus(); QDBusInterface dbus_iface("org.vokoscreen.screencast", "/gui", "org.vokoscreen.gui", bus); if ( ( isRunning == true ) and ( QApplication::instance()->arguments().count() > 1 ) ) { QvkDbus *vkDbus = new QvkDbus(); QString string = vkDbus->showAllMethods(); if ( string.contains( QApplication::instance()->arguments().at( 1 ) ) == false ) { QString string = QApplication::instance()->arguments().at( 1 ); std::cout << "Error:" << " " << string.toStdString() << " " << "is not a method" << std::endl; } if ( QApplication::instance()->arguments().count() == 2 ) { reply = dbus_iface.call( QApplication::instance()->arguments().at( 1 ) ); } if ( QApplication::instance()->arguments().count() == 3 ) { reply = dbus_iface.call( QApplication::instance()->arguments().at( 1 ), QApplication::instance()->arguments().at( 2 )); } // vokoscreens Ausgabe wird mit qDebug auf stderr ausgegeben // std::cout gibt die Ausgabe auf stdout aus, und somit kann in einem script die Ausgabe // in eine Variable geleitet werden. std::cout << reply.value().toStdString() << std::endl; goto stop; } { QTranslator * qtTranslator = new QTranslator(); qtTranslator->load( "qt_" + QLocale::system().name(), QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ); app.installTranslator( qtTranslator ); QTranslator translator; translator.load( "vokoscreen_" + QLocale::system().name(), ":/language" ); app.installTranslator( &translator ); } if( isRunning == false ) { screencast *foo = new screencast(); foo->show(); return app.exec(); } else { QMessageBox::StandardButton ret = QMessageBox::information( NULL, QObject::tr( "Info" ), QObject::tr( "vokoscreen can be started only once" ), QMessageBox::Close ); (void)ret; } stop: { return 0; } }
QList<QDBusObjectPath> QUDisksInterface::enumerateDevices() { QDBusReply<QList<QDBusObjectPath> > reply = call(QLatin1String("EnumerateDevices")); return reply.value(); }
QList <QDBusObjectPath> QNetworkManagerInterface::getDevices() const { QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("GetDevices")); return reply.value(); }
void ConserveWidget::initData() { iface = new QDBusInterface("org.gnome.SettingsDaemon", "/org/gnome/SettingsDaemon/Power", "org.gnome.SettingsDaemon.Power.Screen", QDBusConnection::sessionBus()); gamma_slider->setValue(sessionproxy->get_screen_gamma_qt()); QDBusReply<int> reply = iface->call("GetPercentage"); if (reply.isValid()) { brightness_slider->setValue(reply.value()); brightness_value_label->setText(QString::number(brightness_slider->value())); } else { brightness_label->hide(); brightness_value_label->hide(); brightness_slider->hide(); } current_idle_delay = sessionproxy->get_current_idle_delay_qt(); QStringList idledelaylist = sessionproxy->get_idle_delay_list_qt(); QStringList huname_idle_list; huname_idle_list << tr("1 minute") << tr("2 minutes") << tr("3 minutes") << tr("5 minutes") << tr("10 minutes") << tr("Half an hour") << tr("1 hour") << tr("never"); QList<QString>::Iterator it1 = idledelaylist.begin(), itend1 = idledelaylist.end(); int initIndex1 = 0; bool inHere = false; for(;it1 != itend1; it1++,initIndex1++) { if(*it1 == current_idle_delay) { inHere = true; break; } } if (inHere == false) { huname_idle_list << current_idle_delay; initIndex1 = huname_idle_list.length() - 1; } idle_delay_combo->clear(); idle_delay_combo->clearEditText(); idle_delay_combo->addItems(huname_idle_list); idle_delay_combo->setCurrentIndex(initIndex1); lock_enabled_switch->switchedOn = sessionproxy->get_lock_enabled_qt(); if(lock_enabled_switch->switchedOn) { lock_delay_combo->setDisabled(false); } else { lock_delay_combo->setDisabled(true); } current_lock_delay = sessionproxy->get_current_lock_delay_qt(); QStringList lockdelaylist = sessionproxy->get_lock_delay_list_qt(); QStringList huname_lock_list; huname_lock_list << tr("30 seconds") << tr("1 minute") << tr("2 minutes") << tr("3 minutes") << tr("5 minutes") << tr("10 minutes") << tr("Half an hour") << tr("1 hour") << tr("Turn off the screen"); QList<QString>::Iterator it2 = lockdelaylist.begin(), itend2 = lockdelaylist.end(); int initIndex2 = 0; inHere = false; for(;it2 != itend2; it2++,initIndex2++) { if(*it2 == current_lock_delay) { inHere = true; break; } } if (inHere == false) { huname_lock_list << current_lock_delay; initIndex2 = huname_lock_list.length() - 1; } lock_delay_combo->clear(); lock_delay_combo->clearEditText(); lock_delay_combo->addItems(huname_lock_list); lock_delay_combo->setCurrentIndex(initIndex2); QString critical_low = sessionproxy->get_current_critical_low_qt(); if(critical_low == "suspend" ) { suspend_low_radio->setChecked(true); shutdown_radio->setChecked(false); } else if(critical_low == "shutdown") { shutdown_radio->setChecked(true); suspend_low_radio->setChecked(false); } QString laptop_battery = sessionproxy->get_current_lid_battery_qt(); if(laptop_battery == "suspend") { suspend_lid_battery_radio->setChecked(true); nothing_battery_radio->setChecked(false); } else if(laptop_battery == "nothing") { nothing_battery_radio->setChecked(true); suspend_lid_battery_radio->setChecked(false); } QString laptop_ac = sessionproxy->get_current_lid_ac_qt(); if(laptop_ac == "suspend") { suspend_lid_ac_radio->setChecked(true); nothing_ac_radio->setChecked(false); } else if(laptop_ac == "nothing") { nothing_ac_radio->setChecked(true); suspend_lid_ac_radio->setChecked(false); } sleep_timeout_battery = sessionproxy->get_current_sleep_timeout_battery_qt(); QStringList batterylist = sessionproxy->get_sleep_timeout_list_qt(); QStringList huname_battery_list; huname_battery_list << tr("5 minutes") << tr("10 minutes") << tr("20 minutes") << tr("Half an hour") << tr("1 hour") << tr("2 hours") << tr("never"); QList<QString>::Iterator it3 = batterylist.begin(), itend3 = batterylist.end(); int initIndex3 = 0; inHere = false; for(;it3 != itend3; it3++,initIndex3++) { if(*it3 == sleep_timeout_battery) { inHere = true; break; } } if (inHere == false) { huname_battery_list << sleep_timeout_battery; initIndex3 = huname_battery_list.length() - 1; } sleep_battery_combo->clear(); sleep_battery_combo->clearEditText(); sleep_battery_combo->addItems(huname_battery_list); sleep_battery_combo->setCurrentIndex(initIndex3); sleep_timeout_ac = sessionproxy->get_current_sleep_timeout_ac_qt(); QStringList aclist = sessionproxy->get_sleep_timeout_list_qt(); QStringList huname_ac_list; huname_ac_list << tr("5 minutes") << tr("10 minutes") << tr("20 minutes") << tr("Half an hour") << tr("1 hour") << tr("2 hours") << tr("never"); QList<QString>::Iterator it4 = aclist.begin(), itend4 = aclist.end(); int initIndex4 = 0; inHere = false; for(;it4 != itend4; it4++,initIndex4++) { if(*it4 == sleep_timeout_ac) { inHere = true; break; } } if (inHere == false) { huname_ac_list << sleep_timeout_ac; initIndex4 = huname_ac_list.length() - 1; } sleep_ac_combo->clear(); sleep_ac_combo->clearEditText(); sleep_ac_combo->addItems(huname_ac_list); sleep_ac_combo->setCurrentIndex(initIndex4); sleep_timeout_display_battery = sessionproxy->get_current_sleep_timeout_display_battery_qt(); QStringList huname_display_battery_list; huname_display_battery_list << tr("5 minutes") << tr("10 minutes") << tr("20 minutes") << tr("Half an hour") << tr("1 hour") << tr("2 hours") << tr("never"); QList<QString>::Iterator it5 = aclist.begin(), itend5 = aclist.end(); int initIndex5 = 0; inHere = false; for(;it5 != itend5; it5++,initIndex5++) { if(*it5 == sleep_timeout_display_battery) { inHere = true; break; } } if (inHere == false) { huname_display_battery_list << sleep_timeout_display_battery; initIndex5 = huname_display_battery_list.length() - 1; } sleep_battery_display_combo->clear(); sleep_battery_display_combo->clearEditText(); sleep_battery_display_combo->addItems(huname_display_battery_list); sleep_battery_display_combo->setCurrentIndex(initIndex5); sleep_timeout_display_ac = sessionproxy->get_current_sleep_timeout_display_ac_qt(); QStringList huname_display_ac_list; huname_display_ac_list << tr("5 minutes") << tr("10 minutes") << tr("20 minutes") << tr("Half an hour") << tr("1 hour") << tr("2 hours") << tr("never"); QList<QString>::Iterator it6 = aclist.begin(), itend6 = aclist.end(); int initIndex6 = 0; inHere = false; for(;it6 != itend6; it6++,initIndex6++) { if(*it6 == sleep_timeout_display_ac) { inHere = true; break; } } if (inHere == false) { huname_display_ac_list << sleep_timeout_display_ac; initIndex6 = huname_display_ac_list.length() - 1; } sleep_ac_display_combo->clear(); sleep_ac_display_combo->clearEditText(); sleep_ac_display_combo->addItems(huname_display_ac_list); sleep_ac_display_combo->setCurrentIndex(initIndex6); dataOK = true; this->initConnect(); }
QList <QDBusObjectPath> QNetworkManagerSettings::listConnections() { QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("ListConnections")); return reply.value(); }
/** * \brief Search /sys/block for valid removable media devices. * * This function creates MediaDevice instances for valid removable media * devices found under the /sys/block filesystem in Linux. CD and DVD * devices are created as MythCDROM instances. MythHDD instances will be * created for each partition on removable hard disk devices, if they exist. * Otherwise a single MythHDD instance will be created for the entire disc. * * NOTE: Floppy disks are ignored. */ bool MediaMonitorUnix::CheckMountable(void) { #if CONFIG_QTDBUS for (int i = 0; i < 10; ++i, usleep(500000)) { // Connect to UDisks. This can sometimes fail if mythfrontend // is started during system init QDBusInterface iface(UDISKS_SVC, UDISKS_PATH, UDISKS_IFACE, QDBusConnection::systemBus() ); if (!iface.isValid()) { LOG(VB_GENERAL, LOG_ALERT, LOC + "CheckMountable: DBus interface error: " + iface.lastError().message() ); continue; } // Enumerate devices typedef QList<QDBusObjectPath> QDBusObjectPathList; QDBusReply<QDBusObjectPathList> reply = iface.call("EnumerateDevices"); if (!reply.isValid()) { LOG(VB_GENERAL, LOG_ALERT, LOC + "CheckMountable DBus EnumerateDevices error: " + reply.error().message() ); continue; } // Listen on DBus for UDisk add/remove device messages (void)QDBusConnection::systemBus().connect( UDISKS_SVC, UDISKS_PATH, UDISKS_IFACE, UDISKS_DEVADD, UDISKS_DEVSIG, this, SLOT(deviceAdded(QDBusObjectPath)) ); (void)QDBusConnection::systemBus().connect( UDISKS_SVC, UDISKS_PATH, UDISKS_IFACE, UDISKS_DEVRMV, UDISKS_DEVSIG, this, SLOT(deviceRemoved(QDBusObjectPath)) ); // Parse the returned device array const QDBusObjectPathList& list(reply.value()); for (QDBusObjectPathList::const_iterator it = list.begin(); it != list.end(); ++it) { if (!DeviceProperty(*it, "DeviceIsSystemInternal").toBool() && !DeviceProperty(*it, "DeviceIsPartitionTable").toBool() ) { QString dev = DeviceProperty(*it, "DeviceFile").toString(); // ignore floppies, too slow if (dev.startsWith("/dev/fd")) continue; MythMediaDevice* pDevice; if (DeviceProperty(*it, "DeviceIsRemovable").toBool()) pDevice = MythCDROM::get(this, dev.toLatin1(), false, m_AllowEject); else pDevice = MythHDD::Get(this, dev.toLatin1(), false, false); if (pDevice && !AddDevice(pDevice)) pDevice->deleteLater(); } } // Success return true; } // Timed out return false; #elif defined linux // NB needs script in /etc/udev/rules.d mkfifo(kUDEV_FIFO, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); m_fifo = open(kUDEV_FIFO, O_RDONLY | O_NONBLOCK); QDir sysfs("/sys/block"); sysfs.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); QStringList devices = sysfs.entryList(); for (QStringList::iterator it = devices.begin(); it != devices.end(); ++it) { // ignore floppies, too slow if ((*it).startsWith("fd")) continue; sysfs.cd(*it); QString path = sysfs.absolutePath(); if (CheckRemovable(path)) FindPartitions(path, true); sysfs.cdUp(); } return true; #else // linux return false; #endif }
int main(int argc, char **argv) { KAboutData about("kgrapheditor", 0, ki18n("KGraphEditor"), version, ki18n(description), KAboutData::License_GPL, ki18n("(C) 2005-2010 Gaël de Chalendar"), KLocalizedString(), 0, "*****@*****.**"); about.addAuthor( ki18n("Gaël de Chalendar"), KLocalizedString(), "*****@*****.**" ); KCmdLineArgs::init(argc, argv, &about); KCmdLineOptions options; options.add("+[URL]", ki18n( "Dot graph to open" )); KCmdLineArgs::addCmdLineOptions( options ); KApplication app; // see if we are starting with session management if (app.isSessionRestored()) { RESTORE(KGraphEditor); } else { // no session.. just start up normally KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KGraphEditor *widget = 0; if ( args->count() == 0 ) { widget = new KGraphEditor; new KgrapheditorAdaptor(widget); QDBusConnection::sessionBus().registerObject("/KGraphEditor", widget); widget->show(); } else { QDBusReply<bool> reply = QDBusConnection::sessionBus().interface()->isServiceRegistered( "org.kde.kgrapheditor" ); bool instanceExists = reply.value(); for (int i = 0; i < args->count(); i++ ) { if (instanceExists && (KMessageBox::questionYesNo(0, i18n("A KGraphEditor window is already open, where do you want to open this file?"), i18n("Opening in new window confirmation"), KGuiItem(i18nc("Where to open a file", "Existing window")), KGuiItem(i18nc("Where to open a file", "New window")), "openInNewWindowMode" ) == KMessageBox::Yes) ) { QByteArray tosenddata; QDataStream arg(&tosenddata, QIODevice::WriteOnly); QString strarg = args->arg(i); KUrl url; if (strarg.left(1) == "/") url = KUrl(strarg); else url = KUrl(QDir::currentPath() + '/' + strarg); arg << url; QDBusInterface iface("org.kde.kgrapheditor", "/KGraphEditor", "", QDBusConnection::sessionBus()); if (iface.isValid()) { QDBusReply<void> reply = iface.call("openUrl", url.pathOrUrl()); if (reply.isValid()) { kDebug() << "Reply was valid" << endl; return 0; } kError() << "Call failed: " << reply.error().message() << endl; return 1; } kError() << "Invalid interface" << endl; exit(0); } else { widget = new KGraphEditor; new KgrapheditorAdaptor(widget); QDBusConnection::sessionBus().registerObject("/KGraphEditor", widget); widget->show(); widget->openUrl( args->url( i ) ); } } } args->clear(); if (widget != 0) { widget-> reloadPreviousFiles(); } } return app.exec(); }
void DBusSender::sendAsyncMessage() { QDBusReply<QString> reply = iface->asyncInvoke(m_sender.text().toLocal8Bit()); setWindowTitle(reply.value()); }
int Solid::PowerManagement::beginSuppressingScreenPowerManagement(const QString &reason) { if (globalInhibitions->policyAgentIface.isValid()) { QDBusReply<uint> reply = globalInhibitions->policyAgentIface.AddInhibition( (uint)InhibitionsPrivate::ChangeScreenSettings, QCoreApplication::applicationName(), reason); if (reply.isValid()) { QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("/ScreenSaver"), QStringLiteral("org.freedesktop.ScreenSaver"), QStringLiteral("Inhibit")); message << QCoreApplication::applicationName(); message << reason; QDBusReply<uint> ssReply = QDBusConnection::sessionBus().asyncCall(message); if (ssReply.isValid()) { globalInhibitions->screensaverCookiesForPowerDevilCookies.insert(reply, ssReply.value()); } return reply; } else { return -1; } } else { // No way to fallback on something, hence return failure return -1; } }
void WatchCommands::musicControl(WatchConnector::MusicControl operation) { logger()->debug() << "Operation:" << operation; QString mpris = parent()->property("mpris").toString(); if (mpris.isEmpty()) { logger()->debug() << "No mpris interface active"; return; } QString method; switch(operation) { case WatchConnector::musicPLAY_PAUSE: method = "PlayPause"; break; case WatchConnector::musicPAUSE: method = "Pause"; break; case WatchConnector::musicPLAY: method = "Play"; break; case WatchConnector::musicNEXT: method = "Next"; break; case WatchConnector::musicPREVIOUS: method = "Previous"; break; case WatchConnector::musicVOLUME_UP: case WatchConnector::musicVOLUME_DOWN: { QDBusReply<QDBusVariant> VolumeReply = QDBusConnection::sessionBus().call( QDBusMessage::createMethodCall(mpris, "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "Get") << "org.mpris.MediaPlayer2.Player" << "Volume"); if (VolumeReply.isValid()) { double volume = VolumeReply.value().variant().toDouble(); if (operation == WatchConnector::musicVOLUME_UP) { volume += 0.1; } else { volume -= 0.1; } logger()->debug() << "Setting volume" << volume; QDBusError err = QDBusConnection::sessionBus().call( QDBusMessage::createMethodCall(mpris, "/org/mpris/MediaPlayer2", "org.freedesktop.DBus.Properties", "Set") << "org.mpris.MediaPlayer2.Player" << "Volume" << QVariant::fromValue(QDBusVariant(volume))); if (err.isValid()) { logger()->error() << err.message(); } } else { logger()->error() << VolumeReply.error().message(); } } return; case WatchConnector::musicGET_NOW_PLAYING: onMprisMetadataChanged(parent()->property("mprisMetadata").toMap()); return; case WatchConnector::musicSEND_NOW_PLAYING: logger()->warn() << "Operation" << operation << "not supported"; return; } if (method.isEmpty()) { logger()->error() << "Requested unsupported operation" << operation; return; } logger()->debug() << operation << "->" << method; QDBusError err = QDBusConnection::sessionBus().call( QDBusMessage::createMethodCall(mpris, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player", method)); if (err.isValid()) { logger()->error() << err.message(); } }
MMRegistrationInfoType QModemManagerGsmNetworkInterface::registrationStatus() { QDBusReply<MMRegistrationInfoType > reply = d->connectionInterface->call(QLatin1String("GetRegistrationInfo")); return reply.value(); }
// Convienence function to send notifications. This function does some processing // of the arguments. In these functions: // expire_timeout: The amount of time in milliseconds the message is shown. // A value of -1 means timeout is based on server's settings. // overwrite : Will overwrite the previous message sent from this function. // It will not overwrite notifications sent by other programs. // // // Show notification with summary, app_name, and body text void NotifyClient::sendNotification () { // make sure we have a connection we can send the notification to. if (! b_validconnection) return; // variables QString app_name = s_app_name; quint32 replaces_id = 0; QString app_icon = ""; QString body = ""; QString summary = s_summary; QStringList actions = QStringList(); QVariantMap hints; int expire_timeout = i_expire_timeout; // set replaces_id if (b_overwrite) replaces_id = current_id; // assemble the hints hints.clear(); hints.insert("urgency", QVariant::fromValue(static_cast<uchar>(i_urgency)) ); //if (! app_icon.isEmpty() ) hints.insert("image-path", QVariant::fromValue(app_icon)); // make sure we can display the text on this server if (sl_capabilities.contains("body", Qt::CaseInsensitive) ) { body = s_body; if (! sl_capabilities.contains ("body-markup", Qt::CaseInsensitive) ) { QTextDocument td; td.setHtml(body); body = td.toPlainText(); } // if server cannot display markup } // if capabilities contains body // process the icon, if we are using a fallback icon create a temporary file to hold it QTemporaryFile* tempfileicon = NULL; if (! s_icon.isEmpty() ) { if (QFile::exists(s_icon) ) { tempfileicon = new QTemporaryFile(this); tempfileicon->setAutoRemove(false); if (tempfileicon->open() ) { QPixmap px = QPixmap(s_icon); px.save(tempfileicon->fileName(),"PNG"); app_icon = tempfileicon->fileName().prepend("file://"); } // if tempfileicon could be opened } // if s_icon exists as a disk file // assume s_icon exists as a theme icon, don't check it here. That // check needs to be done in the calling program. else app_icon = s_icon; } // if s_icon is not empty QDBusReply<quint32> reply = notifyclient->call(QLatin1String("Notify"), app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout); if (reply.isValid() ) { current_id = reply.value(); if (file_map.contains(current_id) && tempfileicon != NULL) { if (b_overwrite) { file_map.value(current_id)->remove(); delete file_map.value(current_id); file_map.remove(current_id); } // if else { tempfileicon->remove(); delete tempfileicon; tempfileicon = NULL; } // else } // if contains current_id and not NULL if (tempfileicon != NULL) file_map[current_id] = tempfileicon; } // if reply is valid else #if QT_VERSION >= 0x050400 qCritical("CMST - Error reply received to the Notify method: %s", qUtf8Printable(reply.error().message()) ); #else qCritical("CMST - Error reply received to the Notify method: %s", qPrintable(reply.error().message()) ); #endif return; }
QMmScanResult QModemManagerGsmNetworkInterface::scan() { QDBusReply<QMmScanResult> reply = d->connectionInterface->call(QLatin1String("Scan")); return reply.value(); }
QStringList SessionDispatcher::get_titlebar_options_qt() { QDBusReply<QStringList> reply = sessioniface->call("get_titlebar_options"); return reply.value(); }