Esempio n. 1
0
void KAccounts::moduleLoadCallFinished(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<bool> reply = *watcher;
    bool loaded;
    if (reply.isError()) {
        loaded = false;
    } else {
        loaded = reply.value();
    }

    if (!loaded) {
        qWarning() << "Unable to start the kded module, things may (and most probably will) misbehave";
    }
}
Esempio n. 2
0
void SsuCli::optMode(QStringList opt){
  QTextStream qout(stdout);
  QTextStream qerr(stderr);

  // TODO: allow setting meaningful names instead of numbers

  if (opt.count() == 2){
    QStringList modeList;
    int deviceMode = ssu.deviceMode();

    if ((deviceMode & Ssu::DisableRepoManager) == Ssu::DisableRepoManager)
      modeList.append("DisableRepoManager");
    if ((deviceMode & Ssu::RndMode) == Ssu::RndMode)
      modeList.append("RndMode");
    if ((deviceMode & Ssu::ReleaseMode) == Ssu::ReleaseMode)
      modeList.append("ReleaseMode");
    if ((deviceMode & Ssu::LenientMode) == Ssu::LenientMode)
      modeList.append("LenientMode");
    if ((deviceMode & Ssu::UpdateMode) == Ssu::UpdateMode)
      modeList.append("UpdateMode");

    qout << "Device mode is: " << ssu.deviceMode()
         << " (" << modeList.join(" | ") << ")" << endl;

    if ((deviceMode & Ssu::RndMode) == Ssu::RndMode &&
        (deviceMode & Ssu::ReleaseMode) == Ssu::ReleaseMode)
      qout << "Both Release and RnD mode set, device is in RnD mode" << endl;

    state = Idle;
  } else if (opt.count() == 3 && opt.at(2) == "-s"){
    qout << ssu.deviceMode();
    state = Idle;
  } else if (opt.count() == 3){
    qout << "Setting device mode from " << ssu.deviceMode()
         << " to " << opt.at(2) << endl;

    QDBusPendingReply<> reply = ssuProxy->setDeviceMode(opt.at(2).toInt());
    reply.waitForFinished();
    if (reply.isError()){
      qerr << "DBus call failed, falling back to libssu" << endl;
      ssu.setDeviceMode(Ssu::DeviceModeFlags(opt.at(2).toInt()));

      SsuRepoManager repoManager;
      repoManager.update();
      uidWarning();
    }

    state = Idle;
  }
}
Esempio n. 3
0
void MDeviceState::gotDisplayStatus(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<QString> reply = *watcher;
    if (reply.isError()) {
        qDebug() << __func__ << "getting display state failed:"
                 << reply.error().message();
        goto away;
    }
    mceDisplayStatusIndSignal(reply);

away:
    delete display_call;
    display_call = 0;
}
/*!
    Deletes the user designated by \a uid.

    \param uid The user identifier.
    \param removeFiles If true all files owned by the user will be removed.
    \return whether the user was deleted successfully.
*/
bool AccountsManager::deleteUser(uid_t uid, bool removeFiles)
{
    Q_D(AccountsManager);

    QDBusPendingReply<> reply = d->interface->DeleteUser(uid, removeFiles);
    if (reply.isError()) {
        QDBusError error = reply.error();
        qWarning("Couldn't delete user %d: %s", uid,
                 error.errorString(error.type()).toUtf8().constData());
        return false;
    }

    return true;
}
Esempio n. 5
0
bool Systemd::SystemdPrivate::enableUnitFiles(const QStringList &files, bool runtime, bool force)
{
    qDBusRegisterMetaType<DBusUnitFileChange>();
    qDBusRegisterMetaType<DBusUnitFileChangeList>();
    QDBusPendingReply<bool, DBusUnitFileChangeList> reply = isdface.EnableUnitFiles(files, runtime, force);
    reply.waitForFinished();

    if (reply.isError()) {
        qDebug() << reply.error().message();
        return false;
    }

    return true;
}
void RazorNotificationPrivate::update()
{
    QDBusPendingReply<uint> reply = mInterface->Notify(qAppName(), mId, mIconName, mSummary, mBody, mActions, mHints, mTimeout);
    reply.waitForFinished();
    if (!reply.isError())
    {
        mId = reply.value();
    }
    else
    {
        if (mHints.contains("urgency") && mHints.value("urgency").toInt() != RazorNotification::UrgencyLow)
            QMessageBox::information(0, tr("Notifications Fallback"), mSummary + " \n\n " + mBody);
    }
}
Esempio n. 7
0
void MDeviceState::gotTouchScreenLockMode(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<QString> reply = *watcher;
    if (reply.isError()) {
        qDebug() << __func__ << "getting touch screen lock mode failed:"
                 << reply.error().message();
        goto away;
    }
    touchScreenLockMode = reply;

away:
    delete tsmode_call;
    tsmode_call = 0;
}
void CReporterPrivacySettingsWidget::gotCoreFilesReply(QDBusPendingCallWatcher *call)
{
    if (!waitingForCoreFilesReply)
        return;
    waitingForCoreFilesReply = false;
    QDBusPendingReply<QStringList> fetchReply = *call;

    if (fetchReply.isError()) {
        // Show error, if failed to communicate with the daemon.
        //% "Failed to fetch crash reports from the system."
        CReporterInfoBanner::show(qtTrId("qtn_dcp_failed_to_fetch_crash_reports_text"));
        call->deleteLater();
        return;
    }

    QStringList files = fetchReply.argumentAt<0>();

    if (files.isEmpty()) {
        // No unsent crash reports.
        //% "This system has not stored crash reports."
        CReporterInfoBanner::show(qtTrId("qtn_dcp_no_stored_reports_text"));
        call->deleteLater();
        return;
    }

    // Pass files to dialog server for selection.
    QVariantList arguments;
    arguments << files;

    bool openViaNotification = false; // Open the dialog immediately
    arguments << openViaNotification;

    CReporterDialogServerProxy dialogServerProxy(CReporter::DialogServerServiceName,
                            CReporter::DialogServerObjectPath, QDBusConnection::sessionBus(), this);

    QDBusPendingReply<bool> selectReply =
            dialogServerProxy.requestDialog(CReporter::SendSelectedDialogType, arguments);

    selectReply.waitForFinished();

    if (selectReply.isError()) {
        // Show error, if failed to communicate with the daemon.
        //% "Dialog request failed."
        CReporterInfoBanner::show(qtTrId("qtn_dcp_daemon_communication_error_text."));
        call->deleteLater();
        return;
    }
    call->deleteLater();
}
QString QBluetoothSocketPrivate::peerName() const
{
    quint64 bdaddr;

    if (socketType == QBluetoothServiceInfo::RfcommProtocol) {
        sockaddr_rc addr;
        socklen_t addrLength = sizeof(addr);

        if (::getpeername(socket, reinterpret_cast<sockaddr *>(&addr), &addrLength) < 0)
            return QString();

        convertAddress(addr.rc_bdaddr.b, bdaddr);
    } else if (socketType == QBluetoothServiceInfo::L2capProtocol) {
        sockaddr_l2 addr;
        socklen_t addrLength = sizeof(addr);

        if (::getpeername(socket, reinterpret_cast<sockaddr *>(&addr), &addrLength) < 0)
            return QString();

        convertAddress(addr.l2_bdaddr.b, bdaddr);
    } else {
        qCWarning(QT_BT_BLUEZ) << "peerName() called on socket of unknown type";
        return QString();
    }

    const QString peerAddress = QBluetoothAddress(bdaddr).toString();
    const QString localAdapter = localAddress().toString();

    if (isBluez5()) {
        OrgFreedesktopDBusObjectManagerInterface manager(QStringLiteral("org.bluez"),
                                                         QStringLiteral("/"),
                                                         QDBusConnection::systemBus());
        QDBusPendingReply<ManagedObjectList> reply = manager.GetManagedObjects();
        reply.waitForFinished();
        if (reply.isError())
            return QString();

        foreach (const QDBusObjectPath &path, reply.value().keys()) {
            const InterfaceList ifaceList = reply.value().value(path);
            foreach (const QString &iface, ifaceList.keys()) {
                if (iface == QStringLiteral("org.bluez.Device1")) {
                    if (ifaceList.value(iface).value(QStringLiteral("Address")).toString()
                            == peerAddress)
                        return ifaceList.value(iface).value(QStringLiteral("Alias")).toString();
                }
            }
        }
        return QString();
    } else {
void QOfonoConnectionContext::setContextPath(const QString &idPath)
{

    if (idPath != contextPath()) {
        if(d_ptr->context) {
            delete d_ptr->context;
            d_ptr->context = 0;
            d_ptr->properties.clear();
        }

qDebug() << Q_FUNC_INFO;
        d_ptr->context = new OfonoConnectionContext("org.ofono", idPath, QDBusConnection::systemBus(),this);
        if (d_ptr->context->isValid()) {
            d_ptr->contextPath = idPath;
            connect(d_ptr->context,SIGNAL(PropertyChanged(QString,QDBusVariant)),
                    this,SLOT(propertyChanged(QString,QDBusVariant)));
            QDBusPendingReply<QVariantMap> reply;
            reply = d_ptr->context->GetProperties();
            reply.waitForFinished();
            if (reply.isError())
                Q_EMIT reportError(reply.error().message());

            d_ptr->properties = reply.value();
           Q_EMIT contextPathChanged(idPath);

        } else {
            Q_EMIT reportError("Context is not valid");
            qDebug() << Q_FUNC_INFO << "error Context is not valid";
        }
        QOfonoManager manager;
        if (manager.modems().count() > 0) {
            QOfonoConnectionManager connManager;
            Q_FOREACH (const QString &path, manager.modems()) {
                connManager.setModemPath(path);
                if (connManager.contexts().contains(idPath)) {
                    d_ptr->modemPath = path;
                    Q_EMIT modemPathChanged(path);
                    break;
                }
            }
        }
/*        if (!validateProvisioning()) {
            provisionForCurrentNetwork(this->type());
        } else {
            Q_EMIT reportError("Context provision is not valid");
            qDebug() << Q_FUNC_INFO << "error Context provision is not valid";
        }
*/
    }
Esempio n. 11
0
void QMaliitPlatformInputContext::reset()
{
    const bool hadPreedit = !d->preedit.isEmpty();
    if (hadPreedit && inputMethodAccepted()) {
        // ### selection
        QInputMethodEvent event;
        event.setCommitString(d->preedit);
        QGuiApplication::sendEvent(qGuiApp->focusObject(), &event);
        d->preedit.clear();
    }

    QDBusPendingReply<void> reply = d->server->reset();
    if (hadPreedit)
        reply.waitForFinished();
}
Esempio n. 12
0
void PlayerActionJob::callFinished(QDBusPendingCallWatcher* watcher)
{
    QDBusPendingReply<void> result = *watcher;
    watcher->deleteLater();

    if (result.isError()) {
        // FIXME: try to be a bit cleverer with the error message?
        setError(Failed);
        setErrorText(result.error().message());
    } else {
        setError(NoError);
    }

    emitResult();
}
Esempio n. 13
0
void NetworkRegistrationWatcher::getPropertiesAsyncCallback(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<QVariantMap> reply = *watcher;
    if (reply.error().isValid()) {
        log_error("DBus call to interface %s function GetProperties of path %s failed: %s",
                  interface().toStdString().c_str(),
                  objectPath().toStdString().c_str(),
                  reply.error().message().toStdString().c_str());
        return;
    }

    QVariantMap map = reply.argumentAt<0>();
    foreach (const QString &key, map.keys())
        emit propertyChanged(objectPath(), key, map.value(key));
}
Esempio n. 14
0
void QMirClientClipboard::onDBusClipboardGetContentsFinished(QDBusPendingCallWatcher* call)
{
    Q_ASSERT(call == mPendingGetContentsCall.data());

    QDBusPendingReply<QByteArray> reply = *call;
    if (reply.isError()) {
        qCritical("QMirClientClipboard - Failed to get system clipboard contents via D-Bus. %s, %s",
                qPrintable(reply.error().name()), qPrintable(reply.error().message()));
        // TODO: Might try again later a number of times...
    } else {
        QByteArray serializedMimeData = reply.argumentAt<0>();
        updateMimeData(serializedMimeData);
    }
    call->deleteLater();
}
Esempio n. 15
0
void ItemRetrievalJob::callFinished(QDBusPendingCallWatcher *watcher)
{
    watcher->deleteLater();
    QDBusPendingReply<QString> reply = *watcher;
    if (m_active) {
        m_active = false;
        const QString errorMsg = reply.isError() ? reply.error().message() : reply;
        if (!errorMsg.isEmpty()) {
            Q_EMIT requestCompleted(m_request, QStringLiteral("Unable to retrieve item from resource: %1").arg(errorMsg));
        } else {
            Q_EMIT requestCompleted(m_request, QString());
        }
    }
    deleteLater();
}
Esempio n. 16
0
void ConferenceAuthOp::onPasswordProvided(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<bool> reply = *watcher;
    if (!reply.isValid() || reply.count() < 1) {
        return;
    }

    if (reply.argumentAt<0>()) {
        m_walletInterface->setEntry(m_account,m_channel->targetId(), m_password);
        setFinished();
    } else {
        qDebug() << "Password was incorrect, enter again";
        passwordDialog();
    }
}
Esempio n. 17
0
PendingSessions* SessionTracker::listSessions()
{
    PendingSessions *ps = new PendingSessions;

    auto pendingReply = m_managerIface->ListSessions();
    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply);
    connect(watcher, &QDBusPendingCallWatcher::finished, ps, [=]() {
        QDBusPendingReply<SessionInfoList> reply = *watcher;
        watcher->deleteLater();
        QList<PendingSession*> sessionsToLoad;
        foreach(const SessionInfo &sessionInfo, reply.value()) {
            sessionsToLoad << Session::sessionFromPath(sessionInfo.sessionPath);
        }
        ps->setPendingItems(sessionsToLoad);
    });
Esempio n. 18
0
PendingSeats* SeatTracker::listSeats()
{
    PendingSeats *ps = new PendingSeats;

    auto pendingReply = m_managerIface->ListSeats();
    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingReply);
    connect(watcher, &QDBusPendingCallWatcher::finished, ps, [=]() {
        QDBusPendingReply<NamedSeatPathList> reply = *watcher;
        watcher->deleteLater();
        QList<PendingSeat*> seatsToLoad;
        foreach(const NamedSeatPath &seat, reply.value()) {
            seatsToLoad << Seat::seatFromPath(seat.path);
        }
        ps->setPendingItems(seatsToLoad);
    });
void  SnorePlugin::Freedesktop::slotNotify(Snore::Notification noti)
{
    if (noti.data()->sourceAndTargetAreSimilar(this)) {
        return;
    }

    QStringList actions;
    foreach(int k, noti.actions().keys()) {
        actions << QString::number(k) << noti.actions()[k].name();
    }
    QVariantMap hints;

    FreedesktopImageHint image(noti.icon().pixmap(QSize(128, 128)).toImage());
    hints.insert(QStringLiteral("image_data"), QVariant::fromValue(image));

    char urgency = 1;
    if (noti.priority() < 0) {
        urgency = 0;
    } else if (noti.priority() > 2) {
        urgency = 2;
    }
    hints.insert(QStringLiteral("urgency"), urgency);

    if (noti.application().constHints().contains("desktop-entry")) {
        hints.insert(QStringLiteral("desktop-entry"), noti.application().constHints().value("desktop-entry"));
    }

    hints.insert(QStringLiteral("suppress-sound"), noti.constHints().value("silent").toBool());

    uint updateId = 0;
    if (noti.isUpdate()) {
        updateId = noti.old().hints().privateValue(this, "id").toUInt();
        m_dbusIdMap.take(updateId);
    }

    QString title = noti.application().name() + QLatin1String(" - ") + noti.title(m_supportsRichtext ? Snore::Utils::AllMarkup : Snore::Utils::NoMarkup);
    QString body(noti.text(m_supportsRichtext ? Snore::Utils::AllMarkup : Snore::Utils::NoMarkup));
    //TODO: add app icon hint?
    QDBusPendingReply<uint>  id = m_interface->Notify(noti.application().name(), updateId, QString(), title,
                                  body, actions, hints, noti.isSticky() ? -1 : noti.timeout() * 1000);

    id.waitForFinished();
    noti.hints().setPrivateValue(this, "id", id.value());
    m_dbusIdMap[id.value()] = noti;
    slotNotificationDisplayed(noti);

    qCDebug(SNORE) << noti.id() << "|" << id.value();
}
Esempio n. 20
0
bool ClientImpl::modifyClientAction(const QString &path, const QString &description)
{
    if (!mActions.contains(path))
    {
        return false;
    }

    QDBusPendingReply<bool> reply = mProxy->modifyClientAction(QDBusObjectPath(path), description);
    reply.waitForFinished();
    if (reply.isError())
    {
        return false;
    }

    return reply.argumentAt<0>();
}
Esempio n. 21
0
QString ClientImpl::changeClientActionShortcut(const QString &path, const QString &shortcut)
{
    if (!mActions.contains(path))
    {
        return QString();
    }

    QDBusPendingReply<QString> reply = mProxy->changeClientActionShortcut(QDBusObjectPath(path), shortcut);
    reply.waitForFinished();
    if (reply.isError())
    {
        return QString();
    }

    return reply.argumentAt<0>();
}
static inline OrgBluezDeviceInterface *getDevice(const QBluetoothAddress &address, QBluetoothLocalDevicePrivate *d_ptr)
{
    if (!d_ptr || !d_ptr->adapter)
        return 0;
    QDBusPendingReply<QDBusObjectPath> reply = d_ptr->adapter->FindDevice(address.toString());
    reply.waitForFinished();
    if(reply.isError()) {
        qWarning() << Q_FUNC_INFO << "reply failed" << reply.error();
        return 0;
    }

    QDBusObjectPath path = reply.value();

    return new OrgBluezDeviceInterface(QLatin1String("org.bluez"), path.path(),
                                       QDBusConnection::systemBus());
}
/*!
    Creates a new \a accountType type user account whose name is \a userName,
    real name is \a fullName.

    \param userName The name of the new user to be created.
    \param fullName First name and last name.
    \param accountType The account type.
    \return whether the user was created successfully.
*/
bool AccountsManager::createUser(const QString &userName,
                                 const QString &fullName,
                                 UserAccount::AccountType accountType)
{
    Q_D(AccountsManager);

    QDBusPendingReply<QDBusObjectPath> reply = d->interface->CreateUser(userName, fullName, accountType);
    if (reply.isError()) {
        QDBusError error = reply.error();
        qWarning("Couldn't create user %s: %s", userName.toUtf8().constData(),
                 error.errorString(error.type()).toUtf8().constData());
        return false;
    }

    return true;
}
Esempio n. 24
0
void ClientImpl::removeAction(ActionImpl *actionImpl)
{
    QString path = actionImpl->path();
    if (!mActions.contains(path))
    {
        return;
    }

    QDBusPendingReply<bool> reply = mProxy->deactivateClientAction(QDBusObjectPath(path));
    reply.waitForFinished();

    QDBusConnection::sessionBus().unregisterObject(QString("/global_key_shortcuts") + path);

    mActions[path]->disconnect();
    mActions.remove(path);
}
Esempio n. 25
0
void QBluetoothLocalDevice::powerOn()
{
    if (!d_ptr)
        return;

    // Ensure that mode change is confirmed by first requesting a session
    QDBusPendingReply<void> reply = d_ptr->adapter->RequestSession();
    reply.waitForFinished();
    if (reply.isError())
        return;

    d_ptr->adapter->SetProperty(QLatin1String("Powered"), QDBusVariant(QVariant::fromValue(true)));

    // Release requested session in order to keep Bluez happy
    d_ptr->adapter->ReleaseSession();
}
Esempio n. 26
0
void A2DPTest::connectResult(QDBusPendingCallWatcher *watcher)
{
    watcher->deleteLater();
    QDBusPendingReply<> reply = *watcher;
    if (!reply.isValid()) {
        if (reply.isError() && reply.error().name() == A2DP_CONNECTED) {
            emit deviceReady(true);
            return;
        }

        delete audioSink;
        audioSink = NULL;
        emit deviceReady(false);
    } else
        emit deviceReady(true);
}
Esempio n. 27
0
QNetworkManagerSettings::QNetworkManagerSettings(const QString &settingsService, QObject *parent)
        : QDBusAbstractInterface(settingsService,
                                 NM_DBUS_PATH_SETTINGS,
                                 NM_DBUS_IFACE_SETTINGS,
                                 QDBusConnection::systemBus(), parent)
{
    if (!isValid()) {
        return;
    }
    interfacePath = settingsService;
    QDBusPendingReply<QList <QDBusObjectPath> > nmReply
            = call(QLatin1String("ListConnections"));

    if (!nmReply.isError()) {
        connectionsList = nmReply.value();
    }
}
Esempio n. 28
0
QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent)
    : QDBusAbstractInterface(settingsService,
                             connectionObjectPath,
                             NM_DBUS_IFACE_SETTINGS_CONNECTION,
                             QDBusConnection::systemBus(), parent)
{
    qDBusRegisterMetaType<QNmSettingsMap>();
    if (!isValid()) {
        return;
    }
    interfacepath = connectionObjectPath;
    QDBusPendingReply<QNmSettingsMap> nmReply
            = call(QLatin1String("GetSettings"));
    if (!nmReply.isError()) {
        settingsMap = nmReply.value();
    }
}
Esempio n. 29
0
void ConferenceAuthOp::passwordFlagOperationFinished(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<uint> reply = *watcher;
    if (reply.isError()) {
        qWarning() << "Reply is a error. ABORT!";
        return;
    }


    if (reply.argumentAt<0>() == Tp::ChannelPasswordFlagProvide) {
        if (m_walletInterface->hasEntry(m_account, m_channel->targetId())) {
            providePassword(m_walletInterface->entry(m_account, m_channel->targetId()));
        } else {
            passwordDialog();
        }
    }
}
Esempio n. 30
0
void QOfonoCallForwarding::getPropertiesComplete(QDBusPendingCallWatcher *call)
{
    QDBusPendingReply<QVariantMap> reply = *call;
    if (!reply.isError()) {
        d_ptr->properties = reply.value();
        Q_EMIT voiceUnconditionalChanged(voiceUnconditional());
        Q_EMIT voiceBusyChanged(voiceBusy());
        Q_EMIT voiceNoReplyChanged(voiceNoReply());
        Q_EMIT voiceNoReplyTimeoutChanged(voiceNoReplyTimeout());
        Q_EMIT voiceNotReachableChanged(voiceNotReachable());
        Q_EMIT forwardingFlagOnSimChanged(forwardingFlagOnSim());
        Q_EMIT readyChanged();
    } else {
        Q_EMIT getPropertiesFailed();
    }
    call->deleteLater();
}