Ejemplo n.º 1
0
bool SetupEvents::handleOptions(QCommandLineParser &clp)
{
    if (clp.isSet(cloInstall)) {
        setPathForAppDir(false);
        runUpdate("--createShortcut=GpxUi.exe", false);
        registerGcodeExtension();
        createGpxExeLink();
        return true;
    }
    else if(clp.isSet(cloUpdated)) {
        QDir dirSrc = GpxUiInfo::iniLocation();
        QDir dirDest = dirSrc;
        dirSrc.cdUp();

        QStringList slFilters;
        slFilters << "*.ini";

        QStringList sl = dirSrc.entryList(slFilters);
        int is = sl.size();
        while (is--) {
            QFile::copy(dirSrc.absoluteFilePath(sl[is]), dirDest.absoluteFilePath(sl[is]));
        }

        setPathForAppDir(false);
        registerGcodeExtension();
        createGpxExeLink();
        return true;
    }
    else if (clp.isSet(cloObsolete)) {
        setPathForAppDir(true);
        return true;
    }
    else if (clp.isSet(cloUninstall)) {
        runUpdate("--removeShortcut=GpxUi.exe", true);
        setPathForAppDir(true);
        unregisterGcodeExtension();
        return true;
    }
    else if (clp.isSet(cloFirstRun)) {
    }

    return false;
}
Ejemplo n.º 2
0
    void run() {
        // Run the update.
        {
            Client::WriteContext ctx(&_txn, ns());
            Client& c = cc();
            CurOp& curOp = *c.curop();
            OpDebug* opDebug = &curOp.debug();
            UpdateDriver driver( (UpdateDriver::Options()) );
            Database* db = ctx.ctx().db();

            // Collection should be empty.
            ASSERT_EQUALS(0U, count(BSONObj()));

            UpdateRequest request(&_txn, nsString());
            UpdateLifecycleImpl updateLifecycle(false, nsString());
            request.setLifecycle(&updateLifecycle);

            // Update is the upsert {_id: 0, x: 1}, {$set: {y: 2}}.
            BSONObj query = fromjson("{_id: 0, x: 1}");
            BSONObj updates = fromjson("{$set: {y: 2}}");

            request.setUpsert();
            request.setQuery(query);
            request.setUpdates(updates);

            ASSERT_OK(driver.parse(request.getUpdates(), request.isMulti()));

            // Setup update params.
            UpdateStageParams params(&request, &driver, opDebug);
            scoped_ptr<CanonicalQuery> cq(canonicalize(query));
            params.canonicalQuery = cq.get();

            scoped_ptr<WorkingSet> ws(new WorkingSet());
            auto_ptr<EOFStage> eofStage(new EOFStage());

            scoped_ptr<UpdateStage> updateStage(
                new UpdateStage(params, ws.get(), db, eofStage.release()));

            runUpdate(updateStage.get());
            ctx.commit();
        }

        // Verify the contents of the resulting collection.
        {
            Client::ReadContext ctx(&_txn, ns());
            Collection* collection = ctx.ctx().db()->getCollection(&_txn, ns());

            vector<BSONObj> objs;
            getCollContents(collection, &objs);

            // Expect a single document, {_id: 0, x: 1, y: 2}.
            ASSERT_EQUALS(1U, objs.size());
            ASSERT_EQUALS(objs[0], fromjson("{_id: 0, x: 1, y: 2}"));
        }
    }
Ejemplo n.º 3
0
void loop() {
  if (safeMode) { // safeMode engaged, enter blocking loop wait for an OTA update
    int safeDelay=30000; // five minutes in 100ms counts
    while (safeDelay--) {
      ArduinoOTA.handle();
      delay(100);
    }
    ESP.reset(); // restart, try again
    delay(5000); // give esp time to reboot
  }

  if(wifiMulti.run() != WL_CONNECTED) { // reboot if wifi connection drops
      ESP.reset();
      delay(5000);
  }

  if (!mqtt.connected()) {
    mqttreconnect(); // check mqqt status
  }

  doTick();

  if (hasRSSI) doRSSI();
  if (hasTout) doTout();
  if (hasVout) doVout();
  if (hasIout) doIout();
  if (getRGB) doRGBout();
  if (hasSpeed) doSpeed();

  if ( (doUpdate) || (updateCnt>= 60 / ((updateRate * 20) / 1000) ) ) runUpdate(); // check for config update as requested or every 60 loops

  if (wsConcount>0) wsData();
  if (useMQTT) mqttData(); // regular update for non RGB controllers
  if (prtConfig) printConfig(); // config print was requested

  sprintf(str,"Sleeping in %u seconds.", (updateRate*20/1000));
  if ((!skipSleep) && (sleepEn)) {
    if (useMQTT) mqtt.publish(mqttpub, str);
  }

  int cnt = 30;
  if (updateRate>30) cnt=updateRate;
  while(cnt--) {
    ArduinoOTA.handle();
    if (useMQTT) mqtt.loop();

#ifndef _MINI
    httpd.handleClient();
#endif
    webSocket.loop();

    if (getTime) updateNTP(); // update time if requested by command
    if (scanI2C) i2c_scan();

    if (hasRGB) doRGB(); // rgb updates as fast as possible
    if (rgbTest) testRGB();

#ifndef _MINI

    if (doUpload) { // upload file to spiffs by command
      doUpload = false; fileSet = false;
      int stat = uploadFile(fileName, fileURL);
      sprintf(str, "Upload complete: %s %d bytes.",fileName,stat);
      if (useMQTT) mqtt.publish(mqttpub, str);
    }
#endif

    if (setPolo) {
      setPolo = false; // respond to an mqtt 'ping' of sorts
      if (useMQTT) mqtt.publish(mqttpub, "Polo");
    }

    if (doReset) { // reboot on command
      if (useMQTT) {
        mqtt.publish(mqttpub, "Rebooting!");
        mqtt.loop();
      }
      delay(50);
      ESP.reset();
      delay(5000); // allow time for reboot
    }

    if (!hasRGB) delay(20); // don't delay for rgb controller
  }

  if ((!skipSleep) && (sleepEn)) {
    if ((sleepPeriod<60) || (sleepPeriod>43200)) sleepPeriod=900; // prevent sleeping for less than 1 minute or more than 12 hours
    sprintf(myChr,"Back in %d minutes", sleepPeriod/60);
    if (useMQTT) {
      mqtt.publish(mqttpub, myChr);
      mqtt.loop();
    }

    ESP.deepSleep(1000000 * sleepPeriod, WAKE_RF_DEFAULT); // sleep for 15 min
    delay(5000); // give esp time to fall asleep

  }
  skipSleep = false;
  updateCnt++;
}
Ejemplo n.º 4
0
void UpdateChecker::readUpdateData(const QByteArray &data)
{
	const QStringList activeChannels = SettingsManager::getValue(QLatin1String("Updates/ActiveChannels")).toStringList();
	const QJsonObject updateData = QJsonDocument::fromJson(data).object();
	const QJsonArray channels = updateData.value(QLatin1String("channels")).toArray();
	int mainVersion = QCoreApplication::applicationVersion().remove(QChar('.')).toInt();
	int subVersion = QString(OTTER_VERSION_WEEKLY).toInt();
	QString availableVersion;
	QString availableChannel;

	for (int i = 0; i < channels.count(); ++i)
	{
		if (channels.at(i).isObject())
		{
			const QJsonObject object = channels.at(i).toObject();
			const QString identifier = object["identifier"].toString();
			const QString channelVersion = object["version"].toString();

			if (activeChannels.contains(identifier, Qt::CaseInsensitive))
			{
				const int channelMainVersion = channelVersion.trimmed().remove(QChar('.')).toInt();

				if (channelMainVersion == 0)
				{
					Console::addMessage(QCoreApplication::translate("main", "Unable to parse version number: %1").arg(channelVersion), OtherMessageCategory, ErrorMessageLevel);

					continue;
				}

				const int channelSubVersion = object["subVersion"].toString().toInt();

				if ((mainVersion < channelMainVersion) || (channelSubVersion > 0 && subVersion < channelSubVersion))
				{
					mainVersion = channelMainVersion;
					subVersion = channelSubVersion;
					availableVersion = channelVersion;
					availableChannel = identifier;
					m_detailsUrl = object["detailsUrl"].toString();
				}
			}
		}
	}

	SettingsManager::setValue(QLatin1String("Updates/LastCheck"), QDate::currentDate().toString(Qt::ISODate));

	if (!availableVersion.isEmpty())
	{
		const QString text = tr("New update %1 from %2 channel is available!").arg(availableVersion).arg(availableChannel);

		if (m_showDialog)
		{
			QMessageBox messageBox;
			messageBox.setWindowTitle(tr("New version of Otter Browser is available"));
			messageBox.setText(text);
			messageBox.setInformativeText(tr("Do you want to open a new tab with download page?"));
			messageBox.setIcon(QMessageBox::Question);
			messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
			messageBox.setDefaultButton(QMessageBox::No);

			if (messageBox.exec() == QMessageBox::Yes)
			{
				runUpdate();
			}
			else
			{
				deleteLater();
			}
		}
		else
		{
			Notification *updateNotification = NotificationsManager::createNotification(NotificationsManager::UpdateAvailableEvent, text);

			connect(updateNotification, SIGNAL(clicked()), this, SLOT(runUpdate()));
			connect(updateNotification, SIGNAL(ignored()), this, SLOT(deleteLater()));
		}
	}
	else
	{ 
		deleteLater();
	}
}