MCPcopy Create free account
hub / github.com/audacity/audacity / GetModuleStatus

Method GetModuleStatus

libraries/lib-module-manager/ModuleSettings.cpp:95–142  ·  view source on GitHub ↗

static function that tells us about a module.

Source from the content-addressed store, hash-verified

93
94// static function that tells us about a module.
95int ModuleSettings::GetModuleStatus(const FilePath &fname)
96{
97 // Default status is NEW module, and we will ask once.
98 int iStatus = kModuleNew;
99
100 wxFileName FileName( fname );
101 wxString ShortName = FileName.GetName().Lower();
102
103 wxString PathPref = wxString( wxT("/ModulePath/") ) + ShortName;
104 wxString StatusPref = wxString( wxT("/Module/") ) + ShortName;
105 wxString DateTimePref = wxString( wxT("/ModuleDateTime/") ) + ShortName;
106
107 if( gPrefs->Exists(StatusPref) )
108 {
109 // Update module path in case it was changed
110 gPrefs->Write( PathPref, fname );
111
112 gPrefs->Read( StatusPref, &iStatus, static_cast<int>(kModuleNew) );
113
114 wxDateTime DateTime = FileName.GetModificationTime();
115 wxDateTime OldDateTime;
116 OldDateTime.ParseISOCombined( gPrefs->Read( DateTimePref, wxEmptyString ) );
117
118 // Some platforms return milliseconds, some do not...level the playing field
119 DateTime.SetMillisecond( 0 );
120 OldDateTime.SetMillisecond( 0 );
121
122 // fix up a bad status or reset for newer module
123 if( iStatus > kModuleNew || !OldDateTime.IsEqualTo( DateTime ) )
124 {
125 iStatus=kModuleNew;
126 }
127 }
128 else
129 {
130 // Remove previously saved since it's no longer valid
131 gPrefs->DeleteEntry( PathPref );
132 gPrefs->DeleteEntry( StatusPref );
133 gPrefs->DeleteEntry( DateTimePref );
134 }
135
136 if (iStatus == kModuleNew) {
137 if (autoEnabledModules().count(ShortName))
138 iStatus = kModuleEnabled;
139 }
140
141 return iStatus;
142}
143
144void ModuleSettings::SetModuleStatus(const FilePath &fname, int iStatus)
145{

Callers

nothing calls this directly

Calls 6

ExistsMethod · 0.80
wxStringClass · 0.50
GetNameMethod · 0.45
WriteMethod · 0.45
ReadMethod · 0.45
DeleteEntryMethod · 0.45

Tested by

no test coverage detected