/*! Connect to the configured port and host for the device and setting up the socket. */ void DeviceConnector::connect() { if ( mSocket ) // already connected return; emit startingConnect(); loginDone = false; mSocket = new QTcpSocket(); QObject::connect( mSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError()) ); mSocket->connectToHost( QHostAddress( "10.10.10.20" ), 4245 ); if ( !mSocket->waitForConnected() ) { emit deviceConnMessage( tr( "Error connecting to device:" ) + mSocket->errorString() ); delete mSocket; mSocket = 0; return; } QObject::connect( mSocket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()) ); QObject::connect( mSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()) ); emit deviceConnMessage( tr( "Device connected" ) ); emit finishedConnect(); }
/*! Construct a new \c PackageScanner object, which will scan the \a dir directory, when the refresh() call is made. */ PackageScanner::PackageScanner( const QString &dir, QObject *parent ) : QAbstractListModel( parent ) , mDir( dir ) , mScanner( 0 ) , mConnector( 0 ) { refresh(); mConnector = new DeviceConnector(); QObject::connect( mConnector, SIGNAL(finishedConnect()), this, SLOT(connectorComplete()) ); QObject::connect( mConnector, SIGNAL(deviceConnMessage(QString)), this, SIGNAL(progressMessage(QString)) ); QObject::connect( mConnector, SIGNAL(sendProgress(int)), this, SIGNAL(progressValue(int)) ); }