void QApplicationCommand::updateState(QApplicationCommand::State state, QApplicationCommand::ConnectionError error, const QString &errorString)
{
    if (state != m_connectionState)
    {
        m_connectionState = state;
        emit connectionStateChanged(m_connectionState);

        if (m_connectionState == Connected)
        {
            if (m_connected != true) {
                m_connected = true;
                emit connectedChanged(true);
            }
        }
        else
        {
            if (m_connected != false) {
                m_connected = false;
                emit connectedChanged(m_connected);
            }
        }
    }

    updateError(error, errorString);
}
void QApplicationLauncher::updateState(Service::State state, Service::ConnectionError error, QString errorString)
{
    if (state != m_connectionState)
    {
        if (m_connected) // we are not connected anymore
        {
            stopSubscribeHeartbeat();
            clearSync();
            m_connected = false;
            emit connectedChanged(false);
        }
        else if (state == Service::Connected) {
            m_connected = true;
            emit connectedChanged(true);
        }

        m_connectionState = state;
        emit connectionStateChanged(m_connectionState);

        if ((state == Service::Disconnected) || (state == Service::Error)) {
            initializeObject();
        }
    }

    updateError(error, errorString);
}
Example #3
0
bool Player::init(QObject* sonos)
{
  Sonos* _sonos = reinterpret_cast<Sonos*>(sonos);
  if (_sonos)
  {
    disconnectSonos(m_sonos);
    m_sonos = _sonos;
    m_player = _sonos->getPlayer();
    if (m_player)
    {
      connectSonos(m_sonos);

      // Clear context from the new player
      m_RCTable.clear();
      if (!m_player->RenderingPropertyEmpty())
        handleRenderingControlChange();
      if (!m_player->TransportPropertyEmpty())
        handleTransportChange();

      m_connected = true;
      emit connectedChanged();
      return true;
    }
  }
  m_connected = false;
  emit connectedChanged();
  return false;
}
Example #4
0
void QApplicationStatus::updateState(QApplicationStatus::State state, QApplicationStatus::ConnectionError error, const QString &errorString)
{
    if (state != m_connectionState)
    {
        if (m_connected) // we are not connected anymore
        {
            stopStatusHeartbeat();
            clearSync();
            m_connected = false;
            emit connectedChanged(false);
        }
        else if (state == Connected) {
            m_connected = true;
            emit connectedChanged(true);
        }

        m_connectionState = state;
        emit connectionStateChanged(m_connectionState);

        if ((state == Disconnected) || (state == Error)) {
            initializeObject(MotionChannel);
            initializeObject(ConfigChannel);
            initializeObject(IoChannel);
            initializeObject(TaskChannel);
            initializeObject(InterpChannel);
        }
    }

    updateError(error, errorString);
}
Example #5
0
void UserStream::setConnected(bool connected)
{
    if (m_connected != connected) {
        m_connected = connected;
        emit connectedChanged();
    }
}
void QFbMessenger::setConnected(bool c){
	bool old = this->connected;
	this->connected = c;

	if(old != c)
		emit connectedChanged(c);
}
void OutputConfig::outputChanged(RROutput output, int changes)
{
    Q_ASSERT(m_output->id() == output); Q_UNUSED(output);
    qDebug() << "Output" << m_output->name() << "changed. ( mask =" << QString::number(changes) << ")";

    disconnect(absolutePosX, SIGNAL(valueChanged(int)), this, SLOT(setConfigDirty()));
    disconnect(absolutePosY, SIGNAL(valueChanged(int)), this, SLOT(setConfigDirty()));
    if(changes & RandR::ChangeOutputs)
    {
        qDebug() << "Outputs changed.";
    }

    if(changes & RandR::ChangeCrtc)
    {
        qDebug() << "Output CRTC changed.";

        updateSizeList();
        updateRateList();
        updateRotationList();
    }

    if(changes & RandR::ChangeRect)
    {
        QRect r = m_output->rect();
        qDebug() << "Output rect changed:" << r;
        updatePositionList();
    }

    if(changes & RandR::ChangeRotation)
    {
        qDebug() << "Output rotation changed.";
        updateRotationList();
    }

    if(changes & RandR::ChangeConnection)
    {
        qDebug() << "Output connection status changed.";
        setEnabled(m_output->isConnected());
        emit connectedChanged(m_output->isConnected());
    }

    if(changes & RandR::ChangeRate)
    {
        qDebug() << "Output rate changed.";
        updateRateList();
    }

    if(changes & RandR::ChangeMode)
    {
        qDebug() << "Output mode changed.";
        updateSizeList();

        // This NEEDS to be fixed..
        //QSize modeSize = m_output->screen()->mode(m_output->mode()).size();
        QSize modeSize = m_output->mode().size();
        updateRateList(sizeCombo->findData(modeSize));
    }
    connect(absolutePosX, SIGNAL(valueChanged(int)), this, SLOT(setConfigDirty()));
    connect(absolutePosY, SIGNAL(valueChanged(int)), this, SLOT(setConfigDirty()));
}
void BluetoothDevice::propertyChanged(QString name,QDBusVariant value)
{
    qDebug()<<"BluetoothDevice::propertyChanged()";

    if(name == "Connected")
    {
	    emit connectedChanged(value.variant().toBool());
    }

    if(name == "UUIDs")
    {
	    emit profilesChanged(value.variant().toStringList());
		setupProfiles();
    }

    if(name == "Trusted")
    {
        emit trustedChanged(value.variant().toBool());
    }

    if(name == "Paired")
    {
        emit pairedChanged();
    }

    emit propertyChanged(name,value.variant());

    ///TODO: create individual signals for each property... maybe
}
Example #9
0
void CloudConnection::setConnected(const bool &connected)
{
    if (m_connected != connected) {
        m_connected = connected;
        emit connectedChanged();
    }
}
void NetworkTechnology::init(const QString &path)
{
    m_path = path;

    if (m_technology) {
        delete m_technology;
        m_technology = 0;
        // TODO: After resetting the path iterate through old properties, compare their values
        //       with new ones and emit corresponding signals if changed.
        m_propertiesCache.clear();
    }
    m_technology = new Technology("net.connman", path, QDBusConnection::systemBus(), this);

    if (!m_technology->isValid()) {
        pr_dbg() << "Invalid technology: " << path;
        throw -1; // FIXME
    }

    if (m_propertiesCache.isEmpty()) {
        QDBusReply<QVariantMap> reply;
        reply = m_technology->GetProperties();
        m_propertiesCache = reply.value();
    }
    emit poweredChanged(powered());
    emit connectedChanged(connected());

    connect(m_technology,
            SIGNAL(PropertyChanged(const QString&, const QDBusVariant&)),
            this,
            SLOT(propertyChanged(const QString&, const QDBusVariant&)));

}
Example #11
0
void CLSSIS3820Scaler::onConnectedChanged(){
	if(isConnected() && !connectedOnce_) {
		connectedOnce_ = true;
	}

	if(connectedOnce_)
		emit connectedChanged(isConnected());
}
Example #12
0
bool CanInterface::setConnected(bool connect)
{
    if (connect) {
        if (m_canDevice == Q_NULLPTR) {
            if (!createInterface()) {
                emit connectedChanged(false);
                return false;
            }
        }


        // already connected
        if (m_canDevice->state() == QCanBusDevice::ConnectedState ||
            m_canDevice->state() == QCanBusDevice::ConnectingState)
        {
            return true;
        }

        // try to connect
        if (!m_canDevice->connectDevice()) {
            setErrorString( m_canDevice->errorString());
            qCritical() << qPrintable(m_errorString) << endl;

            delete m_canDevice;
            m_canDevice = Q_NULLPTR;
            emit connectedChanged(false);
            return false;
        }

        // an erro might occur in configuration that isnt cauht in another way
        emit connectedChanged(true);

    } else if (m_canDevice != Q_NULLPTR) {
        m_canDevice->disconnect();
        m_canDevice->deleteLater();
        m_canDevice = Q_NULLPTR;
        emit connectedChanged(false);
        clearErrorString();
    }

    return true;
}
Example #13
0
void QApplicationConfig::updateState(QApplicationConfig::State state)
{
    if (state != m_connectionState)
    {
        m_connectionState = state;
        emit connectionStateChanged(m_connectionState);

        if (m_connectionState == Connected)
        {
            if (m_connected != true) {
                m_connected = true;
                emit connectedChanged(true);
            }
        }
        else if (m_connected != false)
        {
            m_connected = false;
            emit connectedChanged(false);
        }
    }
}
Example #14
0
void CangoteCore::setConnected(bool connected)
{
  m_connected = connected;
  if((connected == false) && !m_armConnectTimer->isActive())
    {
      qWarning() << "Starting Gnunet again;";
      m_armConnectTimer->start(4000);
    }
  else if (m_armConnectTimer->isActive())
    {
      m_armConnectTimer->stop();
    }
  emit connectedChanged(m_connected);
}
Example #15
0
void LogindTest::testLogindPresent()
{
    QTest::qWait(100);
    FakeLogind fakeLogind;
    QScopedPointer<LogindIntegration> logindIntegration(new LogindIntegration(QDBusConnection::sessionBus(), this));

    QSignalSpy connectedSpy(logindIntegration.data(), SIGNAL(connectedChanged()));
    QVERIFY(connectedSpy.wait());
    QVERIFY(logindIntegration->isConnected());

    QSignalSpy lockSpy(logindIntegration.data(), SIGNAL(requestLock()));
    fakeLogind.lock();
    QVERIFY(lockSpy.wait());
    QCOMPARE(lockSpy.count(), 1);
}
void OutgoingContactRequest::startConnection()
{
    if (m_client)
        return;

    qDebug() << "Starting outgoing contact request for" << user->uniqueID;

    m_client = new ContactRequestClient(user);

    connect(m_client, SIGNAL(accepted()), SLOT(accept()));
    connect(m_client, SIGNAL(rejected(int)), SLOT(requestRejected(int)));
    connect(m_client, SIGNAL(acknowledged()), SLOT(requestAcknowledged()));
    connect(m_client, SIGNAL(responseChanged()), SIGNAL(connectedChanged()));

    m_client->setMyNickname(myNickname());
    m_client->setMessage(message());
    m_client->sendRequest();
}
void NetworkTechnology::propertyChanged(const QString &name, const QDBusVariant &value)
{
    QVariant tmp = value.variant();

    Q_ASSERT(m_technology);

    m_propertiesCache[name] = tmp;
    if (name == Powered) {
        emit poweredChanged(tmp.toBool());
    } else if (name == Connected) {
        emit connectedChanged(tmp.toBool());
    } else if (name == IdleTimeout) {
      emit idleTimeoutChanged(tmp.toUInt());
    } else if (name == Tethering) {
      emit tetheringChanged(tmp.toBool());
    } else if (name == TetheringIdentifier) {
      emit tetheringIdChanged(tmp.toString());
    } else if (name == TetheringPassphrase) {
      emit tetheringPassphraseChanged(tmp.toString());
    }
}
void QDeclarativeBluetoothSocket::newSocket(QBluetoothSocket *socket, QDeclarativeBluetoothService *service)
{
    if (d->m_socket){
        delete d->m_socket;
    }

    d->m_service = service;
    d->m_socket = socket;
    d->m_connected = true;
    d->m_componentCompleted = true;
    d->m_error = NoError;

    QObject::connect(socket, SIGNAL(connected()), this, SLOT(socket_connected()));
    QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(socket_disconnected()));
    QObject::connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(socket_error(QBluetoothSocket::SocketError)));
    QObject::connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(socket_state(QBluetoothSocket::SocketState)));
    QObject::connect(socket, SIGNAL(readyRead()), this, SLOT(socket_readyRead()));

    socket_state(socket->state());

    emit connectedChanged();
}
void TechnologyModel::doUpdateTechnologies()
{
    NetworkTechnology *newTech = m_manager->getTechnology(m_techname);
    if (m_tech == newTech)
        return;

    bool oldPowered = false;
    bool oldConnected = false;

    if (m_tech) {
        oldPowered = m_tech->powered();
        oldConnected = m_tech->connected();

        disconnect(m_tech, SIGNAL(poweredChanged(bool)), this, SLOT(changedPower(bool)));
        disconnect(m_tech, SIGNAL(connectedChanged(bool)), this, SLOT(changedConnected(bool)));
        disconnect(m_tech, SIGNAL(scanFinished()), this, SLOT(finishedScan()));
    }

    if (m_scanning) {
        m_scanning = false;
        Q_EMIT scanningChanged(m_scanning);
    }

    m_tech = newTech;

    if (m_tech) {
        connect(m_tech, SIGNAL(poweredChanged(bool)), this, SLOT(changedPower(bool)));
        connect(m_tech, SIGNAL(connectedChanged(bool)), this, SLOT(changedConnected(bool)));
        connect(m_tech, SIGNAL(scanFinished()), this, SLOT(finishedScan()));

        bool b = m_tech->powered();
        if (b != oldPowered)
            Q_EMIT poweredChanged(b);
        b = m_tech->connected();
        if (b != oldConnected)
            Q_EMIT connectedChanged(b);
    } else {
        if (oldPowered)
Example #20
0
void LogindTest::testRegisterUnregister()
{
    QTest::qWait(100);
    QScopedPointer<FakeLogind> fakeLogind(new FakeLogind(this));
    QScopedPointer<LogindIntegration> logindIntegration(new LogindIntegration(QDBusConnection::sessionBus(), this));

    // should get connected
    QSignalSpy connectedSpy(logindIntegration.data(), SIGNAL(connectedChanged()));
    QVERIFY(connectedSpy.wait());
    QVERIFY(logindIntegration->isConnected());
    connectedSpy.clear();

    fakeLogind.reset();
    // should no longer be connected
    QVERIFY(connectedSpy.wait());
    QVERIFY(!logindIntegration->isConnected());
    connectedSpy.clear();

    fakeLogind.reset(new FakeLogind(this));
    // should be connected again
    QVERIFY(connectedSpy.wait());
    QVERIFY(logindIntegration->isConnected());
}
Example #21
0
void LogindTest::testLockUnlock()
{
    QScopedPointer<LogindIntegration> logindIntegration(new LogindIntegration(QDBusConnection::sessionBus(), this));
    QSignalSpy lockSpy(logindIntegration.data(), SIGNAL(requestLock()));
    QSignalSpy unlockSpy(logindIntegration.data(), SIGNAL(requestUnlock()));
    QSignalSpy connectedSpy(logindIntegration.data(), SIGNAL(connectedChanged()));

    FakeLogind fakeLogind;

    // need to wait till we got the pending reply
    QVERIFY(connectedSpy.wait());
    QVERIFY(logindIntegration->isConnected());

    fakeLogind.lock();
    QVERIFY(lockSpy.wait());
    fakeLogind.lock();

    QVERIFY(lockSpy.wait());
    QCOMPARE(lockSpy.count(), 2);

    fakeLogind.unlock();
    QVERIFY(unlockSpy.wait());
    QCOMPARE(unlockSpy.count(), 1);
}
Example #22
0
void QDeclarativeBluetoothSocket::socket_connected()
{
    emit connectedChanged();
}
Example #23
0
void QDeclarativeBluetoothSocket::socket_disconnected()
{
    d->m_socket->deleteLater();
    d->m_socket = 0;
    emit connectedChanged();
}
Example #24
0
void ApplicationError::clearConnected()
{
    m_connected = false;
    emit connectedChanged(m_connected);
}
Example #25
0
void ApplicationError::setConnected()
{
    m_connected = true;
    emit connectedChanged(m_connected);
}
Example #26
0
bool CanInterface::createInterface()
{
    if (m_canDevice != Q_NULLPTR) {
        m_canDevice->disconnectDevice();
        m_canDevice->deleteLater();
        m_canDevice = Q_NULLPTR;
        emit connectedChanged(false);
    }

    // find the can plugin
    QSettings settings;
    QString pluginName = settings.value(can_pluginKey, can_defaultPlugin).toString();
    QList<QByteArray> plugins = QCanBus::instance()->plugins();
    int idx = plugins.indexOf(pluginName.toLocal8Bit());
    if (idx == -1) {
        setErrorString("Can't find the CAN plugin: " + pluginName);
        qCritical() << qPrintable(m_errorString.toLocal8Bit()) << endl;
        return false;
    }

    // try to create interface
    QString ifaceName = settings.value(can_interfaceKey, can_defaultInterface).toString();
    m_canDevice =  QCanBus::instance()->createDevice(plugins.at(idx), ifaceName.toLocal8Bit());
    if (m_canDevice == Q_NULLPTR) {
        setErrorString("Can't create device");
        qCritical() << qPrintable(m_errorString) << endl;
        return false;
    }

    // now we have a interface, connect signals
    connect(m_canDevice, &QCanBusDevice::errorOccurred,
            this, &CanInterface::receiveError);
    connect(m_canDevice, &QCanBusDevice::framesReceived,
            this, &CanInterface::checkMessages);
    connect(m_canDevice, &QCanBusDevice::framesWritten,
            this, &CanInterface::framesWritten);


    // This configuration determines the type of CAN bus frames that the current device accepts.
    // The expected value is QList<QCanBusDevice::Filter>.
    // Passing an empty list clears all previously set filters including default filters.
    if (settings.contains(can_rawFilterKey)) {
        if (m_canDevice->configurationKeys().contains(QCanBusDevice::RawFilterKey)) {
            QList<QVariant> rawfilter = settings.value(can_rawFilterKey).toList();
            m_canDevice->setConfigurationParameter(QCanBusDevice::RawFilterKey, rawfilter);
        } else {
            qDebug() << "Cant set RawFilter to interface " <<
                        qPrintable(settings.value(can_interfaceKey, can_defaultInterface).toString().toLocal8Bit()) << endl;
        }
    }

    // QCanBusDevice::ErrorFilterKey	1
    // This key defines the type of error that should be forwarded via the current connection.
    // The associated value should be of type QCanBusFrame::FrameErrors.
    if (settings.contains(can_errorFilterKey)) {
        if (m_canDevice->configurationKeys().contains(QCanBusDevice::ErrorFilterKey)) {
            QList<QVariant> errorfilter = settings.value(can_errorFilterKey).toList();
            m_canDevice->setConfigurationParameter(QCanBusDevice::ErrorFilterKey, errorfilter);
        } else {
            qDebug() << "Cant set ErrorFilter to interface " <<
                        qPrintable(settings.value(can_interfaceKey, can_defaultInterface).toString().toLocal8Bit()) << endl;
        }
    }

    // QCanBusDevice::LoopbackKey	2
    // This key defines whether the CAN bus device should operate in loopback mode.
    // The expected value for this key is bool.
    if (settings.contains(can_loopbackKey) &&
            settings.value(can_interfaceKey, can_defaultInterface).toString() != "vcan0") // we must have loopback on virtual can
    {
        if (m_canDevice->configurationKeys().contains(QCanBusDevice::LoopbackKey)) {
            m_canDevice->setConfigurationParameter(QCanBusDevice::LoopbackKey,
                                                   settings.value(can_loopbackKey).toBool());
        } else {
            qDebug() << "Cant set Loopback to interface " <<
                        qPrintable(settings.value(can_interfaceKey, can_defaultInterface).toString().toLocal8Bit()) << endl;
        }
    }


    // QCanBusDevice::ReceiveOwnKey	3
    // This key defines whether this CAN device can send messages. The expected value for this key is bool.
    if (settings.contains(can_quietModeKey)) {
        if (m_canDevice->configurationKeys().contains(QCanBusDevice::ReceiveOwnKey)) {
            // note that this configuration is inverted from our settings concept
            m_canDevice->setConfigurationParameter(QCanBusDevice::ReceiveOwnKey,
                                                   settings.value(can_quietModeKey).toBool());
        } else {
            qDebug() << "Cant set quietMode to interface " <<
                        qPrintable(settings.value(can_interfaceKey, can_defaultInterface).toString().toLocal8Bit()) << endl;
        }
    }

    // QCanBusDevice::BitRateKey	4
    // This key defines the bitrate in bits per second.
    if (settings.contains(can_bitrateKey)) {
        if ( m_canDevice->configurationKeys().contains(QCanBusDevice::BitRateKey)) {
            m_canDevice->setConfigurationParameter(QCanBusDevice::BitRateKey, settings.value(can_bitrateKey).toInt());
        } else {
            qDebug() << "Cant set Bitrate to interface " <<
                        qPrintable(settings.value(can_interfaceKey, can_defaultInterface).toString().toLocal8Bit()) << endl;
        }
    }

    // QCanBusDevice::CanFdKey	5
    // This key defines whether sending and receiving of CAN FD frames should be enabled.
    // The expected value for this key is bool.
    if (settings.contains(can_fdFramesKey)) {
        if (m_canDevice->configurationKeys().contains(QCanBusDevice::CanFdKey)) {
            m_canDevice->setConfigurationParameter(QCanBusDevice::CanFdKey, settings.value(can_fdFramesKey).toBool());
        } else {
            qDebug() << "Cant set fdFrames to interface " <<
                        qPrintable(settings.value(can_interfaceKey, can_defaultInterface).toString().toLocal8Bit()) << endl;
        }
    }

    return true;
}
Example #27
0
#ifndef Q_OS_MACX
        if (reason == QSystemTrayIcon::DoubleClick ||
            reason == QSystemTrayIcon::Trigger)
        {
            if (win->isHidden())
                mainWindowShow();
            else
                mainWindowHide();
        }
#else
        Q_UNUSED(reason)
#endif
    });

    wsClient = new WSClient(this);
    connect(wsClient, &WSClient::connectedChanged, [=]() { connectedChanged(); });
    connectedChanged();

    win = new MainWindow(wsClient);
    connect(win, &MainWindow::windowCloseRequested, [=]()
    {
        mainWindowHide();
    });
    //start hidden
    mainWindowHide();

    daemonProcess = new QProcess(this);
    QString program = QCoreApplication::applicationDirPath () + "/moolticuted";
    QStringList arguments;
    // TODO handle Debug arguments
    //arguments << "-e" <<  "-s 8080";
Example #28
0
File: client.cpp Project: klpx/jam
void Jam::Client::setConnected(bool value)
{
    connected = value;
    emit connectedChanged();
}