void FtpClient::handleReadyRead() { qDebug() << "FtpClient:: " << port << " handleReadyRead, available bytes" << tcpSocket->bytesAvailable(); emit deviceStateChanged(DeviceManager::ReadingState); mInBuffer = tcpSocket->readAll(); emit deviceStateChanged(DeviceManager::ReadState); if (mReceivingPicture) // if we are waiting for pisture data { qDebug() << "FtpClient:: " << port << " handleReadyRead, receiving picture data"; if (mProsesedCommand.getImageSize() > mProsesedCommand.getImageData().size()) { // and size of inbuffer is what we wait qDebug() << "FtpClient:: " << port << " handleReadyRead, missing before read" << mProsesedCommand.getImageSize() - mProsesedCommand.getImageData().size(); mProsesedCommand.addImageData(mInBuffer); if (mProsesedCommand.getImageSize() <= mProsesedCommand.getImageData().size()) { qDebug() << "FtpClient:: " << port << " handleReadyRead, all picture data read"; emit commandProsessed(mProsesedCommand); mReceivingPicture = false; if (mCameraOn) { qDebug() << "FtpClient:: " << port << " handleReadyRead, ask next picture"; sendCommand(mPictureCommand); } } else { qDebug() << "FtpClient:: " << port << " handleReadyRead, missing after read" << mProsesedCommand.getImageSize() - mProsesedCommand.getImageData().size(); } } else { qDebug() << "FtpClient:: " << port << " handleReadyRead, error in reading picture data, too much data got"; emit commandProsessed(mProsesedCommand); mReceivingPicture = false; } } else { qDebug() << "FtpClient:: " << port << " handleReadyRead reading normal command: " << mInBuffer; mProsesedCommand = Command(mInBuffer); if (mProsesedCommand.getCommand() == Command::Picture) { qDebug() << "FtpClient:: " << port << " handleReadyRead started receiving picture"; mReceivingPicture = true; } else { qDebug() << "FtpClient:: " << port << " handleReadyRead Command" << mProsesedCommand.toString(); emit commandProsessed(mProsesedCommand); } } }
void BluetoothImpl::initialize() { if ( !netSpace ) { //initialize the value space for this interface QByteArray path("/Network/Interfaces/"+ QByteArray::number(qHash(configIface->configFile())) ); netSpace = new QValueSpaceObject( path, this ); netSpace->setAttribute( QLatin1String("Config"), configIface->configFile() ); netSpace->setAttribute( QLatin1String("State"), QtopiaNetworkInterface::Unknown ); netSpace->setAttribute( QLatin1String("Error"), QtopiaNetworkInterface::NotInitialized ); netSpace->setAttribute( QLatin1String("ErrorString"), tr("Interface hasn't been initialized yet.") ); netSpace->setAttribute( QLatin1String("NetDevice"), QVariant() ); netSpace->setAttribute( QLatin1String("BtDevice"), QVariant() ); netSpace->setAttribute( QLatin1String("UpdateTrigger"), 0 ); } if ( !dialupDev ) { dialupDev = new BluetoothDialupDevice( this ); connect( dialupDev, SIGNAL(deviceStateChanged()), this, SLOT(updateState()) ); connect( dialupDev, SIGNAL(connectionEstablished()), this, SLOT(serialPortConnected()) ); } if ( isAvailable() ) { ifaceStatus = Down; } else { ifaceStatus = Unavailable; } netSpace->setAttribute( QLatin1String("State"), ifaceStatus ); updateTrigger(); }
virtual OniStatus initialize( oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) { oni::driver::DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); // Open Kinect v2 auto hr = ::GetDefaultKinectSensor( &kinect_ ); if ( FAILED( hr ) ) { return ONI_STATUS_NO_DEVICE; } hr = kinect_->Open(); if (FAILED(hr)) { std::cerr << "IKinectSensor::Open() failed." << std::endl; return ONI_STATUS_ERROR; } // Create device info OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo); xnOSStrCopy(pInfo->vendor, "Microsoft", ONI_MAX_STR); xnOSStrCopy(pInfo->name, "Kinect V2 Developer Preview", ONI_MAX_STR); xnOSStrCopy(pInfo->uri, "Kinect V2", ONI_MAX_STR); // internal connect device deviceConnected(pInfo); deviceStateChanged(pInfo, 0); return ONI_STATUS_OK; }
void FtpClient::handleDisconnected() { emit deviceStateChanged(DeviceManager::UnconnectedState); mConnected = false; mConnecting = false; qDebug() << "FtpClient:: " << port << " handleDisconnected"; };
void FtpClient::handleSessionOpened() { qDebug() << "FtpClient:: " << port << " sessionOpened()"; emit deviceStateChanged(DeviceManager::ConnectingState); tcpSocket->connectToHost(QHostAddress(ipAddress), port); }
void FtpClient::handleError(QAbstractSocket::SocketError socketError) { qDebug() << "FtpClient:: " << port << " handleError()"; switch (socketError) { case QAbstractSocket::RemoteHostClosedError: qDebug() << tr("RemoteHostClosedError"); break; case QAbstractSocket::HostNotFoundError: qDebug() << tr("The host was not found. Please check the " "host name and port settings."); break; case QAbstractSocket::ConnectionRefusedError: qDebug() << tr("The connection was refused by the peer. " "Make sure the Wall-E server is running, " "and check that the host name and port " "settings are correct."); break; case QAbstractSocket::NetworkError: qDebug() << tr("An error occurred with the network. " "Host unreachable."); default: qDebug() << tr("The following error occurred: %1 %2.") .arg(tcpSocket->errorString(), QString::number(socketError)); } // emit error emit deviceStateChanged(DeviceManager::ErrorState); emit deviceError(socketError); }
void FtpClient::handleStateChanged ( QAbstractSocket::SocketState socketState ) { qDebug() << "FtpClient:: " << port << " handleStateChanged"; switch (socketState) { case QAbstractSocket::UnconnectedState: qDebug() << tr("UnconnectedState: The socket is not connected."); emit deviceStateChanged(DeviceManager::UnconnectedState); qDebug() << tr("UnconnectedState: handleRequests()"); mConnected = false; mTransferring = false; qDebug() << "FtpClient:: " << port << " handleStateChanged mTransferring " << mTransferring; handleRequests(); // reconnect if we have something to send break; case QAbstractSocket::HostLookupState: qDebug() << tr("HostLookupState: The socket is performing a host name lookup."); emit deviceStateChanged(DeviceManager::UnconnectedState); break; case QAbstractSocket::ConnectingState: qDebug() << tr("ConnectingState: The socket has started establishing a connection."); emit deviceStateChanged(DeviceManager::ConnectingState); break; case QAbstractSocket::ConnectedState: qDebug() << tr("ConnectedState: A connection is established."); emit deviceStateChanged(DeviceManager::ConnectedState); break; case QAbstractSocket::BoundState: qDebug() << tr("BoundState: The socket is bound to an address and port (for servers)."); break; case QAbstractSocket::ClosingState: qDebug() << tr("ClosingState: The socket is about to close (data may still be waiting to be written)."); emit deviceStateChanged(DeviceManager::ClosingState); break; case QAbstractSocket::ListeningState: qDebug() << tr("ListeningState (For internal use only.)"); break; default: qDebug() << tr("Unknown socket state"); break; } }
void register_uri(std::string uri) { OniDeviceInfo info; strncpy(info.uri, uri.c_str(), ONI_MAX_STR); strncpy(info.vendor, "Microsoft", ONI_MAX_STR); //strncpy(info.name, "Kinect 2", ONI_MAX_STR); // XXX, NiTE does not accept new name strncpy(info.name, "Kinect", ONI_MAX_STR); if (devices.find(info) == devices.end()) { WriteMessage("Driver: register new uri: " + uri); devices[info] = NULL; deviceConnected(&info); deviceStateChanged(&info, 0); } }
void FtpClient::handleBytesWritten( qint64 bytes ) { qDebug() << "FtpClient:: " << port << " handleBytesWritten bytes " << bytes << "mOutBuffer.size() " << mOutBuffer.size(); if (bytes <= mOutBuffer.size()) mOutBuffer.remove(0,bytes); else mOutBuffer.clear(); if (mOutBuffer.size() == 0) { mTransferring = false; qDebug() << "FtpClient:: " << port << " handleBytesWritten mTransferring " << mTransferring; emit deviceStateChanged(DeviceManager::WrittenState); } else { handleRequests(); } }
bool QNetworkManagerInterfaceDevice::setConnections() { if(!isValid() ) return false; bool allOk = false; nmDBusHelper = new QNmDBusHelper(this); connect(nmDBusHelper,SIGNAL(pathForStateChanged(const QString &, quint32)), this, SIGNAL(stateChanged(const QString&, quint32))); if(QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE), d->path, QLatin1String(NM_DBUS_INTERFACE_DEVICE), QLatin1String("StateChanged"), nmDBusHelper,SLOT(deviceStateChanged(quint32)))) { allOk = true; } return allOk; }
void FtpClient::handleRequests() { qDebug() << "FtpClient:: " << port << " handleRequests mInitiated" << mInitiated << " mConnected " << mConnected << " mConnecting " << mConnecting << " mTransferring " << mTransferring << " mOutBuffer.size() " << mOutBuffer.size(); if (!mInitiated) init(); if ((!mConnected) && (!mConnecting)) connectServer(); if (!mTransferring && (mOutBuffer.size() > 0) && mInitiated && mConnected) { qDebug() << "FtpClient:: " << port << " handleRequests size" << mOutBuffer.size() << " " << mOutBuffer; emit deviceStateChanged(DeviceManager::WritingState); mTransferring = true; qDebug() << "FtpClient:: " << port << " handleRequests mTransferring " << mTransferring; tcpSocket->write(mOutBuffer); } }
OniStatus initialize(oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) { DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); for (int i = 0; i < Freenect::deviceCount(); i++) { std::string uri = "freenect://" + to_string(i); WriteMessage("Found device " + uri); OniDeviceInfo info; strncpy(info.uri, uri.c_str(), ONI_MAX_STR); strncpy(info.vendor, "Microsoft", ONI_MAX_STR); strncpy(info.name, "Kinect", ONI_MAX_STR); devices[info] = NULL; deviceConnected(&info); deviceStateChanged(&info, 0); } return ONI_STATUS_OK; }
// Initialize the driver // ドライバを初期化する virtual OniStatus initialize( oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) { oni::driver::DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); // Connect to the DepthSense device // DepthSense デバイスに接続する m_context = DepthSense::Context::create("localhost"); // Enumerate the connected devices // 接続されているデバイスの情報を作成する m_depthSenseDevices = m_context.getDevices(); int deviceIndex = 0; for ( auto it = m_depthSenseDevices.begin(); it != m_depthSenseDevices.end(); ++it ) { // Populate the device information // デバイス情報をコピーする OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo); xnOSStrCopy(pInfo->vendor, "DepthSense", ONI_MAX_STR); xnOSStrCopy(pInfo->name, DepthSense::Device::Model_toString( it->getModel() ).c_str(), ONI_MAX_STR); XnUInt32 uriLen; xnOSStrFormat(pInfo->uri, ONI_MAX_STR, &uriLen, "%s/%d", pInfo->name, deviceIndex++); // Register the device information with the map // デバイス情報を登録する m_devices[pInfo] = NULL; // Raise events // デバイスの接続を通知する deviceConnected(pInfo); deviceStateChanged(pInfo, 0); } // Create the thread for main loop // デバイスのメインループ用スレッドを生成する xnOSCreateThread(threadFunc, this, &m_threadHandle); return ONI_STATUS_OK; }
void FtpClient::handleConnected() { emit deviceStateChanged(DeviceManager::ConnectedState); mConnected = true; mConnecting = false; mTransferring = false; qDebug() << "FtpClient:: " << port << " handleConnected mTransferring " << mTransferring; //request(QString(REQUEST_WHO).arg(QString::number(mOutCommandNumber++))); // ask picture if camera is on, and output buffer is empty // test //sendCommand(Command("", -1, Command::Stop)); if (mCameraOn && (mOutBuffer.size() == 0)) { sendCommand(Command("", -1, Command::Picture)); } else // else handle requests we have { handleRequests(); } }
void FtpClient::handleProxyAuthenticationRequired ( const QNetworkProxy & proxy, QAuthenticator * authenticator ) { qDebug() << "FtpClient:: " << port << " handleProxyAuthenticationRequired"; emit deviceStateChanged(DeviceManager::ErrorState); emit deviceError(QAbstractSocket::ProxyAuthenticationRequiredError); };
void FtpClient::handleHostFound() { qDebug() << "FtpClient:: " << port << " handleHostFound"; emit deviceStateChanged(DeviceManager::ErrorState); emit deviceError(QAbstractSocket::HostNotFoundError); };