void SimondConnector::login() { QString user; QString password; if (Settings::publicServer()) { QString shortLangCode; if (Settings::language() == "English") shortLangCode = "EN"; if (Settings::language() == "Deutsch") shortLangCode = "DE"; user = password = "******" + shortLangCode; } else { user = Settings::user(); password = Settings::password(); } qDebug() << "Logging in: " << user << password; QByteArray userBytes = user.toUtf8(); QByteArray passBytes = QCryptographicHash::hash(password.toUtf8(),QCryptographicHash::Sha1); QByteArray body; QDataStream bodyStream(&body, QIODevice::WriteOnly|QIODevice::Unbuffered); bodyStream << (qint8) PROTOCOL_VERSION << userBytes << passBytes; sendRequest(Simond::Login, body); }
QByteArray SoundCard::serialize() { QByteArray body; QDataStream bodyStream(&body, QIODevice::WriteOnly); bodyStream << m_id; bodyStream << m_model; bodyStream << m_type; return body; }
void SimondConnector::commitRecording() { qDebug() << "Committing recording"; emit recognizing(); passThroughSound = false; QByteArray body; QDataStream bodyStream(&body, QIODevice::WriteOnly|QIODevice::Unbuffered); bodyStream << (qint8) 1 /* mic id */; sendRequest(Simond::RecognitionSampleFinished, body, false); }
void SimondConnector::startRecording() { qDebug() << "Starting recording"; emit listening(); QByteArray body; QDataStream bodyStream(&body, QIODevice::WriteOnly|QIODevice::Unbuffered); bodyStream << (qint8) 1 /* mic id */ << mic->channels() << mic->sampleRate(); sendRequest(Simond::RecognitionStartSample, body); passThroughSound = true; }
void SimondConnector::soundDataAvailable() { if (!passThroughSound) { mic->dropCache(); // drop current data return; } QByteArray soundData = mic->readAll(); if (soundData.isEmpty()) return; QByteArray body; QDataStream bodyStream(&body, QIODevice::WriteOnly|QIODevice::Unbuffered); bodyStream << (qint8) 1 /* mic id */ << soundData; sendRequest(Simond::RecognitionSampleData, body); }
QByteArray User::serialize() { QByteArray body; QDataStream bodyStream(&body, QIODevice::WriteOnly); bodyStream << m_userId; bodyStream << m_surname; bodyStream << m_givenName; bodyStream << m_sex; bodyStream << m_birthYear; bodyStream << m_zipCode; bodyStream << m_education; bodyStream << m_currentOccupation; bodyStream << m_motherTongueId; bodyStream << m_motherTongue; bodyStream << m_diagnosis; bodyStream << m_orientation; bodyStream << m_motorFunction; bodyStream << m_communication; bodyStream << m_mouthMotoric; bodyStream << m_interviewPossible; bodyStream << m_repeatingPossible; return body; }
XBOX::VError VRPCService::GetProxy( XBOX::VString& outProxy, const XBOX::VString& inModulePath, const XBOX::VString& inNamespace, const IHTTPRequest* inRequest, IHTTPResponse* inResponse) { VError err = VE_OK; outProxy.Clear(); if (fApplication != NULL) { VRIAContext *riaContext = fApplication->RetainNewContext( err); if (err == VE_OK) { VRPCCatalog *catalog = fApplication->RetainRPCCatalog( riaContext, &err, inRequest, inResponse); if (err == VE_OK) { if (catalog != NULL) { MapOfRPCSchema schemas; err = catalog->RetainSchemasByModule( inModulePath, schemas); if (err == VE_OK) { // Build the proxy VFile *bodyFile = NULL, *templateFile = NULL; VFilePath path; VRIAServerApplication::Get()->GetWAFrameworkFolderPath( path); path.ToSubFolder( L"Core").ToSubFolder( L"Runtime").ToSubFolder( L"rpcService"); path.SetFileName( L"proxy-body.js", true); bodyFile = new VFile( path); if (bodyFile == NULL) err = vThrowError( VE_MEMORY_FULL); if (err == VE_OK) { path.SetFileName( L"proxy-template.js", true); templateFile = new VFile( path); if (templateFile == NULL) err = vThrowError( VE_MEMORY_FULL); } if (err == VE_OK && bodyFile->Exists() && templateFile->Exists()) { VString templateString; VFileStream bodyStream( bodyFile); VFileStream templateStream( templateFile); err = bodyStream.OpenReading(); if (err == VE_OK) templateStream.OpenReading(); if (err == VE_OK) err = bodyStream.GetText( outProxy); if (err == VE_OK) { VValueBag bag; bag.SetString( L"rpc-pattern", fPatternForMethods); bag.SetString( L"publishInGlobalNamespace", (fPublishInClientGlobalNamespace) ? L"true" : L"false"); outProxy.Format( &bag); } if (err == VE_OK) err = templateStream.GetText( templateString); if (err == VE_OK) { if (templateString.BeginsWith( L"/*")) { // sc 28/08/2014, remove the copyright VIndex end = templateString.Find( L"*/"); if (end > 0) { templateString.Remove( 1, end + 1); } } for (MapOfRPCSchema::const_iterator iter = schemas.begin() ; iter != schemas.end() ; ++iter) { VValueBag bag; bag.SetString( L"function-name", iter->first.GetMethodName()); bag.SetString( L"namespace", inNamespace); bag.SetString( L"modulePath", inModulePath); VString proxy( templateString); proxy.Format( &bag); outProxy.AppendString( proxy); } } bodyStream.CloseReading(); templateStream.CloseReading(); } else { err = vThrowError( VE_FILE_NOT_FOUND); } QuickReleaseRefCountable( bodyFile); QuickReleaseRefCountable( templateFile); } } else { err = vThrowError( VE_RIA_RPC_CATALOG_NOT_FOUND); } } } ReleaseRefCountable( &riaContext); } return err; }