MCPcopy Create free account
hub / github.com/Hashiao/wuwaBackendTool / initialCheck

Method initialCheck

mainwindow.cpp:537–606  ·  view source on GitHub ↗

启动时只检查一次:若无文件 / 被篡改 / 已过期 => 让用户输入密码重置

Source from the content-addressed store, hash-verified

535
536// 启动时只检查一次:若无文件 / 被篡改 / 已过期 => 让用户输入密码重置
537bool MainWindow::initialCheck()
538{
539 bool ok = false;
540 licStartTime = readLicenseFile(ok);
541
542 // 设置新时间
543 InternetTimeFetcher fetcher;
544 fetcher.fetchInternetTime(toolCurrentTime);
545 if(!toolCurrentTime.isValid()){
546 QMessageBox::critical(this, "错误", "无法联网获取时间");
547 //qApp->quit();
548 //std::exit(0);
549 return false;
550 }
551
552 if(!ok) {
553 // 文件不存在或被破坏 => 立即提示
554 QMessageBox::warning(this, "提示", "授权文件缺失或损坏,需要最高权限初始化。");
555 if(!requestAdminPassword("请输入最高权限密码:", this)) {
556 QMessageBox::critical(this, "错误", "密码错误");
557 //qApp->quit();
558 //std::exit(0);
559 return false;
560 }
561
562 //验证通过 写入lic
563 if(!writeLicenseFile(toolCurrentTime)) {
564 QMessageBox::critical(this, "错误", "写入授权文件失败 软件即将关闭");
565 //qApp->quit();
566 //std::exit(0);
567 return false;
568 }
569
570 licStartTime = toolCurrentTime;
571 }
572
573
574
575 // 检查是否已经过期
576 if(toolCurrentTime > licStartTime.addMSecs(MAX_MSECS)){
577 qWarning() << QString("toolCurrentTime > licStartTime.addMSecs(MAX_MSECS)");
578
579 this->m_mainBackendWorkerNew.stopWorker();
580 this->m_autoChangeWallpaperBackendWorker.stopWorker();
581
582 // 文件不存在或被破坏 => 立即提示
583 QMessageBox::warning(this, "提示", "软件有效期已过 后台线程均停止 要求输入密码");
584 if(!requestAdminPassword("请输入最高权限密码:", this)) {
585 QMessageBox::critical(this, "错误", "密码错误 软件即将关闭");
586 //qApp->quit();
587 //std::exit(0);
588 return false;
589 }
590
591 if(!writeLicenseFile(toolCurrentTime)) {
592 QMessageBox::critical(this, "错误", "写入授权文件失败 软件即将关闭");
593 //qApp->quit();
594 //std::exit(0);

Callers

nothing calls this directly

Calls 8

readLicenseFileFunction · 0.85
requestAdminPasswordFunction · 0.85
writeLicenseFileFunction · 0.85
isValidMethod · 0.80
setActivateStartTimeMethod · 0.80
setExpirationTimeMethod · 0.80
setCurrentTimeMethod · 0.80
stopWorkerMethod · 0.45

Tested by

no test coverage detected