TVerdict CSMCMStepInitialise::doTestStepL( )
	{
	INFO_PRINTF1( _L( "CSMCMStepInitialise::doTestStepL( )" ) );
	
	SetTestStepResult( EFail );
	
	ChangeLocale( KUTC0 );
	
	// first delete any old SMS service
	iSmsTestUtils->DeleteSmsServiceL( );
	
	// create a new SMS service (this will be time stamped UTC)
	TMsvId serviceId = KMsvNullIndexEntryId;
	serviceId = iSmsTestUtils->CreateSmsServiceL( );
	
	iSmsTestUtils->iSmsClientMtm->SwitchCurrentEntryL( serviceId );
	TMsvEntry serviceEntry = iSmsTestUtils->iSmsClientMtm->Entry( ).Entry( );

	// Change locale to UTC -8
	ChangeLocale( KUTCMin8 );
	TTime now;
	now.UniversalTime( );

	// Check if current time is bigger than time when service was created
	if ( serviceEntry.iDate < now )
		{
		SetTestStepResult( EPass );	
		
		}
	
	// if locale isn't changed the log file timestamps will be out of order 
	// as they are in local time
	ChangeLocale( KUTC0 );
	
	return TestStepResult( );
	
	}
예제 #2
0
파일: main.cpp 프로젝트: tanaga9/appetizer
/**
 * Initialize the application
 */
bool MiniLaunchBar::OnInit() {
  //_CrtSetBreakAlloc(18609);  

  // Remove GUI log errors
  delete wxLog::SetActiveTarget(new wxLogStderr());

  #ifdef __WINDOWS__
  osInfo_.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  BOOL gotInfo = GetVersionEx(&osInfo_);
  if (!gotInfo) {
    osInfo_.dwMajorVersion = 5; // Assume Windows 2000
    osInfo_.dwMinorVersion = 0;
  }  
  #endif // __WINDOWS__

  TiXmlBase::SetCondenseWhiteSpace(false);

  singleInstanceChecker_ = NULL;
  mainFrame_ = NULL;
  locale_ = NULL;
  pluginManager_ = NULL;
  ftLibrary_ = NULL;
  ftFace_ = NULL;
  stopWatch_.Start();
  user_ = new User();

  allowedIconSizes_.push_back(SMALL_ICON_SIZE);
  allowedIconSizes_.push_back(MEDIUM_ICON_SIZE);
  allowedIconSizes_.push_back(LARGE_ICON_SIZE);
  allowedIconSizes_.push_back(EXTRA_LARGE_ICON_SIZE);

  // ***********************************************************************************
  // Initialize the command line object
  // ***********************************************************************************

  wxCmdLineEntryDesc cmdLineDesc[] = {
    { wxCMD_LINE_SWITCH, _T("u"), _T("useuserdatadir"), _("Uses user data directory to save settings.") },
    { wxCMD_LINE_OPTION, _T("d"), _T("datapath"),  _("Sets user data path (-u will be ignored)") },
    { wxCMD_LINE_SWITCH, _T("l"), _T("logwindow"), _("Displays the log window (useful for debugging)") },
    { wxCMD_LINE_SWITCH, _T("?"), _T("help"), _("Displays this help message") },
    { wxCMD_LINE_NONE }
  };

  fileCommandLine_.SetDesc(cmdLineDesc);  

  wxFileName executablePath = wxFileName(wxStandardPaths().GetExecutablePath());
  wxString applicationDirectory = executablePath.GetPath();
  wxString argumentsFilePath = applicationDirectory + _T("/Arguments.txt");

  if (wxFileName::FileExists(argumentsFilePath)) {

    wxTextFile file;
    bool success = file.Open(argumentsFilePath);
    if (!success) {
      ELOG(_T("Couldn't open ") + argumentsFilePath);
    } else {
      wxString line;
      wxString fileArgv;

      for (line = file.GetFirstLine(); !file.Eof(); line = file.GetNextLine()) {
        line = line.Trim(true).Trim(false);
        if (line == wxEmptyString) continue;        
        fileArgv += _T(" ") + line;        
      }

      fileCommandLine_.SetCmdLine(fileArgv);
      fileCommandLine_.Parse();
    }

  }

  commandLine_.SetDesc(cmdLineDesc);
  commandLine_.SetCmdLine(argc, argv);
  commandLine_.Parse(); 

  if (commandLine_.Found(_T("?"))) commandLine_.Usage();

  // Required to enable PNG support
  wxInitAllImageHandlers();

  // Setting this option to "0" removed the flickering.
  wxSystemOptions::SetOption(_T("msw.window.no-clip-children"), _T("0"));

  // ***********************************************************************************
  // Initialize the file paths
  // ***********************************************************************************

  FilePaths::InitializePaths();

  // If the setting file doesn't exist, assume it's the first time the app is launched
  isFirstLaunch_ = !wxFileName::FileExists(FilePaths::GetSettingsFile());

  // ***********************************************************************************
  // Initialize user
  // ***********************************************************************************

  GetUser()->Load();
  UserSettings* userSettings = GetUser()->GetSettings();

  // ***********************************************************************************
  // Initialize locale
  // ***********************************************************************************

  bool localeSet = false;

  wxLanguageInfo info;
  LNG(wxLANGUAGE_USER_DEFINED + 1, "an", LANG_SPANISH, SUBLANG_SPANISH, wxLayout_LeftToRight, "Aragonese");


  if (IsFirstLaunch()) {
    // If it is the first launch, try to detect the language

    int systemLanguage = wxLocale::GetSystemLanguage();
    
    if (systemLanguage != wxLANGUAGE_UNKNOWN) {
      const wxLanguageInfo* info = wxLocale::GetLanguageInfo(systemLanguage);
      if (info) {
        localeSet = ChangeLocale(info->CanonicalName);
        if (localeSet) {
          userSettings->SetString(_T("Locale"), Localization::Instance()->GetLanguageCodeOnly(info->CanonicalName));
        }
      }
    }
  } else {
    localeSet = ChangeLocale(userSettings->GetString(_T("Locale")));
  }
    
  if (!localeSet) {
    localeSet = ChangeLocale(_T("en"));
    if (!localeSet) {
      MessageBoxes::ShowError(_("Could not initialize locale."));
      ::wxExit();
    }
  }  

  // ***********************************************************************************
  // At this point, user settings are loaded
  // ***********************************************************************************

  if (userSettings->GetBool(_T("UniqueApplicationInstance"))) {
    const wxString name = wxString::Format(_T("%s-%s"), APPLICATION_NAME, wxGetUserId());
    singleInstanceChecker_ = new wxSingleInstanceChecker(name);

    if (singleInstanceChecker_->IsAnotherRunning()) {
      ILOG(_T("Another instance of the application is already running."));
      wxDELETE(singleInstanceChecker_);
      return false;
    }
  }

  // ***********************************************************************************
  // Load the skin file
  // ***********************************************************************************
  Styles::LoadSkinFile(FilePaths::GetSkinDirectory() + _T("/") + SKIN_FILE_NAME);

  // ***********************************************************************************
  // Create and initialize the main frame
  // ***********************************************************************************
  mainFrame_ = new MainFrame();
  mainFrame_->Show();
  mainFrame_->SetRotated(userSettings->GetBool(_T("Rotated")));  
  mainFrame_->UpdateTransparency();

  SetTopWindow(mainFrame_);

  if (IsFirstLaunch()) {
    user_->AddAutoAddExclusion(_T("*setup.exe"));
    user_->AddAutoAddExclusion(_T("*unins*.exe"));
    user_->AddAutoAddExclusion(_T("*installer.exe"));
    user_->AddAutoAddExclusion(_T("*unstall.exe"));
    user_->AddAutoAddExclusion(_T("*updater.exe"));
    user_->AddAutoAddExclusion(_T("*unwise.exe"));
    user_->AddAutoAddExclusion(_T("*uninst.exe"));
    user_->AddAutoAddExclusion(_T("*setup*.exe"));
    user_->AddAutoAddExclusion(_T("msiexec.exe"));
  } 

  if (userSettings->GetBool(_T("OptionPanelOpen"))) {
    mainFrame_->InvalidateLayout();
    mainFrame_->InvalidateMask();
    mainFrame_->Update();
    mainFrame_->OpenOptionPanel();
  }

  // ***********************************************************************************
  // Localize the main frame (this is going to recursively call
  // all the Localize() handlers)
  // ***********************************************************************************
  mainFrame_->Localize();  

  // Note: the rest of the initialization code is in MainFrame::OnIdle (on the first IDLE event)

  return true;
}