void NjsProcess::onReadyRead() { QByteArray data = this->readAll(); // qDebug() << "read!!!!" << data << "!!!!"; buffer += data; while ( buffer.size() ) { const int start = buffer.indexOf( CHROMECAST_DEVICE_DETECT_HEADER ); if ( start < 0 ) { buffer.clear(); return; } if ( start > 0 ) buffer = buffer.mid( start ); const int end = buffer.indexOf( CHROMECAST_DEVICE_DETECT_FOOTER ); if ( end <= 0 ) return; // qDebug() << "data" << buffer; QString str = buffer.mid( sizeof( CHROMECAST_DEVICE_DETECT_HEADER ) - 1, end - 2 ); const int index = str.indexOf( ": " ); if ( index > 0 && index + 2 < str.size() ) emit haveToken( str.left( index ).toLatin1(), str.mid( index + 2 ).toLatin1() ); // qDebug() << "token" << str.left( index ).toLatin1() << str.mid( index + 2 ).toLatin1(); // qDebug() << "trash" << buffer.mid( 0, end + sizeof( CHROMECAST_DEVICE_DETECT_FOOTER ) + 1 ); buffer = buffer.mid( end + sizeof( CHROMECAST_DEVICE_DETECT_FOOTER ) + 1 ); } }
void MainWindow::login() { oauth = new OAuthN(); oauth->setGeometry(100,0,500,400); //oauth->setParent(this); connect(oauth, SIGNAL(authSuccess(QString,QString)),this, SLOT(getToken(QString, QString))); connect(this,SIGNAL(haveToken()),this, SLOT(loginSuccess())); // FIXME : Change getGroups slot - to Login Succesfull slot acessuble from qml oauth->show(); }
void MainWindow::getToken(QString token, QString expires) { Token = token; Expires = expires; oauth->disconnect(); oauth->hide(); emit haveToken(); WriteConfig("token",token); WriteConfig("expires",expires); WriteConfig("expDate",QDate::currentDate().addDays(1).toString()); }