Audacity  3.0.3
Functions
ModuleSettings Namespace Reference

Functions

int GetModuleStatus (const FilePath &fname)
 
void SetModuleStatus (const FilePath &fname, int iStatus)
 

Function Documentation

◆ GetModuleStatus()

int ModuleSettings::GetModuleStatus ( const FilePath fname)

Definition at line 28 of file ModuleSettings.cpp.

29 {
30  // Default status is NEW module, and we will ask once.
31  int iStatus = kModuleNew;
32 
33  wxFileName FileName( fname );
34  wxString ShortName = FileName.GetName().Lower();
35 
36  wxString PathPref = wxString( wxT("/ModulePath/") ) + ShortName;
37  wxString StatusPref = wxString( wxT("/Module/") ) + ShortName;
38  wxString DateTimePref = wxString( wxT("/ModuleDateTime/") ) + ShortName;
39 
40  wxString ModulePath = gPrefs->Read( PathPref, wxEmptyString );
41  if( ModulePath.IsSameAs( fname ) )
42  {
43  gPrefs->Read( StatusPref, &iStatus, kModuleNew );
44 
45  wxDateTime DateTime = FileName.GetModificationTime();
46  wxDateTime OldDateTime;
47  OldDateTime.ParseISOCombined( gPrefs->Read( DateTimePref, wxEmptyString ) );
48 
49  // Some platforms return milliseconds, some do not...level the playing field
50  DateTime.SetMillisecond( 0 );
51  OldDateTime.SetMillisecond( 0 );
52 
53  // fix up a bad status or reset for newer module
54  if( iStatus > kModuleNew || !OldDateTime.IsEqualTo( DateTime ) )
55  {
56  iStatus=kModuleNew;
57  }
58  }
59  else
60  {
61  // Remove previously saved since it's no longer valid
62  gPrefs->DeleteEntry( PathPref );
63  gPrefs->DeleteEntry( StatusPref );
64  gPrefs->DeleteEntry( DateTimePref );
65  }
66 
67  if (iStatus == kModuleNew) {
68  if (autoEnabledModules().count(ShortName))
69  iStatus = kModuleEnabled;
70  }
71 
72  return iStatus;
73 }

References autoEnabledModules(), FileConfig::DeleteEntry(), gPrefs, kModuleEnabled, and kModuleNew.

Referenced by ModuleManager::TryLoadModules().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetModuleStatus()

void ModuleSettings::SetModuleStatus ( const FilePath fname,
int  iStatus 
)

Definition at line 75 of file ModuleSettings.cpp.

76 {
77  wxFileName FileName( fname );
78  wxDateTime DateTime = FileName.GetModificationTime();
79  wxString ShortName = FileName.GetName().Lower();
80 
81  wxString PrefName = wxString( wxT("/Module/") ) + ShortName;
82  gPrefs->Write( PrefName, iStatus );
83 
84  PrefName = wxString( wxT("/ModulePath/") ) + ShortName;
85  gPrefs->Write( PrefName, fname );
86 
87  PrefName = wxString( wxT("/ModuleDateTime/") ) + ShortName;
88  gPrefs->Write( PrefName, DateTime.FormatISOCombined() );
89 
90  gPrefs->Flush();
91 }

References FileConfig::Flush(), and gPrefs.

Referenced by ModulePrefs::Commit(), ModuleManager::Initialize(), and ModuleManager::TryLoadModules().

Here is the call graph for this function:
Here is the caller graph for this function:
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
kModuleEnabled
@ kModuleEnabled
Definition: ModuleSettings.h:18
FileConfig::DeleteEntry
virtual bool DeleteEntry(const wxString &key, bool bDeleteGroupIfEmpty=true) wxOVERRIDE
Definition: FileConfig.cpp:209
kModuleNew
@ kModuleNew
Definition: ModuleSettings.h:21
autoEnabledModules
static const std::unordered_set< wxString > & autoEnabledModules()
Definition: ModuleSettings.cpp:18
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143