예제 #1
0
//_____________________________________
// Read user input and act on it
bool controlMode( char ch ) {
    static int arg = -1;
    int retval = false;
    if (isdigit( ch )) {
      if (arg < 0) arg = 0;
      arg = arg * 10 + (ch - '0');
      return false;
    }
    switch ( ch ) {
    // 'N' triggers the NTP protocol manually
    case 'N': case 'n': triggerNtp() ; retval = true ; break ;

    // Left-arrow (Less-Than) slows down the clock for simulation runs
    case '<': case ',': slowDown() ;   retval = true ; break ;

    // Right-arrow (Greater-Than) speeds up the clock for simulation runs
    case '>': case '.': speedUp() ;    retval = true ; break ;

    // PLUS advances the digital clock minute
    case '+': case '=': incMinutes() ; retval = true ; break ;

    // MINUS decrements the digital clock minute
    case '_': case '-': decMinutes() ; retval = true ; break ;

    // H, M, S set hours, minutes, seconds
    case 'H': case 'h': if (arg >= 0) setHours(arg);                retval = true ;      break ;
    case 'M': case 'm': if (arg >= 0) setMinutes(arg);              retval = true ;      break ;
    case 'S': case 's': if (arg >= 0) setSeconds(arg); syncTime() ; retval = true ;      break ;

    // 'Z' resets the digital clock seconds
    case 'z': case 'Z': setSeconds(0) ; syncTime() ; return true ;

    // A, B and C manually force the A/B output pulses but do not affect the internal clock
    // A and B add to the force count for the A and B signals.  C adds to both signals.
    case 'A': case 'a': if (arg < 0) arg = 1 ;    sendPulsesA(arg) ;                     break ;
    case 'B': case 'b': if (arg < 0) arg = 1 ;    sendPulsesB(arg) ;                     break ;
    case 'C': case 'c': if (arg < 0) arg = 1 ;    sendPulsesA(arg) ;  sendPulsesB(arg) ; break ;
    case 'D': case 'd': if (arg < 0) arg = 1 ;    sendPulsesD(arg) ;                     break ;
    case 'E': case 'e':                           sendPulsesE(1)   ;                     break ;

    case 'f':                                     setState(LOW);                         break ;
    case 'F':                                     setState(HIGH);                        break ;

    case 'I': case 'i': if (arg < 0) arg = 60*60; clockHold(arg, arg) ;                  break ;
    case 'U': case 'u': if (arg < 0) arg = 60*60; clockHold(arg, 0) ;                    break ;
    case 'V': case 'v': if (arg < 0) arg = 60*60; clockHold(0, arg) ;                    break ;
    default: break;
  }
  arg = -1;
  return retval ;
}
예제 #2
0
static bool syncSaveGameHeader(Common::Serializer &s, SaveGameHeader &hdr) {
	s.syncAsUint32LE(hdr.id);
	s.syncAsUint32LE(hdr.size);
	s.syncAsUint32LE(hdr.ver);

	s.syncBytes((byte *)hdr.desc, SG_DESC_LEN);
	hdr.desc[SG_DESC_LEN - 1] = 0;

	syncTime(s, hdr.dateTime);

	int tmp = hdr.size - s.bytesSynced();

	// NOTE: We can't use SAVEGAME_ID here when attempting to remove a saved game from the launcher,
	// as there is no TinselEngine initialized then. This means that we can't check if this is a DW1
	// or DW2 savegame in this case, but it doesn't really matter, as the saved game is about to be
	// deleted anyway. Refer to bug #3387551.
	bool correctID = _vm ? (hdr.id == SAVEGAME_ID) : (hdr.id == DW1_SAVEGAME_ID || hdr.id == DW2_SAVEGAME_ID);

	// Perform sanity check
	if (tmp < 0 || !correctID || hdr.ver > CURRENT_VER || hdr.size > 1024)
		return false;
	// Skip over any extra bytes
	s.skip(tmp);
	return true;
}
예제 #3
0
static bool syncSaveGameHeader(Common::Serializer &s, SaveGameHeader &hdr) {
	s.syncAsUint32LE(hdr.id);
	s.syncAsUint32LE(hdr.size);
	s.syncAsUint32LE(hdr.ver);

	s.syncBytes((byte *)hdr.desc, SG_DESC_LEN);
	hdr.desc[SG_DESC_LEN - 1] = 0;

	syncTime(s, hdr.dateTime);

	int tmp = hdr.size - s.bytesSynced();

	// NOTE: We can't use SAVEGAME_ID here when attempting to remove a saved game from the launcher,
	// as there is no TinselEngine initialized then. This means that we can't check if this is a DW1
	// or DW2 savegame in this case, but it doesn't really matter, as the saved game is about to be
	// deleted anyway. Refer to bug #3387551.
	bool correctID = _vm ? (hdr.id == SAVEGAME_ID) : (hdr.id == DW1_SAVEGAME_ID || hdr.id == DW2_SAVEGAME_ID);

	// Perform sanity check
	if (tmp < 0 || !correctID || hdr.ver > CURRENT_VER || hdr.size > 1024)
		return false;

	if (tmp > 0) {
		// If there's header space left, handling syncing the Scn flag and game language
		s.syncAsByte(hdr.scnFlag);
		s.syncAsByte(hdr.language);
		tmp -= 2;

		if (_vm && s.isLoading()) {
			// If the engine is loaded, ensure the Scn/Gra usage is correct, and it's the correct language
			if ((hdr.scnFlag != ((_vm->getFeatures() & GF_SCNFILES) != 0)) ||
					(hdr.language != _vm->_config->_language))
				return false;
		}
	}

	// Handle the number of interpreter contexts that will be saved in the savegame
	if (tmp >= 2) {
		tmp -= 2;
		hdr.numInterpreters = NUM_INTERPRET;
		s.syncAsUint16LE(hdr.numInterpreters);
	} else {
		hdr.numInterpreters = (TinselV2 ? 70 : 64) - 20;
	}

	// Skip over any extra bytes
	s.skip(tmp);
	return true;
}
예제 #4
0
void MConfig::applyDesktop() {

  if (toUserComboBox->currentText().isEmpty()) {
    QMessageBox::information(0, QString::null,
      tr("You must specify a 'copy to' destination. You can not copy to the desktop you are logged in to."));
    return;
  }
  // verify
  int ans = QMessageBox::critical(0, QString::null, tr("Before copying, close all other applications. Be sure the copy to destination is large enough to contain the files you are copying. Copying between desktops may overwrite or delete your files or preferences on the destination desktop. Are you sure you want to proceed?"),
    tr("Yes"), tr("No"));
  if (ans != 0) {
    return;
  }

  QString fromDir = QString("/home/%1").arg(fromUserComboBox->currentText());
  QString toDir = QString("/home/%1").arg(toUserComboBox->currentText());
  if (docsRadioButton->isChecked()) {
    fromDir.append("/Documents");
    toDir.append("/Documents");
  } else if (qupRadioButton->isChecked()) {
    fromDir.append("/.config/.qupzilla");
    toDir.append("/.config/.qupzilla");
  } else if (sharedRadioButton->isChecked()) {
    fromDir.append("/Shared");
    toDir.append("/Shared");
  }
  fromDir.append("/");

  setCursor(QCursor(Qt::WaitCursor));
  if (syncRadioButton->isChecked()) {
    syncStatusEdit->setText(tr("Synchronizing desktop..."));
  } else {
    syncStatusEdit->setText(tr("Copying desktop..."));
  }
  disconnect(timer, SIGNAL(timeout()), 0, 0);
  connect(timer, SIGNAL(timeout()), this, SLOT(syncTime()));
  disconnect(proc, SIGNAL(started()), 0, 0);
  connect(proc, SIGNAL(started()), this, SLOT(syncStart()));
  disconnect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), 0, 0);
  connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(syncDone(int, QProcess::ExitStatus)));
  QString cmd = QString("rsync -qa ");
  if (syncRadioButton->isChecked()) {
    cmd.append("--delete-after ");
  }
  cmd.append(fromDir);
  cmd.append(" ");
  cmd.append(toDir);
  proc->start(cmd);
}
예제 #5
0
void SwitchScheduler::tock()
{
    if (configuration == NULL)
    {
        DEBUG_PRINT("Configuration not set.");
        return;
    }

    if (lastLoopCheck == 0)
    {
        uint32_t tNow = rtc->now();
        while (rtc->second(tNow) != 0)
        {
            DEBUG_PRINT("Second: ");
            DEBUG_PRINT(rtc->second(tNow));
            DEBUG_PRINT("\n");
            DEBUG_PRINT(rtc->ISODateString(rtc->now()) + "\n");
            SPARK_WLAN_Loop();
            delay(1000);
            tNow = rtc->now();
        }
    }

    unsigned long now = millis();

    if (now - lastLoopCheck >= checkLoopInterval ||
        lastLoopCheck == 0)
    {
        DEBUG_PRINT("Tock...");
        DEBUG_PRINT(rtc->ISODateString(rtc->now()) + "\n");

        // Sync the time daily.
        syncTime();

        // Try to get the astronomy data if it's time.
        retrieveAstronomyData();

        if (isSchedulerEnabled())
        {
            // Turn on/off the outlet switch if it's time.
            checkSchedulerTasks();
        }

        lastLoopCheck = now;
    }
}
예제 #6
0
static bool syncSaveGameHeader(Common::Serializer &s, SaveGameHeader &hdr) {
	s.syncAsUint32LE(hdr.id);
	s.syncAsUint32LE(hdr.size);
	s.syncAsUint32LE(hdr.ver);

	s.syncBytes((byte *)hdr.desc, SG_DESC_LEN);
	hdr.desc[SG_DESC_LEN - 1] = 0;

	syncTime(s, hdr.dateTime);

	int tmp = hdr.size - s.bytesSynced();
	// Perform sanity check
	if (tmp < 0 || hdr.id != SAVEGAME_ID || hdr.ver > CURRENT_VER || hdr.size > 1024)
		return false;
	// Skip over any extra bytes
	s.skip(tmp);
	return true;
}
예제 #7
0
int midParseStruct(int identifier,int fd, char *data, int len)
{
	int recvlen;
	int cmd = 0;
	//char *actualdata = NULL;
	char actualdata[1024] = {0};
	char out[2048] = {0};
	int  vallen = 0;
	int  status = 0;
	int  ret = 0;


	char senddata[1024] = {0};
	int totallen = 0;

	int web_ret = SERVER_RET_OK;
	int need_send = 0;


	recvlen = recv(fd, data, len, 0);

	if(recvlen < 0) {
		DEBUG(DL_ERROR, "recv failed,errno = %d,error message:%s \n", errno, strerror(errno));
		//return -1;
		web_ret = SERVER_RET_INVAID_PARM_LEN;
		status = -1;
		goto EXIT;
	}

	vallen = len - sizeof(int);
	//actualdata = (char *)malloc(vallen);
	memcpy(&cmd, data, sizeof(int));
	memcpy(actualdata, data + sizeof(int), len - sizeof(int));
	//PRINTF("cmd = 0x%04x,vallen=%d=len=%d\n", cmd, vallen, len);

	switch(cmd) {

		case MSG_SETOUTPUTVIDEOINFO:
			PRINTF("cmd = 0x%04x is MSG_SETOUTPUTVIDEOINFO.\n", cmd);
			setOutputVideoInfo(identifier,fd, cmd, actualdata, vallen);
			break;

		case MSG_GETOUTPUTVIDEOINFO:
			PRINTF("cmd = 0x%04x is MSG_GETOUTPUTVIDEOINFO.\n", cmd);
			getOutputVideoInfo(identifier,fd, cmd, actualdata, vallen);
			break;

		case MSG_GETVIDEOPARAM:
			PRINTF("cmd = 0x%04x is MSG_GETVIDEOPARAM.\n", cmd);
			GetVideoParam_1260(identifier,fd, cmd, actualdata, vallen);
			break;

		case MSG_GETAUDIOPARAM:
			PRINTF("cmd = 0x%04x is MSG_GETAUDIOPARAM.\n", cmd);
			GetAudioParam_1260(identifier,fd, cmd, actualdata, vallen);
			break;

		case MSG_GETSYSPARAM:
			PRINTF("cmd = 0x%04x is MSG_GETSYSPARAM.\n", cmd);
			getSysParams(identifier,fd, cmd, actualdata, vallen);
			break;

		case MSG_SETSYSPARAM:
			PRINTF("cmd = 0x%04x is MSG_SETSYSPARAM.\n", cmd);
			setSysParams(identifier,fd, cmd, actualdata, vallen);
			break;

		case MSG_SETVIDEOPARAM:
			PRINTF("cmd = 0x%04x is MSG_SETVIDEOPARAM.\n", cmd);
			setVideoParam_1260(identifier,fd, cmd, actualdata, vallen);
			break;

		case MSG_SETAUDIOPARAM:
			PRINTF("cmd = 0x%04x is MSG_SETAUDIOPARAM.\n", cmd);
			setAudioParam_1260(identifier,fd, cmd, actualdata, vallen);
			break;

		case MSG_SYNCTIME:
			PRINTF("cmd = 0x%04x is MSG_SYNCTIME.\n", cmd);
			syncTime(identifier,fd, cmd, actualdata, vallen);
			break;

		case MSG_GET_PROTOCOL:
			PRINTF("cmd = 0x%04x is MSG_GET_PROTOCOL.\n", cmd);
			getProtocol(identifier,fd, cmd, actualdata, vallen);
			break;

		case MSG_GET_LOGOINFO:
			PRINTF("cmd = 0x%04x is MSG_GET_LOGOINFO.\n", cmd);
			ret = getLogoInfo(actualdata, vallen, out);

			if(ret == 0) {
				web_ret = SERVER_RET_INVAID_PARM_VALUE;
			}

			need_send = 1;
			break;

		case MSG_SET_LOGOINFO:
			PRINTF("cmd = 0x%04x is MSG_SET_LOGOINFO.\n", cmd);
			ret = setLogoInfo(actualdata, vallen, out);

			if(ret == -1) {
				web_ret = SERVER_RET_INVAID_PARM_LEN;
			}

			if(ret == -2) {
				web_ret = SERVER_RET_INVAID_PARM_VALUE;
			}

			need_send  = 1;
			break;

		case MSG_GET_TEXTINFO:
			PRINTF("cmd = 0x%04x is MSG_GET_TEXTINFO.\n", cmd);
			ret = getTextInfo(actualdata, vallen, out);

			if(ret == -1) {
				web_ret = SERVER_RET_INVAID_PARM_VALUE;
			}

			need_send = 1;
			break;

		case MSG_SET_TEXTINFO:
			PRINTF("cmd = 0x%04x is MSG_SET_TEXTINFO.\n", cmd);
			ret = setTextInfo(actualdata, vallen, out);
			need_send = 1;
			break;

		case MSG_GETENCODETIME:
			PRINTF("cmd = 0x%04x is MSG_GETENCODETIME.\n", cmd);
			getEncodeTime(identifier,fd, cmd, actualdata, vallen);
			break;



		case MSG_RTSP_GET_GINFO:
		case MSG_RTSP_SET_GINFO:
		case MSG_RTSP_GET_CINFO:
		case MSG_RTSP_SET_CINFO:
		case MSG_RTSP_ADD_SERVER:
		case MSG_MULT_ADD_SERVER:
		case MSG_MULT_GET_CINFO:
		case MSG_MULT_SET_CINFO:
		case MSG_RTSP_SET_STATUS:
		case MSG_MULT_SET_STATUS:
		case MSG_MULT_DEL_SERVER:
			PRINTF("cmd = 0x%04x is MSG_STREAMOUTPUT\n", cmd);
			app_web_stream_output_process_struct(identifier,fd, cmd, actualdata, vallen);
			break;

		default:
			PRINTF("UNKOWN cmd %d\n", cmd);
			break;

	}

	if(ret < 0) {
		web_ret = SERVER_RET_INVAID_PARM_VALUE;
	}

EXIT:

	if(need_send == 1) {
		totallen = MSGINFOHEAD + sizeof(cmd) + sizeof(web_ret) + vallen;
		msgPacket(identifier,senddata, STRING_TYPE, totallen, cmd, web_ret);
		memcpy(senddata + (totallen - vallen), out, vallen);
		PRINTF("the cmd =%04x,,the ret=%04x\n", cmd,  web_ret);
		send(fd, senddata, totallen, 0);
	}

	//	free(actualdata);
	return status;
}