void OAuth::authorizationReceivedToken(QString url) { QUrl tmp(url); QUrl mUrl("?" + tmp.fragment()); // all info is in fragment, we have to transform it to be able to read // if you sent State, expect it! if (!m_state.isEmpty()) if (QString(mUrl.queryItemValue(OAUTH_STATE)) == QString(m_state)) { qDebug() << "[OAuth.onAuthorizationReceived] State did not match! Received: " << mUrl.queryItemValue(OAUTH_STATE); // TODO emit signal with error! return; } if (mUrl.queryItemValue(OAUTH_ACCESS_TOKEN).size() == 0) { return; } if (mUrl.queryItemValue(OAUTH_EXPIRES_IN).size() == 0) { return; } if (mUrl.queryItemValue(OAUTH_TOKEN_TYPE).size() == 0) { return; } // in some cases refresh token will not be received /*if (mUrl.queryItemValue(OAUTH_REFRESH_TOKEN).size() == 0) { return; }*/ setAccessToken(mUrl.queryItemValue(OAUTH_ACCESS_TOKEN)); setExpiresIn(mUrl.queryItemValue(OAUTH_EXPIRES_IN).toInt()); setTokenType(mUrl.queryItemValue(OAUTH_TOKEN_TYPE)); setRefreshToken(mUrl.queryItemValue(OAUTH_REFRESH_TOKEN)); setCode(mUrl.queryItemValue(OAUTH_CODE)); settingsSaveCode(code()); settingsSaveAccessToken(accessToken()); settingsSaveRefreshToken(refreshToken()); // Not considered important? if (mUrl.queryItemValue(OAUTH_ACCOUNT_USERNAME).size() > 0) { setAccountUsername(mUrl.queryItemValue(OAUTH_ACCOUNT_USERNAME)); settingsSaveUsername(accountUsername()); } setIsLinked(true); emit closeBrowser(); m_running = false; }
Token Lexer::lex() { skipSpaces(); // skips the white space that it quite likely (indentation) infront of the Token Token currentToken; currentToken.type = tokNotSet; // not really needed currentToken.look = ""; currentToken.value = 0; currentToken.start.row = row; currentToken.start.col = col; QChar currentChar = getChar(); if ( inputStream->atEnd() ) { kdDebug(0)<<"Lexer::lex(), got EOF."<<endl; currentToken.type = tokEOF; currentToken.look = "EOF"; ungetChar(currentChar); // unget the currentChar and fix the row/col values return currentToken; } if (currentChar == '#') { while ( !inputStream->atEnd() && !(currentChar == '\x0a' || currentChar == '\n') ) currentChar = getChar(); } // if (currentChar.category() == QChar::Separator_Line) somehow doesnt work if (currentChar == '\x0a' || currentChar == '\n') { currentToken.type = tokEOL; currentToken.look = "EOL"; } else if (currentChar.isLetter() || currentChar == '[' || currentChar == ']') { ungetChar(currentChar); // sets currentToken.look by reference, and set the currentToken.type to tokUnknown currentToken.type = getWord(currentToken.look); setTokenType(currentToken); // gets the actual tokenType } else if ( currentChar.isNumber() ) { ungetChar(currentChar); // set currentToken.value/look by reference, and set the currentToken.type to tokNumber currentToken.type = getNumber(currentToken.value, currentToken.look); } else if (currentChar == '>') { currentChar = getChar(); if (currentChar == '=') { currentToken.type = tokGe; currentToken.look = ">="; } else { ungetChar(currentChar); currentToken.type = tokGt; currentToken.look = ">"; } } else if (currentChar == '<') { currentChar = getChar(); if ( currentChar == '=' ) { currentToken.type = tokLe; currentToken.look = "<="; } else { ungetChar(currentChar); currentToken.type = tokLt; currentToken.look = ">"; } } else if (currentChar == '!') { currentChar = getChar(); if (currentChar == '=') { currentToken.type = tokNe; currentToken.look = "!="; } else { ungetChar(currentChar); currentToken.type = tokNot; currentToken.look = "!"; } } else if (currentChar == '=') { currentChar = getChar(); if (currentChar == '=') { currentToken.type = tokEq; currentToken.look = "=="; } else { ungetChar(currentChar); currentToken.type = tokAssign; currentToken.look = "="; } } else if (currentChar == '(') { currentToken.type = tokBraceOpen; currentToken.look = "("; } else if (currentChar == ')') { currentToken.type = tokBraceClose; currentToken.look = ")"; } else if (currentChar == '+') { currentToken.type = tokPlus; currentToken.look = "+"; } else if (currentChar == '-') { currentToken.type = tokMinus; currentToken.look = "-"; } else if (currentChar == '*') { currentToken.type = tokMul; currentToken.look = "*"; } else if (currentChar == '/') { currentToken.type = tokDev; currentToken.look = "/"; } else if (currentChar == ',') { currentToken.type = tokComma; currentToken.look = ","; } else if (currentChar == '"') { getString(currentToken); } else { currentToken.type = tokUnknown; currentToken.look = currentChar; } currentToken.end.row = row; currentToken.end.col = col; return currentToken; }