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 93 of file ModuleSettings.cpp.

94{
95 // Default status is NEW module, and we will ask once.
96 int iStatus = kModuleNew;
97
98 wxFileName FileName( fname );
99 wxString ShortName = FileName.GetName().Lower();
100
101 wxString PathPref = wxString( wxT("/ModulePath/") ) + ShortName;
102 wxString StatusPref = wxString( wxT("/Module/") ) + ShortName;
103 wxString DateTimePref = wxString( wxT("/ModuleDateTime/") ) + ShortName;
104
105 wxString ModulePath = gPrefs->Read( PathPref, wxEmptyString );
106 if( ModulePath.IsSameAs( fname ) )
107 {
108 gPrefs->Read( StatusPref, &iStatus, static_cast<int>(kModuleNew) );
109
110 wxDateTime DateTime = FileName.GetModificationTime();
111 wxDateTime OldDateTime;
112 OldDateTime.ParseISOCombined( gPrefs->Read( DateTimePref, wxEmptyString ) );
113
114 // Some platforms return milliseconds, some do not...level the playing field
115 DateTime.SetMillisecond( 0 );
116 OldDateTime.SetMillisecond( 0 );
117
118 // fix up a bad status or reset for newer module
119 if( iStatus > kModuleNew || !OldDateTime.IsEqualTo( DateTime ) )
120 {
121 iStatus=kModuleNew;
122 }
123 }
124 else
125 {
126 // Remove previously saved since it's no longer valid
127 gPrefs->DeleteEntry( PathPref );
128 gPrefs->DeleteEntry( StatusPref );
129 gPrefs->DeleteEntry( DateTimePref );
130 }
131
132 if (iStatus == kModuleNew) {
133 if (autoEnabledModules().count(ShortName))
134 iStatus = kModuleEnabled;
135 }
136
137 return iStatus;
138}
wxT("CloseDown"))
static const std::unordered_set< wxString > & autoEnabledModules()
@ kModuleNew
@ kModuleEnabled
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
bool DeleteEntry(const wxString &key)
Deletes specified entry if exists.
virtual bool Read(const wxString &key, bool *value) const =0

References autoEnabledModules(), audacity::BasicSettings::DeleteEntry(), gPrefs, kModuleEnabled, kModuleNew, audacity::BasicSettings::Read(), 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 140 of file ModuleSettings.cpp.

141{
142 wxFileName FileName( fname );
143 wxDateTime DateTime = FileName.GetModificationTime();
144 wxString ShortName = FileName.GetName().Lower();
145
146 wxString PrefName = wxString( wxT("/Module/") ) + ShortName;
147 gPrefs->Write( PrefName, iStatus );
148
149 PrefName = wxString( wxT("/ModulePath/") ) + ShortName;
150 gPrefs->Write( PrefName, fname );
151
152 PrefName = wxString( wxT("/ModuleDateTime/") ) + ShortName;
153 gPrefs->Write( PrefName, DateTime.FormatISOCombined() );
154
155 gPrefs->Flush();
156}
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0

References audacity::BasicSettings::Flush(), gPrefs, audacity::BasicSettings::Write(), 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: