/***************************************************************************************************** * setIF -> seta token if * ****************************************************************************************************/ void IFElse::setIF(TokenType *_if){ setClasse(_if->getClasse()); setToken(_if->getToken()); setColumn(_if->getColumn()); setLine(_if->getLine()); setType(_if->getType()); }
/***************************************************************************************************** * setEach -> seta o token each * ****************************************************************************************************/ void Each::setEach(TokenType *each){ setClasse(each->getClasse()); setToken(each->getToken()); setColumn(each->getColumn()); setLine(each->getLine()); setType(each->getType()); }
/***************************************************************************************************** * setList -> seta informaçoes da lista * ****************************************************************************************************/ void TList::setList(TokenType *list){ setClasse(list->getClasse()); setToken(list->getToken()); setLine(list->getLine()); setColumn(list->getColumn()); setType(list->getType()); }
void Utils::resetAuthorization() { setCustomerKey(""); setCustomerSecret(""); setToken(""); setTokenSecret(""); setName(""); }
void Scanner::setHashBang(const char *rawText, int rawLeng, int type) { if (m_type & ReturnAllTokens) { setToken(rawText, rawLeng); } else { m_token->setText("", 0); incLoc(rawText, rawLeng, type); } }
void O1::unlink() { trace() << "O1::unlink"; if (linked()) { setToken(""); setTokenSecret(""); emit linkedChanged(); } emit linkingSucceeded(); }
int ONVIF::VideoSourceConfiguration::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 5) qt_static_metacall(this, _c, _id, _a); _id -= 5; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 5) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 5; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = token(); break; case 1: *reinterpret_cast< QString*>(_v) = name(); break; case 2: *reinterpret_cast< int*>(_v) = useCount(); break; case 3: *reinterpret_cast< QString*>(_v) = sourceToken(); break; case 4: *reinterpret_cast< QRect*>(_v) = bounds(); break; default: break; } _id -= 5; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setToken(*reinterpret_cast< QString*>(_v)); break; case 1: setName(*reinterpret_cast< QString*>(_v)); break; case 2: setUseCount(*reinterpret_cast< int*>(_v)); break; case 3: setSourceToken(*reinterpret_cast< QString*>(_v)); break; case 4: setBounds(*reinterpret_cast< QRect*>(_v)); break; default: break; } _id -= 5; } else if (_c == QMetaObject::ResetProperty) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 5; } else if (_c == QMetaObject::RegisterPropertyMetaType) { if (_id < 5) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 5; } #endif // QT_NO_PROPERTIES return _id; }
Server::Server(const char *name, const char *password, const char *proxyHost, unsigned short int port) { hostPort = port; host = proxyHost; if (SDLNet_Init() == -1) { logger("%s", "Fatal error SDLnet_Init faill"); exit(0); } setToken(name, password); }
Server::Server(const char *name, const char *password) { hostPort = 80; host = "fspo.segrys.ru"; if (SDLNet_Init() == -1) { logger("%s", "Fatal error SDLnet_Init faill"); exit(0); } setToken(name, password); }
int ZhongCai::ZhongCaiYiShiAddToken() { setToken(0, token[0]+1); GameInfo game_info; Coder::tokenNotice(id, 0, token[0], game_info); engine->sendMessage(-1, MSG_GAME, game_info); return GE_SUCCESS; }
int GeDou::NianDan(int step, int playerID) { int ret; if(playerID != id || token[0] == tokenMax[0]){ return GE_SUCCESS; } //满足发动条件,询问客户端是否发动 CommandRequest cmd_req; Coder::askForSkill(id, NIAN_DAN, cmd_req); //有限等待,由UserTask调用tryNotify唤醒 if(engine->waitForOne(id, network::MSG_CMD_REQ, cmd_req)) { void* reply; if (GE_SUCCESS == (ret = engine->getReply(id, reply))) { Respond* respond = (Respond*) reply; //发动 if(respond->args(0)==1) { int dstID = respond->dst_ids(0); PlayerEntity * dstPlayer = engine->getPlayerEntity(dstID); network::SkillMsg skill; Coder::skillNotice(id, dstID, NIAN_DAN, skill); engine->sendMessage(-1, MSG_SKILL, skill); setToken(0, token[0]+1); GameInfo game_info; Coder::tokenNotice(id, 0, token[0], game_info); engine->sendMessage(-1, MSG_GAME, game_info); if(dstPlayer->getCrossNum()==0) { HARM selfHarm; selfHarm.srcID = id; selfHarm.point = token[0]; selfHarm.type = HARM_MAGIC; selfHarm.cause = NIAN_DAN; engine->setStateTimeline3(id, selfHarm); } HARM harm; harm.srcID = id; harm.point = 1; harm.type = HARM_MAGIC; harm.cause = NIAN_DAN; engine->setStateTimeline3(dstID, harm); return GE_URGENT; } //没发动技能 return GE_SUCCESS; } return ret; } else{ //超时啥都不用做 return GE_TIMEOUT; } }
ReceivedQunIMJoinRequest & ReceivedQunIMJoinRequest::operator =( const ReceivedQunIMJoinRequest & rhs ) { externalID = rhs.getExtID(); sender = rhs.getSender(); type = rhs.getType(); message = rhs.getMessage(); commander = rhs.getCommander(); setCode(rhs.getCode(), rhs.getCodeLength()); setToken(rhs.getToken(), rhs.getTokenLength()); return *this; }
string lexicalAnalyzer::getLexeme() { char currentChar; string lex = ""; errorCount = 0; int cs = 0; //currentState string newLexemeValue; tokenType newLexemeType; for( int i = 0; i < lines.size(); i++ ) { lineCount = i; cout << lineCount + 1 << ": " << lines[i]; for( int j = 0; j < lines[i].length(); j++ ) { pos = j; currentChar = lines[i][j]; cs = state( cs, currentChar ); //cout << "\nTHIS IS THE CURRENT STATE " << cs << "\n"; if( !( isspace( currentChar ) ) && !newLex(cs) ) lex += currentChar; if(isAccepting( cs ) ){ if( cs == -1 ) { lex = currentChar; cout << "Error at " << lineCount + 1 << ", " << pos + 1 << ": invalid character found: " << currentChar << endl; errorCount++; } newLexemeValue = lex; newLexemeType = getToken( cs, lex); cout << "\t" << setToken(newLexemeType) << "\t" << newLexemeValue << endl; lex = ""; if(newLex(cs) && j < lines[i].size() -1 ) j--; cs = 0; } } } cout << errorCount << " errors found in the input file." << endl; }
int ZhongCai::PanJueTianPing(Action* action) { // 消耗能量 if (crystal > 0) setCrystal(crystal-1); else setGem(gem-1); // +1审判 setToken(0, token[0]+1); SkillMsg skill_msg; Coder::skillNotice(id, id, PAN_JUE_TIAN_PING, skill_msg); engine->sendMessage(-1, MSG_SKILL, skill_msg); GameInfo game_info; Coder::energyNotice(id, gem, crystal, game_info); Coder::tokenNotice(id, 0, token[0], game_info); if (action->args(0) == 0) { vector<int> hands; list<int>::iterator hand_card_it; for (hand_card_it=handCards.begin(); hand_card_it!=handCards.end(); ++hand_card_it) hands.push_back(*hand_card_it); // 弃光手牌 engine->setStateMoveCardsNotToHand(id, DECK_HAND, -1, DECK_DISCARD, handCards.size(), hands, id, PAN_JUE_TIAN_PING, false); } else { // 摸满手牌 if (handCardsMax > handCards.size()) { vector<int> cards; HARM tianping; tianping.cause = PAN_JUE_TIAN_PING; tianping.point = handCardsMax-handCards.size(); tianping.srcID = id; tianping.type = HARM_NONE; engine->setStateMoveCardsToHand(-1, DECK_PILE, id, DECK_HAND, handCardsMax-handCards.size(), cards, tianping, false); } // 战绩区+1宝石 TeamArea* team_area = engine->getTeamArea(); team_area->setGem(color, team_area->getGem(color)+1); Coder::stoneNotice(color, team_area->getGem(color), team_area->getCrystal(color), game_info); } engine->sendMessage(-1, MSG_GAME, game_info); return GE_URGENT; }
int ZhongCai::ShenPanLangChao() { SkillMsg skill_msg; Coder::skillNotice(id, id, SHEN_PAN_LANG_CHAO, skill_msg); engine->sendMessage(-1, MSG_SKILL, skill_msg); setToken(0, token[0]+1); GameInfo game_info; Coder::tokenNotice(id, 0, token[0], game_info); engine->sendMessage(-1, MSG_GAME, game_info); return GE_SUCCESS; }
int HongLian::XingHongShiZi(int &step, Action* action) { GameInfo game_info; vector<int> cards; int i; for (i = 0; i < action->card_ids_size(); ++i) cards.push_back(action->card_ids(i)); SkillMsg skill_msg; Coder::skillNotice(id, action->dst_ids(0), XING_HONG_SHI_ZI, skill_msg); engine->sendMessage(-1, MSG_SKILL, skill_msg); CardMsg show_card; Coder::showCardNotice(id, 2, cards, show_card); engine->sendMessage(-1, MSG_CARD, show_card); if(crystal>0) { setCrystal(--crystal); } else { setGem(--gem); } Coder::energyNotice(id, gem, crystal, game_info); engine->sendMessage(-1, MSG_GAME, game_info); setToken(0,--token[0]); Coder::tokenNotice(id, 0, getToken(0), game_info); engine->sendMessage(-1, MSG_GAME, game_info); HARM selfHarm; selfHarm.cause = XING_HONG_SHI_ZI; selfHarm.point = 4; selfHarm.srcID = id; selfHarm.type = HARM_MAGIC; HARM harm; harm.cause = XING_HONG_SHI_ZI; harm.point = 3; harm.srcID = id; harm.type = HARM_MAGIC; engine->setStateTimeline3(action->dst_ids(0), harm); engine->setStateTimeline3(id, selfHarm); engine->setStateMoveCardsNotToHand(id, DECK_HAND, -1, DECK_DISCARD, cards.size(), cards, id, XING_HONG_SHI_ZI, true); return GE_URGENT; }
void O2Gft::onTokenReplyFinished() { qDebug() << "O2Gft::onTokenReplyFinished"; QNetworkReply *tokenReply = qobject_cast<QNetworkReply *>(sender()); if (tokenReply->error() == QNetworkReply::NoError) { QByteArray replyData = tokenReply->readAll(); QScriptEngine engine; QScriptValueIterator it(engine.evaluate("(" + QString(replyData) + ")")); QVariantMap tokens; while (it.hasNext()) { it.next(); tokens.insert(it.name(), it.value().toVariant()); } // Check for mandatory tokens if (tokens.contains(O2_OAUTH2_ACCESS_TOKEN)) { setToken(tokens.take(O2_OAUTH2_ACCESS_TOKEN).toString()); // setIdToken(tokens.take(O2_OAUTH2_ID_TOKEN).toString()); // bool ok = false; int expiresIn = tokens.take(O2_OAUTH2_EXPIRES_IN).toInt(&ok); if (ok) { qDebug() << "Token expires in" << expiresIn << "seconds"; setExpires(QDateTime::currentMSecsSinceEpoch() / 1000 + expiresIn); } setRefreshToken(tokens.take(O2_OAUTH2_REFRESH_TOKEN).toString()); // Set extra tokens if any if (!tokens.isEmpty()) { setExtraTokens(tokens); } timedReplies_.remove(tokenReply); emit linkedChanged(); emit tokenChanged(); emit linkingSucceeded(); } else { qWarning() << "O2::onTokenReplyFinished: oauth_token missing from response" << replyData; emit linkedChanged(); emit tokenChanged(); emit linkingFailed(); } } tokenReply->deleteLater(); }
int HongLian::ShaLuShengYan(CONTEXT_TIMELINE_2_HIT *con) { int ret = GE_SUCCESS; int srcID = con->attack.srcID; int dstID = con->attack.dstID; GameInfo update_info; if(srcID != id || !con->attack.isActive || 0 == token[0]){ return GE_SUCCESS; } //满足发动条件,询问客户端是否发动 CommandRequest cmd_req; Coder::askForSkill(id, SHA_LU_SHENG_YAN, cmd_req); //有限等待,由UserTask调用tryNotify唤醒 if(engine->waitForOne(id, network::MSG_CMD_REQ, cmd_req)) { void* reply; if (GE_SUCCESS == (ret = engine->getReply(srcID, reply))) { Respond* respond = (Respond*) reply; //发动 if(respond->args(0) == 1){ network::SkillMsg skill; Coder::skillNotice(id, dstID, SHA_LU_SHENG_YAN, skill); engine->sendMessage(-1, MSG_SKILL, skill); con->harm.point += 2; setToken(0,--token[0]); Coder::tokenNotice(id, 0, getToken(0), update_info); engine->sendMessage(-1, MSG_GAME, update_info); HARM selfHarm; selfHarm.cause = SHA_LU_SHENG_YAN; selfHarm.point = 4; selfHarm.srcID = id; selfHarm.type = HARM_MAGIC; engine->setStateTimeline3(id, selfHarm); return GE_URGENT; } } return ret; } else{ //超时啥都不用做 return GE_TIMEOUT; } }
void TokenManager::disconnect() { setToken(QString()); // We need to remove the cache TODO: move this as independant of app names ? QString sharePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); if (!sharePath.contains(QCoreApplication::instance()->applicationName())) { return; } if (!sharePath.contains(QCoreApplication::instance()->organizationName())) { return; } QDir dataDir (sharePath); dataDir.removeRecursively(); }
void newsoul::DistributedSocket::initiateActiveWithIP(const std::string & user, const std::string & ip, uint port) { setUser(user); setToken(newsoul()->token()); NNLOG("newsoul.distrib.debug", "Initiating active distributed connection to %s (type %s, ip %s, port %d).", user.c_str(), type().c_str(), ip.c_str(), port); HInitiate handshake(newsoul()->server()->username(), type(), token()); sendMessage(handshake.make_network_packet()); cannotConnectEvent.connect(this, & DistributedSocket::onCannotConnectActive); if((ip == "0.0.0.0") || (port == 0)) { cannotConnectEvent(this); return; } connect(ip, port); }
//Got credentials back, store if necessary void SkynetClient::processReady(char *data, jsmntok_t *tok) { DBGCSN("Skynet Connect"); char temp[UUIDSIZE]; status = 1; getUuid(temp); //if uuid has been refreshed, save it if (!TOKEN_STRING(data, tok[13], temp )) { DBGCSN("uuid refresh"); strncpy(temp, data + tok[13].start, tok[13].end - tok[13].start); DBGCS("new: "); DBGCN(temp); setUuid(temp); }else { DBGCSN("no uuid refresh necessary"); } getToken(temp); //if token has been refreshed, save it if (!TOKEN_STRING(data, tok[15], temp )) { DBGCSN("token refresh"); strncpy(temp, data + tok[15].start, tok[15].end - tok[15].start); DBGCS("new: "); DBGCN(temp); setToken(temp); }else { DBGCSN("no token refresh necessary"); } }
int ZhongCai::MoRiShenPan(Action* action) { SkillMsg skill_msg; Coder::skillNotice(id, id, MO_RI_SHEN_PAN, skill_msg); engine->sendMessage(-1, MSG_SKILL, skill_msg); HARM shenpan; shenpan.cause = MO_RI_SHEN_PAN; shenpan.point = token[0]; shenpan.srcID = id; shenpan.type = HARM_MAGIC; engine->setStateTimeline3(action->dst_ids(0), shenpan); setToken(0, 0); GameInfo game_info; Coder::tokenNotice(id, 0, token[0], game_info); engine->sendMessage(-1, MSG_GAME, game_info); return GE_URGENT; }
int GeDou::BaiShiDouShen(int PlayerID) { int ret; int skillID; if(getEnergy()<=0 && token[0] < 3) { return GE_SUCCESS; } if(getEnergy()>0 && token[0] >= 3){ skillID = BAI_SHI_DOU_SHEN; } if(getEnergy()>0 && token[0] < 3){ skillID = DOU_SHEN_TIAN_QU; } if(getEnergy()<=0 && token[0] >=3 ){ skillID = BAI_SHI_HUAN_LONG_QUAN; } CommandRequest cmd_req; Coder::askForSkill(id, skillID, cmd_req); //有限等待,由UserTask调用tryNotify唤醒 if(engine->waitForOne(id, network::MSG_CMD_REQ, cmd_req)) { void* reply; if (GE_SUCCESS == (ret = engine->getReply(id, reply))) { Respond* respond = (Respond*) reply; //发动 if(respond->args(0)==1) { network::SkillMsg skill; Coder::skillNotice(id, id, BAI_SHI_HUAN_LONG_QUAN, skill); engine->sendMessage(-1, MSG_SKILL, skill); baiShiUsed = true; setToken(0, token[0]-3); GameInfo game_info; Coder::tokenNotice(id, 0, token[0], game_info); tap = true; Coder::tapNotice(id, tap, game_info); engine->sendMessage(-1, MSG_GAME, game_info); return GE_SUCCESS; } if(respond->args(0)==2) { network::SkillMsg skill; Coder::skillNotice(id, id, DOU_SHEN_TIAN_QU, skill); engine->sendMessage(-1, MSG_SKILL, skill); GameInfo update_info; if(crystal>0){ setCrystal(--crystal); } else{ setGem(--gem); } Coder::energyNotice(id, gem, crystal, update_info); addCrossNum(2); Coder::crossNotice(id, crossNum, update_info); engine->sendMessage(-1, MSG_GAME, update_info); vector<int> cardIDs; int cardNum = ((getHandCardNum()-3)>0)? (getHandCardNum()-3):0; for(int i = 0; i < cardNum; i ++) { cardIDs.push_back(respond->card_ids(i)); } if(cardNum > 0) { engine->setStateMoveCardsNotToHand(id, DECK_HAND, -1, DECK_DISCARD, cardNum, cardIDs, id, DOU_SHEN_TIAN_QU, false); return GE_URGENT; } return GE_SUCCESS; } //没发动技能 return GE_SUCCESS; } return ret; } else{ //超时啥都不用做 return GE_TIMEOUT; } }
int HongLian::XueXingDaoYan() { CommandRequest cmd_req; Coder::askForSkill(id, XUE_XING_DAO_YAN, cmd_req); //有限等待,由UserTask调用tryNotify唤醒 if(engine->waitForOne(id, network::MSG_CMD_REQ, cmd_req)) { void* reply; int ret; if (GE_SUCCESS == (ret = engine->getReply(id, reply))) { Respond* respond = (Respond*) reply; if(respond->args(0) == 0){ return ret; } //发动 list<int> dst; //list<int> cross; int crossSumToSend = 0; for(int i = 0; i < respond->dst_ids_size(); i++) { dst.push_back(respond->dst_ids(i)); //cross.push_back(respond->args(i)); crossSumToSend += respond->args(i); } SkillMsg skill_msg; Coder::skillNotice(id, dst, XUE_XING_DAO_YAN, skill_msg); engine->sendMessage(-1, MSG_SKILL, skill_msg); GameInfo update_info; if(crossNum < crossSumToSend) return GE_INVALID_ARGUMENT; if(crossNum > 0 && crossSumToSend > 0) { //heal minus this->subCrossNum(crossSumToSend); Coder::crossNotice(id, this->getCrossNum(), update_info); //engine->sendMessage(-1, MSG_GAME, update_info); //heal plus for(int i = 0; i < respond->dst_ids_size(); i++) { int dstID = respond->dst_ids(i); int crossToSend = respond->args(i); engine->getPlayerEntity(dstID)->addCrossNum(crossToSend); Coder::crossNotice(dstID, engine->getPlayerEntity(dstID)->getCrossNum(), update_info); //engine->sendMessage(-1, MSG_GAME, update_info); } //token notify if(token[0]<2){ setToken(0,token[0] + 1); } Coder::tokenNotice(id, 0, getToken(0), update_info); engine->sendMessage(-1, MSG_GAME, update_info); HARM selfHarm; selfHarm.cause = XUE_XING_DAO_YAN; selfHarm.point = crossSumToSend; selfHarm.srcID = id; selfHarm.type = HARM_MAGIC; engine->setStateTimeline3(id, selfHarm); return GE_URGENT; } } return ret; } else{ //超时啥都不用做 return GE_TIMEOUT; } }
ScriptTokenListPtr ScriptLexer::tokenize(const String &str, const String &source) { // State enums enum{ READY = 0, COMMENT, MULTICOMMENT, WORD, QUOTE, VAR, POSSIBLECOMMENT }; // Set up some constant characters of interest const wchar_t varopener = '$', quote = '\"', slash = '/', backslash = '\\', openbrace = '{', closebrace = '}', colon = ':', star = '*', cr = '\r', lf = '\n'; char c = 0; String lexeme; uint32 line = 1, state = READY, lastQuote = 0; ScriptTokenListPtr tokens(OGRE_NEW_T(ScriptTokenList, MEMCATEGORY_GENERAL)(), SPFM_DELETE_T); // Iterate over the input String::const_iterator i = str.begin(), end = str.end(); while(i != end) { char lastc = c; c = *i; if(c == quote) lastQuote = line; switch(state) { case READY: if(c == slash && lastc == slash) { // Comment start, clear out the lexeme lexeme = ""; state = COMMENT; } else if(c == star && lastc == slash) { lexeme = ""; state = MULTICOMMENT; } else if(c == quote) { // Clear out the lexeme ready to be filled with quotes! lexeme = c; state = QUOTE; } else if(c == varopener) { // Set up to read in a variable lexeme = c; state = VAR; } else if(isNewline(c)) { lexeme = c; setToken(lexeme, line, source, tokens.get()); } else if(!isWhitespace(c)) { lexeme = c; if(c == slash) state = POSSIBLECOMMENT; else state = WORD; } break; case COMMENT: // This newline happens to be ignored automatically if(isNewline(c)) state = READY; break; case MULTICOMMENT: if(c == slash && lastc == star) state = READY; break; case POSSIBLECOMMENT: if(c == slash && lastc == slash) { lexeme = ""; state = COMMENT; break; } else if(c == star && lastc == slash) { lexeme = ""; state = MULTICOMMENT; break; } else { state = WORD; } case WORD: if(isNewline(c)) { setToken(lexeme, line, source, tokens.get()); lexeme = c; setToken(lexeme, line, source, tokens.get()); state = READY; } else if(isWhitespace(c)) { setToken(lexeme, line, source, tokens.get()); state = READY; } else if(c == openbrace || c == closebrace || c == colon) { setToken(lexeme, line, source, tokens.get()); lexeme = c; setToken(lexeme, line, source, tokens.get()); state = READY; } else { lexeme += c; } break; case QUOTE: if(c != backslash) { // Allow embedded quotes with escaping if(c == quote && lastc == backslash) { lexeme += c; } else if(c == quote) { lexeme += c; setToken(lexeme, line, source, tokens.get()); state = READY; } else { // Backtrack here and allow a backslash normally within the quote if(lastc == backslash) lexeme = lexeme + "\\" + c; else lexeme += c; } } break; case VAR: if(isNewline(c)) { setToken(lexeme, line, source, tokens.get()); lexeme = c; setToken(lexeme, line, source, tokens.get()); state = READY; } else if(isWhitespace(c)) { setToken(lexeme, line, source, tokens.get()); state = READY; } else if(c == openbrace || c == closebrace || c == colon) { setToken(lexeme, line, source, tokens.get()); lexeme = c; setToken(lexeme, line, source, tokens.get()); state = READY; } else { lexeme += c; } break; } // Separate check for newlines just to track line numbers if(c == cr || (c == lf && lastc != cr)) line++; i++; } // Check for valid exit states if(state == WORD || state == VAR) { if(!lexeme.empty()) setToken(lexeme, line, source, tokens.get()); } else { if(state == QUOTE) { OGRE_EXCEPT(Exception::ERR_INVALID_STATE, Ogre::String("no matching \" found for \" at line ") + Ogre::StringConverter::toString(lastQuote), "ScriptLexer::tokenize"); } } return tokens; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),ui(new Ui::MainWindow) { ui->setupUi(this); qDebug()<<QApplication::applicationVersion(); music = new MusicControl; netCore = new NetWorker; settings = new QSettings(this); settingsWindow = new PrefWindow(this); settingsWindow->setWindowFlags(Qt::Dialog); ui->lineEdit->setPlaceholderText("Search here"); ui->seekSlider->setRange(0,0); ui->repeatButton->hide(); isUnity = false; ///tray icon setup QAction *next = new QAction(tr("Next"),this); QAction *restore = new QAction(tr("Show window"),this); QAction *prev = new QAction(tr("Previous"),this); QAction *playPause = new QAction(tr("Play/Pause"),this); QAction *close = new QAction(tr("Exit"),this); connect(next,SIGNAL(triggered()),music,SLOT(playNextSong())); connect(prev,SIGNAL(triggered()),music,SLOT(playPrevSong())); connect(playPause,SIGNAL(triggered()),music,SLOT(changeState())); connect(close,SIGNAL(triggered()),qApp,SLOT(quit())); connect(restore,SIGNAL(triggered()),this,SLOT(show())); QMenu *trayIconMenu = new QMenu(this); trayIconMenu->addAction(restore); trayIconMenu->addAction(next); trayIconMenu->addAction(prev); trayIconMenu->addAction(playPause); trayIconMenu->addAction(close); trayIcon = new QSystemTrayIcon(QIcon(":/icons/qvk.svg")); trayIcon->setContextMenu(trayIconMenu); connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this, SLOT(trayHandler(QSystemTrayIcon::ActivationReason))); //trayIcon->setVisible(true); //trayIcon->show(); ///table setting QStringList header; ui->musicWidget->setColumnCount(4); header <<"Artist"<<"Title"<<"Duration"<<"link"; //in case of unsuccesseful update.... ui->musicWidget->hideColumn(3); ui->musicWidget->setHorizontalHeaderLabels(header); ui->musicWidget->verticalHeader()->setVisible(false); ui->musicWidget->setShowGrid(false); ui->musicWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->musicWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->musicWidget->setSelectionBehavior(QAbstractItemView::SelectRows); ui->musicWidget->setSelectionMode(QAbstractItemView::SingleSelection); ////////////////////////////////////////////////Creating actions QAction *login = new QAction(tr("Login"),this); QAction *About = new QAction(tr("About"),this); QAction *refrsh = new QAction(tr("Refresh"),this); QAction *showSettingsWindow = new QAction(tr("Settings"),this); connect(showSettingsWindow, SIGNAL(triggered()),settingsWindow,SLOT(show())); connect(refrsh,SIGNAL(triggered()), netCore, SLOT(getAudioList())); connect(login, SIGNAL(triggered()), netCore, SLOT(loginSlot())); connect(About, SIGNAL(triggered()), this, SLOT(about())); ////////////////////////////////////////////////Creating menu QMenu *gearButtonMenu = new QMenu("Options", ui->toolButton); gearButtonMenu->addAction(refrsh); gearButtonMenu->addAction(login); gearButtonMenu->addAction(showSettingsWindow); gearButtonMenu->addSeparator(); gearButtonMenu->addAction(About); gearButtonMenu->addAction(close); ///////////////////////////////////////////////making menu button ui->toolButton->setMenu(gearButtonMenu); ///connection area connect(this,SIGNAL(setPlayingOrder(QList<QUrl>)),music,SLOT(setPlayList(QList<QUrl>))); connect(ui->volumeSlider,SIGNAL(valueChanged(int)),music,SLOT(volumeSliderSlot(int))); connect(ui->musicWidget,SIGNAL(cellDoubleClicked(int,int)),music,SLOT(playThatSong(int,int))); connect(ui->shuffButton,SIGNAL(toggled(bool)),music,SLOT(shuffleMode(bool))); connect(ui->nextButton,SIGNAL(clicked()),music,SLOT(playNextSong())); connect(music,SIGNAL(setIndexToUi(int,int)),this,SLOT(setSongUi(int,int))); connect(ui->prevButton,SIGNAL(clicked()),music,SLOT(playPrevSong())); connect(ui->tooglePlayingButton,SIGNAL(clicked()),music,SLOT(changeState())); connect(music,SIGNAL(setPlayingUi()),this,SLOT(setPlayingUi())); connect(music,SIGNAL(setPausedUi()),this,SLOT(setPausedUi())); connect(ui->seekSlider,SIGNAL(sliderMoved(int)),music,SLOT(setPosition(int))); connect(music,SIGNAL(newPosition(qint64)),this,SLOT(positionChanged(qint64))); connect(music,SIGNAL(newRange(qint64)),this,SLOT(durationChanged(qint64))); connect(ui->lineEdit,SIGNAL(textChanged(QString)),this,SLOT(currentSearch(QString))); connect(this,SIGNAL(loadToken(QString,QString)),netCore,SLOT(setToken(QString,QString))); connect(netCore,SIGNAL(audioListGet(QList<QUrl>)),music,SLOT(setPlayList(QList<QUrl>))); connect(ui->musicWidget,SIGNAL(cellClicked(int,int)),music,SLOT(setSelectedSong(int,int))); connect(ui->repeatButton,SIGNAL(clicked(bool)),music,SLOT(repeatMode(bool))); connect(netCore,SIGNAL(dataGot()),this,SLOT(setMusicTable())); connect(this,SIGNAL(setPrefWindowsHotkeysUi(bool,bool)),settingsWindow,SLOT(setUseHotkeysUi(bool,bool))); connect(this,SIGNAL(setMinToTray(bool)),settingsWindow,SLOT(setUseMinTray(bool))); connect(settingsWindow,SIGNAL(setNewSettings(bool,bool,bool,QString,bool)), this,SLOT(setNewSettings(bool,bool,bool,QString,bool))); ///connection area ///DBUS setting #ifdef Q_OS_LINUX DBusMethods* demo = new DBusMethods(); new DBusAdaptor(demo); new DBusAdaptor1(demo); QDBusConnection connection = QDBusConnection::sessionBus(); bool ret = connection.registerService("org.mpris.MediaPlayer2.qvkplayer.mainwindow"); ret = connection.registerObject("/org/mpris/MediaPlayer2", demo); connect(demo,SIGNAL(dbusNext()),ui->nextButton,SIGNAL(clicked())); connect(demo,SIGNAL(dbusPlayPause()),ui->tooglePlayingButton,SIGNAL(clicked())); connect(demo,SIGNAL(dbusPrev()),ui->prevButton,SIGNAL(clicked())); connect(demo,SIGNAL(dbusQuit()),qApp,SLOT(quit())); connect(demo,SIGNAL(dbusRaise()),this,SLOT(show())); #endif ///DBUS setting ///CONFIG LOADING================================== this->loadSettings(); }
TokenManager::TokenManager(QObject *parent) : QObject(parent) { QSettings settings (ORGANIZATION_NAME, APPLICATION_NAME); setToken(settings.value(TOKEN_KEY, QString()).toString()); }
// many thanks to starkwong. He found the change of this bit in QQ2006 ReceivedQunIMJoinRequest::ReceivedQunIMJoinRequest(const unsigned short imType, const unsigned char * buf, const int len) : externalID(0), sender(0), type(0), message(""), commander(0), m_Code(0), m_CodeLen(0), m_Token(0), m_TokenLen(0) { printf("ReceivedQunIMJoinRequest\n"); for(int i=0; i<len; i++){ if(!(i%8)) printf("\n%d: ", i); printf("%2x ", (uint8_t)buf[i]); } printf("\n\n"); int pos=0; unsigned char exttype=0; externalID = ntohl(*(unsigned int*)buf); pos+=4; type = buf[pos++]; switch(imType){ case QQ_RECV_IM_ADDED_TO_QUN: case QQ_RECV_IM_DELETED_FROM_QUN: sender = READ32(buf+pos); pos+=4; exttype=buf[pos++]; // LumaQQ disregard value of exttype(rootCause) when deal with QQ_RECV_IM_ADDED_TO_QUN // Values for exttype (For QQ_RECV_IM_DELETED_FROM_QUN, from LumaQQ Mac) // static const char kQQExitClusterDismissed = 0x01; // static const char kQQExitClusterActive = 0x02; // static const char kQQExitClusterPassive = 0x03; if(imType == QQ_RECV_IM_ADDED_TO_QUN || exttype == 3) { commander = READ32(buf+pos); pos+=4; } break; case QQ_RECV_IM_REQUEST_JOIN_QUN: sender = READ32(buf+pos); pos+=4; break; case QQ_RECV_IM_APPROVE_JOIN_QUN: case QQ_RECV_IM_REJECT_JOIN_QUN: commander = READ32(buf+pos); pos+=4; break; case QQ_RECV_IM_SET_QUN_ADMIN: commander = buf[pos++]; // just use the commander variable to save the action. 0:unset, 1:set sender = READ32(buf + pos); // sender is the persion which the action performed on pos += 4; pos++;// unknonw, probably the admin value of the above member break; case QQ_RECV_IM_CREATE_QUN: default: sender = READ32(buf+pos); pos+=4; break; } if(imType != QQ_RECV_IM_DELETED_FROM_QUN || exttype == 3){ if(len == pos) { message = ""; return; } unsigned length = (unsigned int)buf[pos++]; char *msg = (char *)malloc((length+1) * sizeof(char)); memcpy(msg, buf + pos, length); msg[length] = 0x00; message.assign(msg); free(msg); pos += length; } m_CodeLen = READ16(buf + pos); pos +=2; setCode(buf+pos, m_CodeLen); pos += m_CodeLen; if(imType == QQ_RECV_IM_REQUEST_JOIN_QUN){ m_TokenLen = READ16(buf + pos); pos +=2; setToken(buf+pos, m_TokenLen); pos += m_TokenLen; } }
void CloudAuthenticator::replyFinished(QNetworkReply *reply) { int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); // token request if (m_tokenRequests.contains(reply)) { QByteArray data = reply->readAll(); m_tokenRequests.removeAll(reply); if (reply->error() != QNetworkReply::NoError) { qCWarning(dcCloud()) << "Authenticator: Request token reply error:" << status << reply->errorString(); m_error = Cloud::CloudErrorIdentityServerNotReachable; setAuthenticated(false); reply->deleteLater(); return; } // check HTTP status code if (status != 200) { qCWarning(dcCloud()) << "Authenticator: Request token reply HTTP error:" << status << reply->errorString(); qCWarning(dcCloud()) << data; m_error = Cloud::CloudErrorAuthenticationFailed; setAuthenticated(false); reply->deleteLater(); return; } // check JSON QJsonParseError error; QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error); if (error.error != QJsonParseError::NoError) { qCWarning(dcCloud()) << "Authenticator: Request token reply JSON error:" << error.errorString(); m_error = Cloud::CloudErrorAuthenticationFailed; setAuthenticated(false); reply->deleteLater(); return; } if (!jsonDoc.toVariant().toMap().contains("access_token")) { qCWarning(dcCloud()) << "Authenticator: Could not get access token" << jsonDoc.toJson(); m_error = Cloud::CloudErrorAuthenticationFailed; setAuthenticated(false); reply->deleteLater(); return; } m_error = Cloud::CloudErrorNoError; setToken(jsonDoc.toVariant().toMap().value("access_token").toString()); setAuthenticated(true); // Save the username GuhSettings settings(GuhSettings::SettingsRoleDevices); settings.beginGroup("Cloud"); settings.setValue("userName", m_username); settings.endGroup(); if (jsonDoc.toVariant().toMap().contains("expires_in") && jsonDoc.toVariant().toMap().contains("refresh_token")) { int expireTime = jsonDoc.toVariant().toMap().value("expires_in").toInt(); setRefreshToken(jsonDoc.toVariant().toMap().value("refresh_token").toString()); qCDebug(dcCloud()) << "Authenticator: Token will be refreshed in" << expireTime << "[s]"; m_timer->start((expireTime - 20) * 1000); } } else if (m_refreshTokenRequests.contains(reply)) { QByteArray data = reply->readAll(); m_refreshTokenRequests.removeAll(reply); if (reply->error() != QNetworkReply::NoError) { qCWarning(dcCloud()) << "Authenticator: Request token reply error:" << status << reply->errorString(); m_error = Cloud::CloudErrorIdentityServerNotReachable; setAuthenticated(false); reply->deleteLater(); return; } // check HTTP status code if (status != 200) { qCWarning(dcCloud()) << "Authenticator: Refresh token reply HTTP error:" << status << reply->errorString(); m_error = Cloud::CloudErrorAuthenticationFailed; setAuthenticated(false); reply->deleteLater(); return; } // check JSON QJsonParseError error; QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error); if (error.error != QJsonParseError::NoError) { qCWarning(dcCloud()) << "Authenticator: Refresh token reply JSON error:" << error.errorString(); m_error = Cloud::CloudErrorAuthenticationFailed; setAuthenticated(false); reply->deleteLater(); return; } if (!jsonDoc.toVariant().toMap().contains("access_token")) { qCWarning(dcCloud()) << "Authenticator: Could not get access token after refresh" << jsonDoc.toJson(); m_error = Cloud::CloudErrorAuthenticationFailed; setAuthenticated(false); reply->deleteLater(); return; } m_error = Cloud::CloudErrorNoError; setToken(jsonDoc.toVariant().toMap().value("access_token").toString()); qCDebug(dcCloud()) << "Authenticator: Token refreshed successfully"; if (jsonDoc.toVariant().toMap().contains("expires_in") && jsonDoc.toVariant().toMap().contains("refresh_token")) { int expireTime = jsonDoc.toVariant().toMap().value("expires_in").toInt(); setRefreshToken(jsonDoc.toVariant().toMap().value("refresh_token").toString()); qCDebug(dcCloud()) << "Authenticator: Token will be refreshed in" << expireTime << "[s]"; m_timer->start((expireTime - 20) * 1000); } if (!authenticated()) setAuthenticated(true); } reply->deleteLater(); }
int GeDou::XuLiCangYan(CONTEXT_TIMELINE_1 *con) { int ret; int srcID = con->attack.srcID; int dstID = con->attack.dstID; if(srcID != id || !con->attack.isActive ){ return GE_SUCCESS; } int skillID; if(token[0] == tokenMax[0]){ skillID = CANG_YAN_ZHI_HUN; } if(token[0] == 0){ skillID = XU_LI_YI_JI; } if(token[0] > 0 && token[0] < tokenMax[0]){ skillID = XU_LI_CANG_YAN; } //满足发动条件,询问客户端是否发动 CommandRequest cmd_req; Coder::askForSkill(id, skillID, cmd_req); //有限等待,由UserTask调用tryNotify唤醒 if(engine->waitForOne(id, network::MSG_CMD_REQ, cmd_req)) { void* reply; if (GE_SUCCESS == (ret = engine->getReply(srcID, reply))) { Respond* respond = (Respond*) reply; //发动 if(respond->args(0)==1) { network::SkillMsg skill; Coder::skillNotice(id, dstID, XU_LI_YI_JI, skill); engine->sendMessage(-1, MSG_SKILL, skill); xuLiUsed = true; setToken(0, token[0]+1); GameInfo game_info; Coder::tokenNotice(id, 0, token[0], game_info); //蓄力退出百事 if(tap) { tap = false; baiShiTarget = -1; Coder::tapNotice(id, tap, game_info); } engine->sendMessage(-1, MSG_GAME, game_info); con->harm.point += 1; return GE_SUCCESS; } if(respond->args(0)==2) { network::SkillMsg skill; Coder::skillNotice(id, dstID, CANG_YAN_ZHI_HUN, skill); engine->sendMessage(-1, MSG_SKILL, skill); cangYanUsed = true; setToken(0, token[0]-1); GameInfo game_info; Coder::tokenNotice(id, 0, token[0], game_info); engine->sendMessage(-1, MSG_GAME, game_info); con->hitRate = RATE_NOREATTACK; return GE_SUCCESS; } //没法动技能 return GE_SUCCESS; } return ret; } else{ //超时啥都不用做 return GE_TIMEOUT; } }