Exemple #1
1
void ViewerCmdLine::parse()
{
  const CmdLineOption options[] = {
    HELP,
    HELP_SHORT,
    OPTIONS_FILE,
    LISTEN,
    HOST,
    PORT,
    PASSWORD,
    SHOW_CONTROLS,
    VIEW_ONLY,
    USE_CLIPBOARD,
    SCALE,
    FULL_SCREEN,
    WARN_FULL_SCREEN,
    ENCODING,
    COPY_RECT,
    MOUSE_CURSOR,
    MOUSE_LOCAL,
    MOUSE_SWAP,
    JPEG_IMAGE_QUALITY,
    COMPRESSION_LEVEL
  };

  if (!processCmdLine(&options[0], sizeof(options) / sizeof(CmdLineOption))) {
    throw CommandLineFormatException();
  }

  if (isHelpPresent()) {
    throw CommandLineFormatHelp();
  }


  if (m_wpcl.getArgumentsCount() > 2) {
    throw CommandLineFormatException();
  }

  if (m_wpcl.getArgumentsCount() > 1) {
    if (isPresent(ViewerCmdLine::HOST)) {
      throw CommandLineFormatException();
    }
  }

  if (isPresent(ViewerCmdLine::OPTIONS_FILE)) {
    parseOptionsFile();
  } else {
    if (isPresent(ViewerCmdLine::LISTEN)) {
      *m_isListening = true;
    } else {
      if (!parseHost()) {
        throw CommandLineFormatException();
      }
    }
  }
  parsePassword();
  parseEncoding();
  parseMouseShape();
  parseMouseCursor();
  parseScale();
  parseFullScreen();
  parseCompressionLevel();
  parseWarnFullScr();
  parseMouseSwap();
  parseUseClipboard();
  parseShowControl();
  parseCopyRect();
  parseViewOnly();
  parseJpegImageQuality();
}
bool AndroidInputServer::initialize(int argc, char* argv[]) {
	// parse arguments, daemonize, create device handlers, ready sockets

	if ( !parseOptions(argc, argv) ) {
		logger->error("Error parsing parametres");
		return false;
	}

	if ( !parseOptionsFile() ) {
		logger->error("Error in config file");
		return false;
	}

	if ( !getDefaultPaths() ) {
		logger->error("Error setting options");
		return false;
	}

	if (debug) {
		logger->printMessage("08.12.2011 16:25:02 Options parsed");
	}

	if (!semaphoresInit()) {
		logger->error("13.12.2011 21:17:54 Semaphore initialization failed");
		return false;
	}

	if ( isDaemon ) {
		if (!daemonize()) {
			logger->error("06.12.2011 01:34:59 daemonize() error");
			return false;
		}
	}

	if (isDaemon && debug) {
		logger->printMessage("06.12.2011 01:40:39 Daemonized");
	}

	if ( !readySocket(&keyboardListeningSocket, &keyboardServerAddress, keyboardListeningPort) ) {
		logger->error("08.12.2011 16:20:59 readySocket() error");
		return false;
	}

	if ( !readySocket(&mouseListeningSocket, &mouseServerAddress, mouseListeningPort) ) {
		logger->error("12.11.2012 10:00:01 readySocket() error");
		return false;
	}

	if (debug) {
		logger->printMessage("08.12.2011 16:27:10 listeningSocket bound");
	}

	return true;
}