void IoDisk::setup(const StringMap & settings) { Io::setup(settings); // -------------------------- // Get name from instance std::string instanceName = settings.at("name"); setInstanceName(instanceName); // -------------------------- // Check if need to draw timestamp bool drawTimestamp = (settings.at("ios.Disk.markWithTimestamp") == "true"); setDrawTimestamp(drawTimestamp); cv::Scalar color = getColor(settings.at("ios.Disk.timestampColor")); setTimestampColor(color); std::string timezone = settings.at("timezone"); std::replace(timezone.begin(), timezone.end(), '-', '/'); std::replace(timezone.begin(), timezone.end(), '$', '_'); setTimezone(timezone); // ------------------------------------------------------------- // Filemanager is mapped to a directory and is used by an image // to save to the correct directory. setFileFormat(settings.at("ios.Disk.fileFormat")); m_fileManager.setBaseDirectory(settings.at("ios.Disk.directory")); }
int TextSetup::run() { int ret; for (int i=0; i<9; ++i) { switch(i) { case 0: ret = setPackageSource(); break; case 1: ret = setInstallType(); break; case 2: ret = setPartitionEditor(); break; case 3: ret = setMountPoints(); break; case 4: ret = setBootLoader(); break; case 5: ret = setRootPassword(); break; case 6: ret = setCreateUser(); break; case 7: ret = setNetworkSettings(); break; case 8: ret = setTimezone(); break; default: return -1; } if (ret!=0) i=i-2; if (i<0) return -1; } saveConfigSettings(); string runString = "LC_ALL=" + settings["language"] + " setup_exec"; ncInterface.uninit(); system(runString); return 0; }
void totpClient() { RTCunadjustedWizard(1); if(isRTCunadjusted()) { mMsgBoxPush(6); multiPrintXY(3, 2, "The OATH TOTP\nauthenticator\ncan't work with\nthe clock\nunadjusted.", TEXT_MODE_TRANSPARENT_BACKGROUND, TEXT_COLOR_BLACK); closeMsgBox(0, 7); return; } totp ts[MAX_DAY_EVENTS]; Menu menu; menu.type = MENUTYPE_FKEYS; MenuItem items[MAX_DAY_EVENTS]; menu.items = items; reload: menu.numitems = loadTOTPs(ts); for(int i = 0; i < menu.numitems; i++) { items[i].text = ts[i].name; } menu.title = (char*)"TOTP authenticator"; menu.scrollout = 1; menu.height = 7; menu.nodatamsg = (char*)"No tokens - press F2"; menu.returnOnRight = 1; while(1) { drawFkeyLabels(0, 0x0186, 0, 0, 0, 0x012A); // NEW, TIME if(menu.numitems) { drawFkeyLabels(0x0235, -1, 0x0188, 0x0038); // FACTOR, RENAME, DELETE } int res = doMenu(&menu); switch(res) { case MENU_RETURN_EXIT: return; case KEY_CTRL_F1: if(!menu.numitems) break; case MENU_RETURN_SELECTION: viewTOTPcode(&ts[menu.selection-1]); break; case KEY_CTRL_F2: if(menu.numitems >= MAX_DAY_EVENTS) { AUX_DisplayErrorMessage(0x2E); } else { if(addTOTPwizard()) goto reload; } break; case KEY_CTRL_F3: if(menu.numitems && renameTOTPscreen(menu.selection-1, ts[menu.selection-1].name)) goto reload; break; case KEY_CTRL_F4: case KEY_CTRL_DEL: if(menu.numitems && deleteTOTPprompt(menu.selection-1)) goto reload; break; case KEY_CTRL_F6: setTimezone(); break; } } }
int64_t TimeStamp::Get(bool &error, int hou, int min, int sec, int mon, int day, int yea, bool gmt) { auto dt = req::make<DateTime>(Current()); if (gmt) { dt->setTimezone(req::make<TimeZone>("UTC")); } dt->set(hou, min, sec, mon, day, yea); return dt->toTimeStamp(error); }
void QFacebookGraphUser::requestDone(bool ok) { if(ok) { QVariantMap map = result(); QVariantMap::const_iterator i; for (i = map.constBegin(); i != map.constEnd(); ++i) { if(i.key() == "name" ) setName(i.value().toString()); if(i.key() == "hometown") setHometown(i.value().toMap()); if(i.key() == "last_name") setLastName(i.value().toString()); if(i.key() == "birthday") setBirthday(i.value().toString()); if(i.key() == "education") { QFacebookGraphCommonEducationModel *edu = new QFacebookGraphCommonEducationModel(); for (int j = 0; j < i.value().toList().size(); ++j) { edu->populate(i.value().toList().at(j).toMap()); m_education.append(edu); edu = new QFacebookGraphCommonEducationModel(); } } if(i.key() == "work") { QFacebookGraphCommonWorkModel *work = new QFacebookGraphCommonWorkModel(); for (int j = 0; j < i.value().toList().size(); ++j) { work->populate(i.value().toList().at(j).toMap()); m_work.append(work); work = new QFacebookGraphCommonWorkModel(); } } if(i.key() == "first_name") setFirstName(i.value().toString()); if(i.key() == "gender") setGender(i.value().toString()); if(i.key() == "id") setFbid(i.value().toString()); if(i.key() == "link") setLink(i.value().toString()); if(i.key() == "locale") setLocale(i.value().toString()); if(i.key() == "location") setLocation(i.value().toMap()); if(i.key() == "middle_name") setMiddleName(i.value().toString()); if(i.key() == "timezone") setTimezone(i.value().toLongLong()); if(i.key() == "updated_time") setUpdatedtime(i.value().toString()); if(i.key() == "verified") setVerified(i.value().toBool()); } emit modelPopulated(); } }
Object HHVM_METHOD(MongoDBBsonUTCDateTime, toDateTime) { int64_t milliseconds = this_->o_get(s_MongoBsonUTCDateTime_milliseconds, false, s_MongoBsonUTCDateTime_className).toInt64(); auto tmp_dt = req::make<DateTime>(milliseconds / 1000, true); tmp_dt->setTimezone(req::make<TimeZone>(String("UTC"))); String tmp_str = tmp_dt->toString("Y-m-d H:i:s"); /* Prepare result */ HPHP::Object obj{DateTimeData::getClass()}; DateTimeData* data = Native::data<DateTimeData>(obj.get()); data->m_dt = req::make<DateTime>(); data->m_dt->fromString(tmp_str + "." + String((int) (milliseconds % 1000) * 1000), req::make<TimeZone>(String("UTC"))); return obj; }
void viewTOTPcode(totp* tkn) { unsigned short key = 0; int keyCol, keyRow; Bdisp_AllClr_VRAM(); drawScreenTitle(tkn->name); int shown_since_beginning = 0; while(key != KEY_PRGM_EXIT && key != KEY_PRGM_LEFT) { int ThirtySecCode = computeTOTP(tkn); char buffer[10]; itoa_zeropad(tkn->totpcode, buffer, 6); long long int ms_spent_ll = currentUTCUEBT() - (long long int)ThirtySecCode * 30LL * 1000LL; int ms_spent = (int)(ms_spent_ll); drawCircularCountdownIndicator(LCD_WIDTH_PX/2, 104, 44, COLOR_BLACK, COLOR_WHITE, (ms_spent*43)/30000, getCurrentSecond() < 30 ? 0 : 1); // fade in/out animation for text int val = 0; if(ms_spent >= 29000) { val += (-29000 + ms_spent)/4; } else if (ms_spent <= 1020) { val += (1020 - ms_spent)/4; } int color = drawRGB24toRGB565(val, val, val); printCentered(buffer, 164, color, COLOR_WHITE); if(ms_spent < 2500) shown_since_beginning = 1; else if(ms_spent < 15000 && shown_since_beginning) DefineStatusMessage((char*)totpHelpMessages[(ms_spent-2500)/2500], 1, 0, 0); else DefineStatusMessage((char*)"", 1, 0, 0); DisplayStatusArea(); Bdisp_PutDisp_DD(); key = PRGM_GetKey(); if(key == KEY_PRGM_MENU) GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key); //this is here to handle the Menu key if(key == KEY_PRGM_OPTN) { DefineStatusMessage((char*)"", 1, 0, 0); GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key); // clear keybuffer RTCunadjustedWizard(0, 1); setTimezone(); return; // so we don't have to redraw etc. // Also, this way the Shift+Menu instruction shown in the adjustment wizard becomes vali // immediately, which is great if the user wants to repeat the adjustment. } } DefineStatusMessage((char*)"", 1, 0, 0); // clear keybuffer: GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key); }