Example #1
0
void QBluetoothLocalDevicePrivate::pairingCompleted(QDBusPendingCallWatcher *watcher)
{
    Q_Q(QBluetoothLocalDevice);
    QDBusPendingReply<> reply = *watcher;

    if(reply.isError()) {
        qDebug() << Q_FUNC_INFO << "failed to create pairing" << reply.error();
        emit q->pairingFinished(address, QBluetoothLocalDevice::Unpaired);
        delete watcher;
        return;
    }

    QDBusPendingReply<QDBusObjectPath> findReply = adapter->FindDevice(address.toString());
    findReply.waitForFinished();
    if(findReply.isError()) {
        qDebug() << Q_FUNC_INFO << "failed to find device" << findReply.error();
        emit q->pairingFinished(address, QBluetoothLocalDevice::Unpaired);
        delete watcher;
        return;
    }

    OrgBluezDeviceInterface device(QLatin1String("org.bluez"), findReply.value().path(),
                                   QDBusConnection::systemBus());

    if(pairing == QBluetoothLocalDevice::AuthorizedPaired) {
        device.SetProperty(QLatin1String("Trusted"), QDBusVariant(QVariant(true)));
        emit q->pairingFinished(address, QBluetoothLocalDevice::AuthorizedPaired);
    }
    else {
        device.SetProperty(QLatin1String("Trusted"), QDBusVariant(QVariant(false)));
        emit q->pairingFinished(address, QBluetoothLocalDevice::Paired);
    }
    delete watcher;

}
void PendingConnection::onCallFinished(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<QString, QDBusObjectPath> reply = *watcher;

    if (!reply.isError()) {
        QString busName = reply.argumentAt<0>();
        QString objectPath = reply.argumentAt<1>().path();

        debug() << "Got reply to ConnectionManager.CreateConnection - bus name:" <<
            busName << "- object path:" << objectPath;

        PendingReady *readyOp = manager()->connectionFactory()->proxy(busName,
                objectPath, manager()->channelFactory(), manager()->contactFactory());
        mPriv->connection = ConnectionPtr::qObjectCast(readyOp->proxy());
        connect(readyOp,
                SIGNAL(finished(Tp::PendingOperation*)),
                SLOT(onConnectionBuilt(Tp::PendingOperation*)));
    } else {
        debug().nospace() <<
            "CreateConnection failed: " <<
            reply.error().name() << ": " << reply.error().message();
        setFinishedWithError(reply.error());
    }

    watcher->deleteLater();
}
Example #3
0
void QBluetoothDeviceDiscoveryAgentPrivate::start()
{

    if(pendingCancel == true) {
        pendingStart = true;
        return;
    }

    discoveredDevices.clear();

    QDBusPendingReply<QDBusObjectPath> reply = manager->DefaultAdapter();
    reply.waitForFinished();
    if (reply.isError()) {
        errorString = reply.error().message();
#ifdef QTM_DEVICEDISCOVERY_DEBUG
        qDebug() << Q_FUNC_INFO << "ERROR: " << errorString;
#endif
        lastError = QBluetoothDeviceDiscoveryAgent::IOFailure;
        Q_Q(QBluetoothDeviceDiscoveryAgent);
        emit q->error(lastError);
        return;
    }

    adapter = new OrgBluezAdapterInterface(QLatin1String("org.bluez"), reply.value().path(),
                                           QDBusConnection::systemBus());

    Q_Q(QBluetoothDeviceDiscoveryAgent);
    QObject::connect(adapter, SIGNAL(DeviceFound(QString,QVariantMap)),
                     q, SLOT(_q_deviceFound(QString,QVariantMap)));
    QObject::connect(adapter, SIGNAL(PropertyChanged(QString,QDBusVariant)),
                     q, SLOT(_q_propertyChanged(QString,QDBusVariant)));

    QDBusPendingReply<QVariantMap> propertiesReply = adapter->GetProperties();
    propertiesReply.waitForFinished();
    if(propertiesReply.isError()) {
#ifdef QTM_DEVICEDISCOVERY_DEBUG
        qDebug() << Q_FUNC_INFO << "ERROR: " << errorString;
#endif
        errorString = propertiesReply.error().message();
        lastError = QBluetoothDeviceDiscoveryAgent::IOFailure;
        Q_Q(QBluetoothDeviceDiscoveryAgent);
        emit q->error(lastError);
        return;
    }

    QDBusPendingReply<> discoveryReply = adapter->StartDiscovery();
    if (discoveryReply.isError()) {
        delete adapter;
        adapter = 0;
        errorString = discoveryReply.error().message();
        lastError = QBluetoothDeviceDiscoveryAgent::IOFailure;
        Q_Q(QBluetoothDeviceDiscoveryAgent);
        emit q->error(lastError);
#ifdef QTM_DEVICEDISCOVERY_DEBUG
        qDebug() << Q_FUNC_INFO << "ERROR: " << errorString;
#endif
        return;
    }
}
void PowerManagerNux::OnAsyncReply(QDBusPendingCallWatcher *call)
{
    if (m_state == request_idle)
    {
        QDBusPendingReply<> reply = *call;

        if(reply.isError())
        {
            qDebug("D-Bus: Reply: Error: %s", qPrintable(reply.error().message()));
            m_state = error;
        }
        else
        {
            m_state = idle;
            qDebug("D-Bus: PowerManagerInhibitor: Request successful");
            if (m_intended_state == busy)
                this->setState(1, QString::fromLatin1(""));
        }
    }
    else if (m_state == request_busy)
    {
        QDBusPendingReply<uint> reply = *call;

        if(reply.isError())
        {
            qDebug("D-Bus: Reply: Error: %s", qPrintable(reply.error().message()));

            if (!m_use_gsm)
            {
                qDebug("D-Bus: Falling back to org.gnome.SessionManager");
                m_use_gsm = true;
                m_state = idle;
                if (m_intended_state == busy)
                    // XXX
                    this->setState(1, QString("Busy"));
            }
            else
            {
                m_state = error;
            }
        }
        else
        {
            m_state = busy;
            m_cookie = reply.value();
            qDebug("D-Bus: PowerManagerInhibitor: Request successful, cookie is %d", m_cookie);
            if (m_intended_state == idle)
                // XXX
                this->setState(0, QString("Iddle"));
        }
    }
    else
    {
        qDebug("D-Bus: Unexpected reply in state %d", m_state);
        m_state = error;
    }

    call->deleteLater();
}
void QMirClientClipboard::onDBusClipboardSetContentsFinished(QDBusPendingCallWatcher *call)
{
    QDBusPendingReply<void> reply = *call;
    if (reply.isError()) {
        qCritical("QMirClientClipboard - Failed to set the 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...
    }
    call->deleteLater();
}
Example #6
0
void QOfonoMessageManager::sendMessageFinished(QDBusPendingCallWatcher *call)
{
    QDBusPendingReply<QDBusObjectPath> reply = *call;
    bool ok = true;
    if (reply.isError()) {
        qWarning() << Q_FUNC_INFO << "failed:" << reply.error();
         d_ptr->errorMessage = reply.error().name() + " " + reply.error().message();
         ok = false;
    }
    Q_EMIT sendMessageComplete(ok, reply.value().path());
}
Example #7
0
Transaction::InternalError Daemon::setProxy(const QString& http_proxy, const QString& https_proxy, const QString& ftp_proxy, const QString& socks_proxy, const QString& no_proxy, const QString& pac)
{
    Q_D(Daemon);
    QDBusPendingReply<> r = d->daemon->SetProxy(http_proxy, https_proxy, ftp_proxy, socks_proxy, no_proxy, pac);
    r.waitForFinished();
    d->lastError = r.error();
    if (r.isError()) {
        return Transaction::parseError(r.error().name());
    } else {
        return Transaction::InternalErrorNone;
    }
}
void QOfonoNetworkOperator::registerFinished(QDBusPendingCallWatcher *call)
{
    QDBusPendingReply<> reply = *call;
    QOfonoNetworkOperator::Error error = NoError;
    QString errorString;

    if (reply.isError()) {
         qWarning() << "QOfonoNetworkOperator::registerOperator() failed:" << reply.error();
         error = errorNameToEnum(reply.error().name());
         errorString = reply.error().name() + " " + reply.error().message();
    }
    Q_EMIT registerComplete(error,errorString);
}
Example #9
0
void QOfonoVoiceCall::deflectFinished(QDBusPendingCallWatcher *call)
{
    QDBusPendingReply<> reply = *call;
    QOfonoVoiceCall::Error error = NoError;
    QString errorString;

    if (reply.isError()) {
         qWarning() << "QOfonoVoiceCall::deflect() failed:" << reply.error();
         error = errorNameToEnum(reply.error().name());
         errorString = reply.error().name() + " " + reply.error().message();
    }
    Q_EMIT deflectComplete(error, errorString);
}
void ConnectionAgentPlugin::sendUserReply(const QVariantMap &input)
{
    if (!connManagerInterface || !connManagerInterface->isValid()) {
        Q_EMIT errorReported("","ConnectionAgent not available");
        return;
    }
    QDBusPendingReply<> reply = connManagerInterface->sendUserReply(input);
    reply.waitForFinished();
    if (reply.isError()) {
        qDebug() << Q_FUNC_INFO << reply.error().message();
        Q_EMIT errorReported("",reply.error().message());
    }
}
void QOfonoHandsfreeAudioCard::connectAudioFinished(QDBusPendingCallWatcher *call)
{
    QDBusPendingReply<> reply = *call;
    QOfonoHandsfreeAudioCard::Error error = NoError;
    QString errorString;

    if (reply.isError()) {
         qWarning() << "QOfonoHandsfreeAudioCard::connectAudio() failed:" << reply.error();
         error = errorNameToEnum(reply.error().name());
         errorString = reply.error().name() + " " + reply.error().message();
    }

    emit connectAudioComplete(error, errorString);
}
Example #12
0
void QOfonoCallMeter::resetFinished(QDBusPendingCallWatcher *call)
{
    call->deleteLater();
    QDBusPendingReply<> reply = *call;
    QOfonoCallMeter::Error error = NoError;
    QString errorString;

    if (reply.isError()) {
        qWarning() << "QOfonoCallMeter::reset() failed:" << reply.error();
        error = errorNameToEnum(reply.error().name());
        errorString = reply.error().name() + " " + reply.error().message();
        Q_EMIT resetComplete(error,errorString);
    }
}
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();
}
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));
}
/*!
    Returns a list of user accounts.

    \param systemUsers If true, returns also system users.
*/
UserAccountList AccountsManager::listCachedUsers()
{
    Q_D(AccountsManager);

    UserAccountList list;

    QDBusPendingReply< QList<QDBusObjectPath> > reply = d->interface->ListCachedUsers();
    reply.waitForFinished();

    if (reply.isError()) {
        QDBusError error = reply.error();
        qWarning("Couldn't list cached users: %s",
                 error.errorString(error.type()).toUtf8().constData());
        return list;
    }

    QList<QDBusObjectPath> value = reply.argumentAt<0>();
    list.reserve(value.size());

    for (int i = 0; i < value.size(); i++) {
        const QString path = value.at(i).path();
        UserAccount *account = d->usersCache.value(path, Q_NULLPTR);
        if (!account) {
            account = new UserAccount(path, d->interface->connection());
            d->usersCache[path] = account;
        }
        list.append(account);
    }

    return list;
}
QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString &activeConnectionObjectPath, QObject *parent)
    : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
                             activeConnectionObjectPath,
                             NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
                             QDBusConnection::systemBus(), parent)
{
    if (!isValid()) {
        return;
    }
    PropertiesDBusInterface connectionActivePropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
                                                  activeConnectionObjectPath,
                                                  QLatin1String("org.freedesktop.DBus.Properties"),
                                                  QDBusConnection::systemBus());


    QList<QVariant> argumentList;
    argumentList << QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION);
    QDBusPendingReply<QVariantMap> propsReply
            = connectionActivePropertiesInterface.callWithArgumentList(QDBus::Block,QLatin1String("GetAll"),
                                                                       argumentList);

    if (!propsReply.isError()) {
        propertyMap = propsReply.value();
    } else {
        qWarning() << propsReply.error().message();
    }

    QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
                                  activeConnectionObjectPath,
                                  QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
                                  QLatin1String("PropertiesChanged"),
                                  this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
}
/*!
    Cached a list of user accounts.
    Async unblocking API.
*/
void AccountsManager::listCachedUsersAsync()
{
    Q_D(AccountsManager);

    QDBusPendingCall call = d->interface->ListCachedUsers();
    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *w) {
        QDBusPendingReply< QList<QDBusObjectPath> > reply = *w;
        w->deleteLater();
        if (reply.isError()) {
            QDBusError error = reply.error();
            qWarning("Couldn't list cached users: %s",
                     error.errorString(error.type()).toUtf8().constData());
        } else {
            UserAccountList userList;
            QList<QDBusObjectPath> value = reply.argumentAt<0>();
            userList.reserve(value.size());
            for (int i = 0; i < value.size(); i++) {
                const QString path = value.at(i).path();
                UserAccount *account = d->usersCache.value(path, Q_NULLPTR);
                if (!account) {
                    account = new UserAccount(path, d->interface->connection());
                    d->usersCache[path] = account;
                }
                userList.append(account);
            }
            Q_EMIT listCachedUsersFinished(userList);
        }
    });
}
void ShutDownFrame::inhibitShutdown() {
    m_login1Inter = new DBusLogin1Manager("org.freedesktop.login1", "/org/freedesktop/login1", QDBusConnection::systemBus(), this);
    QString reminder_tooltip  = QString();

    if (m_login1Inter->isValid()) {
        qDebug() <<  "m_login1Inter is valid!";

        QDBusPendingReply<InhibitorsList> reply = m_login1Inter->ListInhibitors();
        reply.waitForFinished();

        if (!reply.isError()){
            InhibitorsList inhibitList = qdbus_cast<InhibitorsList>(reply.argumentAt(0));
            qDebug() << "inhibitList:" << inhibitList.count();

            for(int i = 0; i < inhibitList.count();i++) {
                if (inhibitList.at(i).what == "shutdown" && inhibitList.at(i).dosome == "block") {
                    reminder_tooltip = inhibitList.at(i).why;
                }
            }
            qDebug() << "shutdown Reason!" << reminder_tooltip;
            showTips(reminder_tooltip);
        } else {
            reminder_tooltip = "";
            qDebug() << reply.error().message();
        }
    } else {
        qDebug() << "shutdown login1Manager error!";
        reminder_tooltip = "";
    }
}
void NotificationsModel::refreshNotificationList()
{
    if (!m_dbusInterface) {
        return;
    }

    if (!m_notificationList.isEmpty()) {
        beginRemoveRows(QModelIndex(), 0, m_notificationList.size() - 1);
        qDeleteAll(m_notificationList);
        m_notificationList.clear();
        endRemoveRows();
    }

    if (!m_dbusInterface->isValid()) {
        kDebug(debugArea()) << "dbus interface not valid";
        return;
    }

    QDBusPendingReply<QStringList> pendingNotificationIds = m_dbusInterface->activeNotifications();
    pendingNotificationIds.waitForFinished();
    if (pendingNotificationIds.isError()) {
        kDebug(debugArea()) << pendingNotificationIds.error();
        return;
    }
    const QStringList& notificationIds = pendingNotificationIds.value();

    if (notificationIds.isEmpty()) {
        return;
    }

    beginInsertRows(QModelIndex(), 0, notificationIds.size() - 1);
    Q_FOREACH (const QString& notificationId, notificationIds) {
        NotificationDbusInterface* dbusInterface = new NotificationDbusInterface(m_deviceId, notificationId, this);
        m_notificationList.append(dbusInterface);
    }
void QBluetoothTransferReplyBluez::sessionStarted(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<QDBusObjectPath, QVariantMap> reply = *watcher;
    if (reply.isError()) {
        qCWarning(QT_BT_BLUEZ) << "Failed to start obex session:"
                               << reply.error().name() << reply.reply().errorMessage();

        m_errorStr = QBluetoothTransferReply::tr("Push session cannot be started");
        m_error = QBluetoothTransferReply::SessionError;
        m_finished = true;
        m_running = false;

        cleanupSession();

        emit QBluetoothTransferReply::error(m_error);
        emit finished(this);

        watcher->deleteLater();
        return;
    }

    const QDBusObjectPath path = reply.argumentAt<0>();
    const QVariantMap map = reply.argumentAt<1>();
    m_transfer_path = path.path();

    //watch the transfer
    OrgFreedesktopDBusPropertiesInterface *properties = new OrgFreedesktopDBusPropertiesInterface(
                            QStringLiteral("org.bluez.obex"), path.path(),
                            QDBusConnection::sessionBus(), this);
    connect(properties, SIGNAL(PropertiesChanged(QString,QVariantMap,QStringList)),
            SLOT(sessionChanged(QString,QVariantMap,QStringList)));

    watcher->deleteLater();
}
Example #21
0
void NetworkManager::getPropertiesReply(QDBusPendingCallWatcher *call)
{
    Q_ASSERT(call);

    pr_dbg() << "Got reply with manager's properties";

    QDBusPendingReply<QVariantMap> reply = *call;
    if (reply.isError()) {

        pr_dbg() << "Error getPropertiesReply: " << reply.error().message();

        disconnectFromConnman();

        // TODO: set up timer to reconnect in a bit
        QTimer::singleShot(10000,this,SLOT(connectToConnman()));
    } else {

        m_propertiesCache = reply.value();

        pr_dbg() << "Initial Manager's properties";
        pr_dbg() << "\tState: " << m_propertiesCache[State].toString();
        pr_dbg() << "\tOfflineMode: " << m_propertiesCache[OfflineMode].toString();

        emit stateChanged(m_propertiesCache[State].toString());

        connect(m_manager,
                SIGNAL(PropertyChanged(const QString&, const QDBusVariant&)),
                this,
                SLOT(propertyChanged(const QString&, const QDBusVariant&)));
    }
}
void ManagerProxy::managerDBusGetModemsDone(QDBusPendingCallWatcher *call)
{
    QDBusPendingReply<QArrayOfPathProperties> reply = *call;

    if (reply.isError()) {
        // TODO: Handle this properly, by setting states, or disabling features
        qWarning() << "org.ofono.Manager.GetModems() failed: " <<
                      reply.error().message();
    } else {
        QArrayOfPathProperties modems = reply.value();
        if (modems.count() >= 1) {
            // FIXME: Handle multiple modems...
            OfonoPathProperties p = modems[0];
            if (m_modemPath.isNull() || m_modemPath.isEmpty()) {
                qDebug() << QString("\n======\nUsing modem: \"%1\"\n======").arg(p.path.path());
                m_modemPath = QString(p.path.path());
                m_modem = new ModemProxy(m_modemPath);
                m_network = new NetworkProxy(m_modemPath);
                m_callManager = new CallManager(m_modemPath);
                m_volumeManager = new VolumeManager(m_modemPath);
                m_voicemail = new VoicemailProxy(m_modemPath);
            // TODO: Connect to service proxies as available/needed here
            }
        }
    }
}
/*!
    Caches a user account, so that it shows up in listCachedUsers() output.
    The user name may be a remote user, but the system must be able to lookup
    the user name and resolve the user information.

    A userCached() signal with a UserAccount pointer will be emitted as soon
    as the user account has been cached by AccountsService.

    \param userName The user name for the user.
*/
void AccountsManager::cacheUser(const QString &userName)
{
    Q_D(AccountsManager);

    QDBusPendingCall call = d->interface->CacheUser(userName);
    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
    connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *w) {
        QDBusPendingReply<QDBusObjectPath> reply = *w;
        w->deleteLater();
        if (reply.isError()) {
            QDBusError error = reply.error();
            qWarning("Couldn't cache user %s: %s",
                     userName.toUtf8().constData(),
                     error.errorString(error.type()).toUtf8().constData());
        } else {
            QDBusObjectPath path = reply.argumentAt<0>();
            if (path.path().isEmpty())
                return;

            UserAccount *account = d->usersCache.value(path.path(), Q_NULLPTR);
            if (!account) {
                account = new UserAccount(path.path(), d->interface->connection());
                d->usersCache[path.path()] = account;
            }
            Q_EMIT userCached(account);
        }
    });
}
/*!
    Finds a user by \a userName.
    Sync blocking API.

    \param userName The user name to look up.
    \return the corresponding UserAccount object.
*/
UserAccount *AccountsManager::findUserByName(const QString &userName)
{
    Q_D(AccountsManager);

    QDBusPendingReply<QDBusObjectPath> reply = d->interface->FindUserByName(userName);
    reply.waitForFinished();

    if (reply.isError()) {
        QDBusError error = reply.error();
        qWarning("Couldn't find user by user name %s: %s",
                 userName.toUtf8().constData(),
                 error.errorString(error.type()).toUtf8().constData());
        return 0;
    }

    QDBusObjectPath path = reply.argumentAt<0>();
    if (path.path().isEmpty())
        return Q_NULLPTR;

    UserAccount *account = d->usersCache.value(path.path(), Q_NULLPTR);
    if (!account) {
        account = new UserAccount(path.path(), d->interface->connection());
        d->usersCache[path.path()] = account;
    }
    return account;
}
QStringList
PlatformUdisks2::getPartitionList(const QString &devicePath)
{
    QStringList partitionList;
    org::freedesktop::DBus::ObjectManager manager("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2", QDBusConnection::systemBus());
    QDBusPendingReply<DBUSManagerStruct> reply = manager.GetManagedObjects();
    reply.waitForFinished();
    if (reply.isError()) {
        qDebug() << "Failure: " <<  reply.error();
        exit(0);
    }

    QRegExp reg(QString("%1[0-9]+$").arg(devicePath));

    Q_FOREACH(const QDBusObjectPath &path, reply.value().keys()) {
        const QString udi = path.path();
        if (!udi.startsWith("/org/freedesktop/UDisks2/block_devices"))
            continue;

        if (!udi.contains(reg))
            continue;
        partitionList << udi;
    }

    return partitionList;
}
void CReporterNotificationPrivate::retrieveNotificationId()
{
    if (callWatcher == 0)
        return;

    callWatcher->waitForFinished();

    QDBusPendingReply<quint32> reply = *callWatcher;
    callWatcher->deleteLater();
    callWatcher = 0;

    if (reply.isValid()) {
        id = reply.argumentAt<0>();
        if (id == 0) {
            // Notification didn't exist, create a new one.
            sendDBusNotify();
            retrieveNotificationId();
            return;
        }
        qDebug() << __PRETTY_FUNCTION__
                 << "Create notification with id: " << id;
    } else if (reply.isError()) {
        QDBusError error = reply.error();
        qDebug() << __PRETTY_FUNCTION__ << "Failed to create notification: "
                 << error.name() << " - " << error.message();
    }
}
Example #27
0
void request_watcher_t::call_returned(QDBusPendingCallWatcher *w)
{
  log_debug() ;
  log_assert(w==this->w, "oops, somethig is really wrong with qdbus...") ;

  QDBusPendingReply<bool> reply = *w ;

  bool ok = reply.isValid() and reply.value() ;

  abstract_io_state_t *next = machine->state_dlg_user ;

  if (ok)
    log_notice("Voland acknowledge received, moving %d event(s) to DLG_USER", events.size()) ;
  else
  {
    string err = reply.isValid() ? "false returned" : reply.error().message().toStdString() ;
    log_error("Voland call 'create' failed, message: '%s'", err.c_str()) ;
    log_notice("moving %d event(s) to DLG_WAIT", events.size()) ;
    next = machine->state_dlg_wait ;
  }

  for(set<event_t*>::const_iterator it=events.begin(); it!=events.end(); ++it)
    next->go_to(*it) ;

  if (events.size()>0)
    machine->process_transition_queue() ;

  // Don't need the watcher any more
  delete this ;
}
void AbstractBluetoothSerialProfile::connect(string hwaddy)
{
	std::string device = findDevice(hwaddy);

	if(device.empty())
	{
		DebugOut(DebugOut::Error) << "could not find device with address: " << hwaddy << endl;
		return;
	}

	QDBusInterface deviceManager("org.bluez", device.c_str(), "org.bluez.Device1", QDBusConnection::systemBus());

	if(!deviceManager.isValid())
	{
		DebugOut(DebugOut::Error) << "could not create DBus interface for device with address '"
								  << hwaddy <<"' " << deviceManager.lastError().message().toStdString() << endl;
		return;
	}

	QDBusPendingCall reply = deviceManager.asyncCall("Connect");

	QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);

	QObject::connect(watcher, &QDBusPendingCallWatcher::finished, [](auto call)
	{
		QDBusPendingReply<void> reply = *call;
		if(reply.isError())
		{
			DebugOut(DebugOut::Error) << "Connecting: " << reply.error().message().toStdString() << endl;
		}
	});

}
void QBluetoothTransferReplyBluez::sessionCreated(QDBusPendingCallWatcher *watcher)
{
    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
    if (reply.isError()) {
        qCWarning(QT_BT_BLUEZ) << "Failed to create obex session:"
                               << reply.error().name() << reply.reply().errorMessage();

        m_errorStr = QBluetoothTransferReply::tr("Invalid target address");
        m_error = QBluetoothTransferReply::HostNotFoundError;
        m_finished = true;
        m_running = false;

        emit QBluetoothTransferReply::error(m_error);
        emit finished(this);

        watcher->deleteLater();
        return;
    }

    m_objectPushBluez = new OrgBluezObexObjectPush1Interface(QStringLiteral("org.bluez.obex"),
                                                           reply.value().path(),
                                                           QDBusConnection::sessionBus(), this);
    QDBusPendingReply<QDBusObjectPath, QVariantMap> newReply = m_objectPushBluez->SendFile(fileToTranser);
    QDBusPendingCallWatcher *newWatcher = new QDBusPendingCallWatcher(newReply, this);
    connect(newWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
            SLOT(sessionStarted(QDBusPendingCallWatcher*)));
    watcher->deleteLater();
}
Example #30
0
void SessionAgent::requestConnect()
{
    if (m_session) {
      QDBusPendingReply<> reply = m_session->Connect();
      if (reply.isError())
          qDebug() << reply.error().message();
    }
}