Exemplo n.º 1
0
bool CCommandLine::Parse()
{
	int res = m_parser.Parse(false);
	if (res != 0)
		return false;
		
	if (HasSwitch(sitemanager) && GetOption(site) != _T(""))
	{
		wxMessageBox(_("-s and -c cannot be present at the same time."), _("Syntax error in command line"));
		return false;
	}

	if (HasSwitch(sitemanager) && m_parser.GetParamCount())
	{
		wxMessageBox(_("-s cannot be used together with an FTP URL."), _("Syntax error in command line"));
		return false;
	}

	if (GetOption(site) != _T("") && m_parser.GetParamCount())
	{
		wxMessageBox(_("-c cannot be used together with an FTP URL."), _("Syntax error in command line"));
		return false;
	}

	if (m_parser.Found(_T("verbose")))
		wxLog::SetVerbose(true);

	return true;
}
Exemplo n.º 2
0
int CCmdLine::GetArgumentCount(const char *pSwitch)
{
   int iArgumentCount = -1;

   if (HasSwitch(pSwitch))
   {
	   CCmdLine::iterator theIterator;

      theIterator = find(pSwitch);
	   if (theIterator!=end())
      {
         iArgumentCount = (*theIterator).second.m_strings.size();
      }
   }

   return iArgumentCount;
}
Exemplo n.º 3
0
StringType CCmdLine::GetArgument(const char *pSwitch, idx iIdx)
{
    if (HasSwitch(pSwitch)) {
	CCmdLine::iterator theIterator;

	theIterator = find(pSwitch);
	if (theIterator!=end()) {
	    if ((*theIterator).second.m_strings.size() > iIdx) {
		return (*theIterator).second.m_strings[iIdx];
	    }
	}
    }

    throw (int)0;

    return "";
}
Exemplo n.º 4
0
StringType CCmdLine::GetArgument(const char *pSwitch, size_t iIdx)
{
   if (HasSwitch(pSwitch))
   {
      CCmdLine::iterator theIterator;

      theIterator = find(pSwitch);
      if (theIterator!=end())
      {
         if ((*theIterator).second.m_strings.size() > iIdx)
         {
            return (*theIterator).second.m_strings[iIdx];
         }
      }
   }

   throw std::runtime_error( "CCmdLine::GetArgument: error" );

   return "";
}
Exemplo n.º 5
0
// Returns the application settings based on command line arguments.
void AppGetSettings(CefSettings& settings, CefRefPtr<CefCommandLine> command_line) {
  DCHECK(command_line.get());
  if (!command_line.get())
    return;

#if defined(OS_WIN)
  settings.multi_threaded_message_loop =
      command_line->HasSwitch(client::switches::kMultiThreadedMessageLoop);
#endif

  CefString(&settings.cache_path) =
      command_line->GetSwitchValue(client::switches::kCachePath);
  CefString(&settings.log_file) =
      command_line->GetSwitchValue(client::switches::kLogFile);

  {
    std::string str = command_line->GetSwitchValue(client::switches::kLogSeverity);

    // Default to LOGSEVERITY_DISABLE
    settings.log_severity = LOGSEVERITY_DISABLE;

    if (!str.empty()) {
      if (str == client::switches::kLogSeverity_Verbose)
        settings.log_severity = LOGSEVERITY_VERBOSE;
      else if (str == client::switches::kLogSeverity_Info)
        settings.log_severity = LOGSEVERITY_INFO;
      else if (str == client::switches::kLogSeverity_Warning)
        settings.log_severity = LOGSEVERITY_WARNING;
      else if (str == client::switches::kLogSeverity_Error)
        settings.log_severity = LOGSEVERITY_ERROR;
      else if (str == client::switches::kLogSeverity_Disable)
        settings.log_severity = LOGSEVERITY_DISABLE;
    }
  }

  // Don't update the settings.locale with the locale that we detected from the OS.
  // Otherwise, CEF will use it to find the resources and when it fails in finding resources
  // for some locales that are not available in resources, it crashes.
  //CefString(&settings.locale) = appshell::GetCurrentLanguage( );

  CefString(&settings.javascript_flags) =
      command_line->GetSwitchValue(client::switches::kJavascriptFlags);
    
  // Enable dev tools
  settings.remote_debugging_port = REMOTE_DEBUGGING_PORT;
  
  std::wstring versionStr = appshell::AppGetProductVersionString();
    
  if (!versionStr.empty()) {
    // Explicitly append the Chromium version to our own product version string
    // since assigning product version always replaces the Chromium version in
    // the User Agent string.
    versionStr.append(L" ");
    versionStr.append(appshell::AppGetChromiumVersionString());
      
    // Set product version, which gets added to the User Agent string
    CefString(&settings.product_version) = versionStr;
  }

#ifdef OS_WIN
  // We disable renderer accessibility by default as it is known to cause performance
  // issues. But if any one wants to enable it back, then we need to honor the flag.

  CefString force_acc_switch_name("--force-renderer-accessibility");
  CefString enable_acc_switch_name("--enable-renderer-accessibility");

  if (HasSwitch(command_line, force_acc_switch_name) || HasSwitch(command_line, enable_acc_switch_name))
    g_force_enable_acc = true;
#endif

}