Audacity 3.2.0
Functions
ModuleSettings Namespace Reference

Functions

MODULE_MANAGER_API int GetModuleStatus (const FilePath &fname)
 
MODULE_MANAGER_API 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}
wxT("CloseDown"))
static const std::unordered_set< wxString > & autoEnabledModules()
@ kModuleNew
@ kModuleEnabled
FileConfig * gPrefs
Definition: Prefs.cpp:70
virtual bool DeleteEntry(const wxString &key, bool bDeleteGroupIfEmpty=true) wxOVERRIDE
Definition: FileConfig.cpp:209

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

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}
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143

References FileConfig::Flush(), gPrefs, and wxT().

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: