bool pinDialog::doDialogInloop(pinOpInterface &operation,PinString &authPinCache) { for(;;) { byte retries = 0; try { PinString pin; if (authPinCache.empty()) { if (!doDialog()) throw std::runtime_error("User cancelled"); pin = getPin(); } else pin = authPinCache; mutexObjLocker lock(operation.m_mutex); if (m_key == EstEidCard::AUTH) operation.m_card.validateAuthPin(pin,retries); else operation.m_card.validateSignPin(pin,retries); operation.call(operation.m_card,pin,m_key); authPinCache = pin; return true; } catch(AuthError &auth) { authPinCache.clear(); if (auth.m_blocked) { showPrompt("Wrong pin entered, PIN is blocked"); throw std::runtime_error("PIN is blocked"); } std::stringstream buf; buf << "Wrong pin entered, " << (int)retries << " retries left"; if (!showPrompt(buf.str(),true)) throw std::runtime_error("User cancelled"); } } }
void SerialUI::handleRequests() { Menu * ret_menu; for (uint8_t i = 0; i <= 100; i++) { #ifdef SUI_ENABLE_USER_PRESENCE_HEARTBEAT if (heartbeat_function_cb != NULL) { uint32_t timeNow = millis(); if (timeNow >= (heartbeat_function_last_called + heartbeat_function_period)) { // time to call again... heartbeat_function_cb(); heartbeat_function_last_called = timeNow; } } #endif if (this->available() > 0) { SERIALUI_DEBUG("Handling pending request"); // we have input (and therefore a user), so we reset our presence counter to zero user_presence_last_interaction_ms = 0; ret_menu = current_menu->handleRequest(); if (ret_menu) { if (menu_manual_override) { // leave the current menu as is, as it was overridden in // the last command menu_manual_override = false; } else { // make certain we reflect whatever changes are required // (e.g. the item was a submenu) current_menu = ret_menu; } } else { exit(false); return; } #ifdef SUI_SERIALUI_SHOW_PROMPTS showPrompt(); #endif } else { delay(SUI_SERIALUI_HANDLEREQ_DELAY_MS); user_presence_last_interaction_ms += SUI_SERIALUI_HANDLEREQ_DELAY_MS; //println(user_presence_last_interaction_ms, DEC); } } return; }
void PlayerLink::responseFinished(bool ok){ // playing placed here as synthesizer shares the multipurpose buffer with web requests if(ok && (requestType == NEW_TEXT_CHIRP_REQUEST || requestType == NEW_URL_CHIRP_REQUEST)) { Playlists::currentPlaylist()->play(); } showPrompt(); }
void SerialUI::enter() { if (greeting_msg) { current_menu->returnMessage(greeting_msg); } #ifdef SUI_SERIALUI_SHOW_PROMPTS showPrompt(); #endif }
void InternalLink::handleInternalLink(DesuraId id, uint8 action, const std::vector<std::string> &argsList) { if (g_pMainApp->isOffline() && action != ACTION_LAUNCH) return; Args args(argsList); bool handled = true; switch (action) { case ACTION_UPLOAD : uploadMCF( id ); break; case ACTION_CREATE : createMCF( id ); break; case ACTION_RESUPLOAD : resumeUploadMCF( id, args ); break; #ifdef WIN32 case ACTION_INSTALLEDW : installedWizard(); break; #endif case ACTION_SHOWSETTINGS: showSettings(args); break; case ACTION_APPUPDATELOG: showUpdateLogApp( id.getItem() ); break; case ACTION_PAUSE : setPauseItem( id , true ); break; case ACTION_UNPAUSE : setPauseItem( id , false ); break; case ACTION_UNINSTALL : uninstallMCF( id ); break; case ACTION_PROMPT : showPrompt(id, args); break; case ACTION_UPDATELOG : showUpdateLog(id); break; case ACTION_DISPCDKEY : showCDKey(id, args); break; default: handled = false; break; } if (handled || checkForm(id)) return; switch (action) { case ACTION_INSTALL : installItem(id, args); break; case ACTION_LAUNCH : launchItem(id, args); break; case ACTION_VERIFY : verifyItem(id, args); break; case ACTION_UPDATE : updateItem(id, args); break; case ACTION_TEST : installTestMCF(id, args); break; case ACTION_INSCHECK : installCheck(id); break; case ACTION_SHOWUPDATE : showUpdateForm(id, args); break; case ACTION_SWITCHBRANCH: switchBranch(id, args); break; case ACTION_CLEANCOMPLEXMOD: cleanComplexMod(id); break; default: Warning(gcString("Unknown internal link {0} for item {1}\n.", (uint32)action, id.toInt64())); break; } }
void SearchTreeBrowser::startBrowserMode() const { NodePtr pCurrentNode = m_searchTree.getCurrentNode(); bool bExtendComment = false; bool bHideComment = true; bool bShowData = false; showPrompt(); printNode(std::cout, pCurrentNode); std::cout << std::endl; printComment(std::cout, pCurrentNode, bExtendComment, bHideComment); printData(std::cout, pCurrentNode, bShowData); unsigned char c = 0; while ((c = getch()) != 'q' && c != 'Q') { bool bRedraw = false; // Arrow key is start with esc if (c == '\033') { bRedraw = handlePressArrowKey(pCurrentNode); } else if (c == 'e' || c == 'E') { bExtendComment = !bExtendComment; bRedraw = true; } else if (c == 'c' || c == 'C') { bHideComment = !bHideComment; bRedraw = true; } else if (c == 'd' || c == 'D') { bShowData = !bShowData; bRedraw = true; } if (bRedraw) { showPrompt(); printNode(std::cout, pCurrentNode); std::cout << std::endl; printComment(std::cout, pCurrentNode, bExtendComment, bHideComment); printData(std::cout, pCurrentNode, bShowData); } } m_searchTree.setCurrentNode(pCurrentNode); }
void Greeter::showPromptFilter(const QString &text, QLightDM::Greeter::PromptType type) { Q_D(Greeter); d->wasPrompted = true; bool isDefaultPrompt = (text == dgettext("Linux-PAM", "Password: "******":"))) { trimmedText.chop(1); } Q_EMIT showPrompt(trimmedText, type == QLightDM::Greeter::PromptTypeSecret, isDefaultPrompt); }
void RestartLayer::promptCallback(CCObject* object) { #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS bool purchased = LoadBooleanFromXML(KEY_PROMPT_PURCHASED, false); if(!purchased) { std::string productID = IOSWrapper::isLiteVersion() ? AppPromptProductId_Lite : AppPromptProductId_Pro; IAPWrapper::sharedInstance()->buyProductIdentifierWithPromptDialog(productID, "You need to pay for the guide(it's for all stages). That's a lot of help for us to improve this game.", this); } else { showPrompt(); } #endif }
// gather command from serial input // this may be performed in multiple passes - only a newline (not stored) marks command ready to process void processSerialCommands() { int inch; // append any newly arrived chars & execute command if return received while ((inch = Serial.read()) >= 0) { if (inch == '\n') { // end of line if(doCommand(commandBuffer)) { showPrompt(); } commandAp.reset(); return; // process at most one command per loop } else { // continue line commandAp.append((char) inch); } } }
void LoginForm::initialize() { QPixmap icon(":/resources/rqt-2.png"); // This project came from Razor-qt ui->iconLabel->setPixmap(icon.scaled(ui->iconLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); ui->hostnameLabel->setText(m_Greeter.hostname()); ui->sessionCombo->setModel(&sessionsModel); addLeaveEntry(power.canShutdown(), "system-shutdown", tr("Shutdown"), "shutdown"); addLeaveEntry(power.canRestart(), "system-reboot", tr("Restart"), "restart"); addLeaveEntry(power.canHibernate(), "system-suspend-hibernate", tr("Hibernate"), "hibernate"); addLeaveEntry(power.canSuspend(), "system-suspend", tr("Suspend"), "suspend"); ui->leaveComboBox->setDisabled(ui->leaveComboBox->count() <= 1); ui->sessionCombo->setCurrentIndex(0); setCurrentSession(m_Greeter.defaultSessionHint()); connect(ui->userInput, SIGNAL(editingFinished()), this, SLOT(userChanged())); connect(ui->leaveComboBox, SIGNAL(activated(int)), this, SLOT(leaveDropDownActivated(int))); connect(&m_Greeter, SIGNAL(showPrompt(QString, QLightDM::Greeter::PromptType)), this, SLOT(onPrompt(QString, QLightDM::Greeter::PromptType))); connect(&m_Greeter, SIGNAL(authenticationComplete()), this, SLOT(authenticationComplete())); ui->passwordInput->setEnabled(false); ui->passwordInput->clear(); if (! m_Greeter.hideUsersHint()) { QStringList knownUsers; QLightDM::UsersModel usersModel; for (int i = 0; i < usersModel.rowCount(QModelIndex()); i++) { knownUsers << usersModel.data(usersModel.index(i, 0), QLightDM::UsersModel::NameRole).toString(); } ui->userInput->setCompleter(new QCompleter(knownUsers)); ui->userInput->completer()->setCompletionMode(QCompleter::InlineCompletion); } QString user = Cache().getLastUser(); if (user.isEmpty()) { user = m_Greeter.selectUserHint(); } ui->userInput->setText(user); userChanged(); }
void autoplayLoop() { static int32_t then; // now field from last time in loop int32_t now = timeNowSecondsSinceMidnight(); int16_t nowMinute = now / 60; // start any new autoplays if(nowMinute > then / 60 || autoplayNow) { // its a new minute; check the playlists to see if any due to start autoplaying this minute autoplayNow = false; for(int ix = 0; ix < N_PLAYLISTS; ix++) { Playlist *p = Playlists::playlist(ix); if(p->nChirps > 0 && p->autoplayCount == 0) { // only check if playlist has chirps and isn't already playing AutoplayStructure settings; p->getAutoplaySettings(&settings); int16_t startMinute = settings.startMinute; // run through all start times for playlist // doesn't play before initial start time and doesn't continue repeating past midnight for(uint8_t n = 0; n < settings.count && nowMinute >= startMinute && startMinute < minutesInOneDay; n++) { if(startMinute == nowMinute) { if(p->getUpdateFlags() & UPDATE_WHEN_AUTOPLAY) { p->requestUpdate(); } // setting non-zero count makes autoplay active p->autoplayCount = min(settings.maxChirps, p->nChirps); p->autoplayTimeSeconds = 0; // play as soon as possible break; } startMinute += settings.repeatMinutes; } } } } // autoplay up to one chirp per new second if(now > then) { // it's a new second // first check to see if current playlist is being autoplayed from the command line if(immediateAutoplayCount > 0 && now >= immediateAutoplayTimeSeconds) { Playlist *p = Playlists::currentPlaylist(); if(p->playSequenced()) { immediateAutoplayCount--; immediateAutoplayTimeSeconds = now + p->getInterval(); } else { // empty playlist: turn off immediateAutoplayCount = 0; } if(immediateAutoplayCount == 0) { showPrompt(); } } else { // check any timed autoplaying playlists for any due to play now for(int ix = 0; ix < N_PLAYLISTS; ix++) { Playlist *p = Playlists::playlist(ix); if(p->autoplayCount > 0 && now >= p->autoplayTimeSeconds && p->awaitingUpdate == NOT_AWAITING_UPDATE) { if(p->playSequenced()) { p->autoplayCount--; p->autoplayTimeSeconds = now + p->getInterval(); break; // only one play per vsit to this function } else { p->autoplayCount = 0; // empty playlist (shouldn't happen here) } } } } } then = now; }
LoginForm::LoginForm(QWidget *parent) : QWidget(parent), ui(new Ui::LoginForm) { if (! m_Greeter.connectSync()) { close(); } ui->setupUi(this); setStyleSheet(razorTheme.qss("razor-lightdm-greeter/razor-lightdm-greeter")); ui->hostnameLabel->setFocus(); // Setup users m_UsersModel = new QLightDM::UsersModel(); QStringList userIds; for (int i = 0; i < m_UsersModel->rowCount(QModelIndex()); i++) { QModelIndex index = m_UsersModel->index(i); QString userId = m_UsersModel->data(index, Qt::UserRole).toString(); userIds << userId; } QCompleter *completer = new QCompleter(userIds); completer->setCompletionMode(QCompleter::InlineCompletion); ui->userIdInput->setCompleter(completer); // Setup sessions m_SessionsModel = new QLightDM::SessionsModel(); ui->sessionCombo->setModel(m_SessionsModel); for (int row = 0; row < ui->sessionCombo->model()->rowCount(); row++) { QModelIndex index = ui->sessionCombo->model()->index(row, 0); if (QString("Razor Desktop") == ui->sessionCombo->model()->data(index, Qt::DisplayRole).toString()) { ui->sessionCombo->setCurrentIndex(row); break; } } QPixmap icon(QString(SHARE_DIR) + "/graphics/rqt-2.svg"); ui->iconLabel->setPixmap(icon.scaled(ui->iconLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); #ifdef USING_LIGHTDM_QT_1 ui->hostnameLabel->setText(QLightDM::hostname()); connect(&m_Greeter, SIGNAL(showPrompt(QString,QLightDM::PromptType)), this, SLOT(onPrompt(QString,QLightDM::PromptType))); #else ui->hostnameLabel->setText(m_Greeter.hostname()); connect(&m_Greeter, SIGNAL(showPrompt(QString,QLightDM::Greeter::PromptType)), this, SLOT(onPrompt(QString,QLightDM::Greeter::PromptType))); #endif connect(ui->loginButton, SIGNAL(clicked(bool)), this, SLOT(doLogin())); connect(ui->cancelButton, SIGNAL(clicked()), SLOT(doCancel())); connect(&m_Greeter, SIGNAL(authenticationComplete()), this, SLOT(authenticationDone())); connect(ui->leaveButton, SIGNAL(clicked()), SLOT(doLeave())); connect(&m_razorPowerProcess, SIGNAL(finished(int)), this, SLOT(razorPowerDone())); }
void InternalLink::launchItem(DesuraId id, Args args) { bool cdKeyArg = args.containsArg("cdkey"); bool noUpdateArg = args.containsArg("noupdate"); bool exeNumArg = args.containsArg("exe"); std::string exe = args.getArgValue("exe"); if (exe == "") exeNumArg = false; g_pMainApp->showPlay(); if (checkForPreorder(id)) return; UserCore::Item::ItemInfoI* item = GetUserCore()->getItemManager()->findItemInfo(id); bool delFlag=false; if (!item || !item->isLaunchable()) { installItem(id, Args()); return; } if (!item->hasAcceptedEula()) { showPrompt(id, FormatArgs("prompt=eula")); return; } if (!exeNumArg && item->getExeCount(true) > 1) { showExeSelect(id, cdKeyArg); return; } else if (exe.size() > 0) { item->setActiveExe(exe.c_str()); } bool hasCDKey = item->getCurrentBranch() && item->getCurrentBranch()->hasCDKey(); bool hasDLCDKey = item->getCurrentBranch() && item->getCurrentBranch()->isCDKeyValid(); if (!cdKeyArg && ((item->isFirstLaunch() && hasCDKey) || (hasCDKey && !hasDLCDKey))) { showCDKey(id, FormatArgs("launch=true", std::string("exe=") + exe)); return; } bool shouldShowGameDisk = false; if (args.containsArg("gamedisk") == false && HasAnyFlags(item->getOptions(), UserCore::Item::ItemInfoI::OPTION_DONTPROMPTGAMEDISK) == false) { size_t x=0; while (g_GameDiskList[x].isOk()) { if (item->getId() == g_GameDiskList[x] || item->getParentId() == g_GameDiskList[x]) { shouldShowGameDisk = true; break; } x++; } } if (shouldShowGameDisk) { showGameDisk(id, exe.c_str(), cdKeyArg); return; } if (noUpdateArg && !HasAnyFlags(item->getOptions(), UserCore::Item::ItemInfoI::OPTION_NOTREMINDUPDATE)) { item->addOFlag(UserCore::Item::ItemInfoI::OPTION_NOTREMINDUPDATE); delFlag = true; } UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_LAUNCH); if (!form) Warning(gcString("Cant find item (or item not ready) for launch [{0}].\n", id.toInt64())); if (item && delFlag) item->delOFlag(UserCore::Item::ItemInfoI::OPTION_NOTREMINDUPDATE); }
int main(int argc, char** argv) { int outfileid; char * c; char buffer[BUFFER_LEN]; char * buffer_aux; char mktemp_filename[PATH_MAX]; char mktemp_dir[PATH_MAX]; int len, pid, mode; char * orig; int inputPipe; int totalProc; double totalTime; pid = getpid(); if (argc!=2) { fprintf(stderr, "Modo de utilizacao: %s <pathname para o pipe>", argv[0]); exit(EXIT_FAILURE); } if ((outfileid = open(argv[1], O_WRONLY)) < 0) { fprintf(stderr, "Could not create fifo %s\n", argv[1]); exit(EXIT_FAILURE); } mode = 1; orig = (char*)&mode; memcpy(buffer, orig, sizeof(int)); orig = (char*)&pid; memcpy(buffer+sizeof(int), orig, sizeof(int)); TESTTRUE(write(outfileid, buffer, 2*sizeof(int))==2*sizeof(int), "Erro na escrite para o pipe (" _AT_ ")\n"); showPrompt(); buffer_aux = buffer + 3*sizeof(int); while ((c = fgets(buffer_aux, BUFFER_LEN - 3*sizeof(int), stdin)) > 0) { //printf("\"%s\"\n", buffer_aux); if (c == NULL || *c == EOF) { break; } if (strcmp("exit\n", buffer_aux)==0) { break; } if (strcmp("exit-global\n", buffer_aux)==0) { mode = 3; orig = (char*)&mode; memcpy(buffer, orig, sizeof(int)); TESTTRUE(write(outfileid, buffer, sizeof(int))==sizeof(int), "Erro na escrite para o pipe (" _AT_ ")\n"); pause(); //o processo vai morrer, mas ate la pausamos exit(EXIT_FAILURE); } if (strcmp("stats\n", buffer_aux)==0) { strcpy(mktemp_dir, MKTEMP_TEMPLATE); TESTTRUE(mkdtemp(mktemp_dir)!=NULL, "Erro na criação do diretorio temporário (" _AT_ "\n"); strncpy(mktemp_filename, mktemp_dir, PATH_MAX); strncpy(mktemp_filename+strlen(mktemp_filename), "/out", PATH_MAX-strlen(mktemp_filename)); if (mkfifo(mktemp_filename, 0660) <0) { fprintf(stderr, "Could not create fifo " INPUT_FILE "\n"); exit(EXIT_FAILURE); } len = strlen(mktemp_filename); strncpy(buffer_aux, mktemp_filename, BUFFER_LEN - 3*sizeof(int)); mode = 4; orig = (char*)&mode; memcpy(buffer, orig, sizeof(int)); orig = (char*)&len; memcpy(buffer+sizeof(int), orig, sizeof(int)); orig = (char*)&pid; memcpy(buffer+2*sizeof(int), orig, sizeof(int)); TESTTRUE(write(outfileid, buffer, 3*sizeof(int) + len)==3*sizeof(int) + len, "Erro na escrita para o pipe (" _AT_ ")\n"); if ((inputPipe = open(mktemp_filename, O_RDONLY)) < 0) { fprintf(stderr, "Could not create fifo " INPUT_FILE "\n"); exit(EXIT_FAILURE); } TESTTRUE((read(inputPipe, &totalProc, sizeof(int))==sizeof(int)), "Erro no formato do pipe (" _AT_ ")\n"); TESTTRUE((read(inputPipe, &totalTime, sizeof(double))==sizeof(double)), "Erro no formato do pipe (" _AT_ ")\n"); printf("Numero total de processos: %d\n" "Tempo total: %f\n", totalProc, totalTime); close(inputPipe);//nao faz sentido testarmos isto, pois e um ficheiro temporario unlink(mktemp_filename);//nao faz sentido testarmos isto, pois e um ficheiro temporario unlink(mktemp_dir);//nao faz sentido testarmos isto, pois e um ficheiro temporario showPrompt(); continue; } //Caso comando normal: len = strlen(buffer_aux); len++; mode = 0; orig = (char*)&mode; memcpy(buffer, orig, sizeof(int)); orig = (char*)&len; memcpy(buffer+sizeof(int), orig, sizeof(int)); orig = (char*)&pid; memcpy(buffer+2*sizeof(int), orig, sizeof(int)); TESTTRUE(write(outfileid, buffer, 3*sizeof(int) + len)==3*sizeof(int) + len, "Erro na escrite para o pipe (" _AT_ ")\n"); showPrompt(); } mode = 2; orig = (char*)&mode; memcpy(buffer, orig, sizeof(int)); orig = (char*)&pid; memcpy(buffer+sizeof(int), orig, sizeof(int)); TESTTRUE(write(outfileid, buffer, 2*sizeof(int))==2*sizeof(int), "Erro na escrite para o pipe (" _AT_ ")\n"); return close(outfileid); }
void FakeGreeter::onAuthenticationTimerExpired() { Q_EMIT showPrompt("Password:", QLightDM::Greeter::PromptTypeQuestion); }
void CLI_Exec(void) { uint8_t index; uint8_t argc; char* argv[ARGV_MAX_SIZE]; // Òì³£ÅÐ¶Ï if(Command_Ready == false) { goto __EXIT; } if(Buffer_Index == 1) { goto __EXIT; } // ²ÎÊý½âÎö argv[0] = strtok(Buffer, " "); for(index = 1; index < ARGV_MAX_SIZE; index ++) { argv[index] = strtok(NULL, " "); if(argv[index] == NULL) break; } argc = index; // ÃüÁî·Ö·¢ struct COMMAND_ENTRY* entry_seek; struct COMMAND_ENTRY* entry_tail; entry_seek = __section_begin("COMMAND_ENTRY"); entry_tail = __section_end("COMMAND_ENTRY"); for(; entry_seek < entry_tail; ++entry_seek) { if( strcmp(argv[0], entry_seek->name) ) continue; if( (argc < entry_seek->min_argc) || (argc > entry_seek->max_argc) ) {// arg error showHelp(entry_seek); goto __EXIT; } if(entry_seek->command != 0) { entry_seek->command(argc-1, &argv[1]); } } showPrompt(); __EXIT: Command_Ready = false; Buffer_Index = 0; }
/* * Read commands from the specified file. * A null name pointer indicates to read from stdin. */ static void readFile(const char * name) { FILE * fp; int cc; BOOL ttyFlag; char buf[CMD_LEN]; if (sourceCount >= MAX_SOURCE) { fprintf(stderr, "Too many source files\n"); return; } fp = stdin; if (name) { fp = fopen(name, "r"); if (fp == NULL) { perror(name); return; } } sourcefiles[sourceCount++] = fp; ttyFlag = isatty(fileno(fp)); while (TRUE) { if (ttyFlag) showPrompt(); if (intFlag && !ttyFlag && (fp != stdin)) { fclose(fp); sourceCount--; return; } if (fgets(buf, CMD_LEN - 1, fp) == NULL) { if (ferror(fp) && (errno == EINTR)) { clearerr(fp); continue; } break; } cc = strlen(buf); if (buf[cc - 1] == '\n') cc--; while ((cc > 0) && isBlank(buf[cc - 1])) cc--; buf[cc] = '\0'; command(buf); } if (ferror(fp)) { perror("Reading command line"); if (fp == stdin) exit(1); } clearerr(fp); if (fp != stdin) fclose(fp); sourceCount--; }
void RestartLayer::guidePurchased(bool isSuccessful) { if(isSuccessful) showPrompt(); }