Moved addons and non-default plugins to #SETTINGSPATH#

This commit is contained in:
Birunthan Mohanathas 2012-06-09 18:38:45 +03:00
parent 1b4d45e81c
commit 87817bc050
5 changed files with 204 additions and 137 deletions

View File

@ -697,15 +697,27 @@ SkipIniMove:
Delete "$0\SkinInstaller.exe" Delete "$0\SkinInstaller.exe"
${EndIf} ${EndIf}
; Cleanup old stuff
Delete "$INSTDIR\Rainmeter.exe.config" Delete "$INSTDIR\Rainmeter.exe.config"
Delete "$INSTDIR\Rainmeter.chm" Delete "$INSTDIR\Rainmeter.chm"
Delete "$INSTDIR\Default.ini" Delete "$INSTDIR\Default.ini"
RMDir /r "$INSTDIR\Addons\Rainstaller"
RMDir /r "$INSTDIR\Addons\RainBackup"
${If} $InstallPortable != 1 ${If} $InstallPortable != 1
${AndIfNot} ${FileExists} "$INSTDIR\Defaults" CreateDirectory "$INSTDIR\Defaults"
SetOutPath "$INSTDIR\Defaults"
Rename "$INSTDIR\Skins" "$INSTDIR\Defaults\Skins" Rename "$INSTDIR\Skins" "$INSTDIR\Defaults\Skins"
Rename "$INSTDIR\Themes" "$INSTDIR\Defaults\Themes" Rename "$INSTDIR\Themes" "$INSTDIR\Defaults\Themes"
${If} ${FileExists} "$INSTDIR\Addons\Backup"
${OrIf} ${FileExists} "$INSTDIR\Plugins\Backup"
CreateDirectory "$INSTDIR\Defaults\Backup"
Rename "$INSTDIR\Addons\Backup" "$INSTDIR\Defaults\Backup\Addons"
Rename "$INSTDIR\Plugins\Backup" "$INSTDIR\Defaults\Backup\Plugins"
${EndIf}
Rename "$INSTDIR\Addons" "$INSTDIR\Defaults\Addons"
${Locate} "$INSTDIR\Plugins" "/L=F /M=*.dll /G=0" "MoveNonDefaultPlugins"
${EndIf} ${EndIf}
!ifdef INCLUDEFILES !ifdef INCLUDEFILES
@ -719,8 +731,6 @@ SkipIniMove:
SetOutPath "$INSTDIR\Languages" SetOutPath "$INSTDIR\Languages"
File "..\..\TestBench\x32\Release\Languages\*.*" File "..\..\TestBench\x32\Release\Languages\*.*"
RMDir /r "$INSTDIR\Addons\Rainstaller"
SetOutPath "$INSTDIR\Defaults\Skins" SetOutPath "$INSTDIR\Defaults\Skins"
RMDir /r "$INSTDIR\Skins\illustro" RMDir /r "$INSTDIR\Skins\illustro"
Delete "$INSTDIR\Skins\*.txt" Delete "$INSTDIR\Skins\*.txt"
@ -805,6 +815,35 @@ Function CopyIniToAppData
${EndIf} ${EndIf}
FunctionEnd FunctionEnd
Function MoveNonDefaultPlugins
${If} $R7 != "AdvancedCPU.dll"
${AndIf} $R7 != "CoreTemp.dll"
${AndIf} $R7 != "FolderInfo.dll"
${AndIf} $R7 != "InputText.dll"
${AndIf} $R7 != "iTunesPlugin.dll"
${AndIf} $R7 != "MediaKey.dll"
${AndIf} $R7 != "NowPlaying.dll"
${AndIf} $R7 != "PerfMon.dll"
${AndIf} $R7 != "PingPlugin.dll"
${AndIf} $R7 != "PowerPlugin.dll"
${AndIf} $R7 != "Process.dll"
${AndIf} $R7 != "QuotePlugin.dll"
${AndIf} $R7 != "RecycleManager.dll"
${AndIf} $R7 != "ResMon.dll"
${AndIf} $R7 != "SpeedFanPlugin.dll"
${AndIf} $R7 != "SysInfo.dll"
${AndIf} $R7 != "VirtualDesktops.dll"
${AndIf} $R7 != "WebParser.dll"
${AndIf} $R7 != "WifiStatus.dll"
${AndIf} $R7 != "Win7AudioPlugin.dll"
${AndIf} $R7 != "WindowMessagePlugin.dll"
CreateDirectory "$INSTDIR\Defaults\Plugins"
Rename "$R9" "$INSTDIR\Defaults\Plugins\$R7"
${EndIf}
Push $0
FunctionEnd
Function RemoveStartMenuShortcuts Function RemoveStartMenuShortcuts
!insertmacro RemoveStartMenuShortcuts "$SMPROGRAMS\Rainmeter" !insertmacro RemoveStartMenuShortcuts "$SMPROGRAMS\Rainmeter"
FunctionEnd FunctionEnd
@ -901,35 +940,20 @@ Section Uninstall
Sleep 500 Sleep 500
${Next} ${Next}
RMDir /r "$TEMP\Rainmeter-Cache" RMDir /r "$INSTDIR\Defaults"
RMDir /r "$INSTDIR\Skins\Gnometer"
RMDir /r "$INSTDIR\Skins\Tranquil"
RMDir /r "$INSTDIR\Skins\Enigma"
RMDir /r "$INSTDIR\Skins\Arcs"
RMDir /r "$INSTDIR\Skins\illustro"
Delete "$INSTDIR\Skins\*.txt"
RMDir "$INSTDIR\Skins"
RMDir /r "$INSTDIR\Addons\RainThemes"
RMDir /r "$INSTDIR\Addons\RainBrowser"
RMDir /r "$INSTDIR\Addons\RainBackup"
RMDir /r "$INSTDIR\Addons\Rainstaller"
RMDir "$INSTDIR\Addons"
Delete "$INSTDIR\Plugins\*.*"
RMDir "$INSTDIR\Plugins"
RMDir /r "$INSTDIR\Languages" RMDir /r "$INSTDIR\Languages"
RMDir /r "$INSTDIR\Themes" RMDir /r "$INSTDIR\Plugins"
Delete "$INSTDIR\*.*" Delete "$INSTDIR\Rainmeter.dll"
Delete "$INSTDIR\Rainmeter.exe"
Delete "$INSTDIR\SkinInstaller.exe"
RMDir "$INSTDIR"
${If} $un.DeleteAll == 1 ${If} $un.DeleteAll == 1
RMDir /r "$INSTDIR\Skins" RMDir /r "$INSTDIR\Skins"
RMDir /r "$INSTDIR\Addons" RMDir /r "$INSTDIR\Addons"
RMDir /r "$INSTDIR\Plugins"
RMDir /r "$INSTDIR\Fonts" RMDir /r "$INSTDIR\Fonts"
${EndIf} ${EndIf}
RMDir "$INSTDIR"
SetShellVarContext all SetShellVarContext all
RMDir /r "$APPDATA\Rainstaller" RMDir /r "$APPDATA\Rainstaller"

View File

@ -937,25 +937,23 @@ void CDialogAbout::CTabPlugins::Initialize()
vitem.iItem = 0; vitem.iItem = 0;
vitem.iSubItem = 0; vitem.iSubItem = 0;
// Scan for plugins auto findPlugins = [&](const std::wstring& path)
WIN32_FIND_DATA fileData; // Data structure describes the file found {
HANDLE hSearch; // Search handle returned by FindFirstFile std::wstring filter = path + L"*.dll";
std::wstring files = Rainmeter->GetPluginPath() + L"*.dll"; WIN32_FIND_DATA fd;
HANDLE hSearch = FindFirstFile(filter.c_str(), &fd);
// Start searching for .ini files in the given directory.
hSearch = FindFirstFile(files.c_str(), &fileData);
int index = 0; int index = 0;
do do
{ {
if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
// Try to get the version and author // Try to get the version and author
std::wstring tmpSz = Rainmeter->GetPluginPath() + fileData.cFileName; std::wstring tmpSz = path + fd.cFileName;
const WCHAR* path = tmpSz.c_str(); const WCHAR* path = tmpSz.c_str();
vitem.iItem = index; vitem.iItem = index;
vitem.pszText = fileData.cFileName; vitem.pszText = fd.cFileName;
// Try to get version and author from file resources first // Try to get version and author from file resources first
DWORD handle; DWORD handle;
@ -1039,9 +1037,12 @@ void CDialogAbout::CTabPlugins::Initialize()
LogWithArgs(LOG_ERROR, L"Unable to load plugin: %s (%u)", tmpSz.c_str(), err); LogWithArgs(LOG_ERROR, L"Unable to load plugin: %s (%u)", tmpSz.c_str(), err);
} }
} }
while (FindNextFile(hSearch, &fileData)); while (FindNextFile(hSearch, &fd));
FindClose(hSearch); FindClose(hSearch);
};
findPlugins(Rainmeter->GetPluginPath());
findPlugins(Rainmeter->GetUserPluginPath());
} }
/* /*

View File

@ -117,23 +117,31 @@ void CMeasurePlugin::ReadOptions(CConfigParser& parser, const WCHAR* section)
} }
const std::wstring& plugin = parser.ReadString(section, L"Plugin", L""); const std::wstring& plugin = parser.ReadString(section, L"Plugin", L"");
std::wstring pluginFile = Rainmeter->GetPluginPath();
size_t pos = plugin.find_last_of(L"\\/"); size_t pos = plugin.find_last_of(L"\\/");
std::wstring pluginName;
if (pos != std::wstring::npos) if (pos != std::wstring::npos)
{ {
pluginFile.append(plugin, pos, plugin.length() - pos); pluginName.assign(plugin, pos, plugin.length() - pos);
} }
else else
{ {
pluginFile += plugin; pluginName = plugin;
} }
// First try from program path
std::wstring pluginFile = Rainmeter->GetPluginPath() + pluginName;
m_Plugin = CSystem::RmLoadLibrary(pluginFile.c_str()); m_Plugin = CSystem::RmLoadLibrary(pluginFile.c_str());
if (m_Plugin == NULL) if (!m_Plugin)
{ {
LogWithArgs(LOG_ERROR, L"Plugin: \"%s\" not found", pluginFile.c_str()); // Try from settings path
pluginFile = Rainmeter->GetUserPluginPath() + pluginName;
m_Plugin = CSystem::RmLoadLibrary(pluginFile.c_str());
if (!m_Plugin)
{
LogWithArgs(LOG_ERROR, L"Plugin: \"%s\" not found", pluginName.c_str());
return; return;
} }
}
FARPROC initializeFunc = GetProcAddress(m_Plugin, "Initialize"); FARPROC initializeFunc = GetProcAddress(m_Plugin, "Initialize");
m_ReloadFunc = GetProcAddress(m_Plugin, "Reload"); m_ReloadFunc = GetProcAddress(m_Plugin, "Reload");

View File

@ -804,6 +804,8 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
// Set file locations // Set file locations
{ {
m_SettingsPath = ExtractPath(m_IniFile);
size_t len = m_IniFile.length(); size_t len = m_IniFile.length();
if (len > 4 && _wcsicmp(iniFile + (len - 4), L".ini") == 0) if (len > 4 && _wcsicmp(iniFile + (len - 4), L".ini") == 0)
{ {
@ -900,25 +902,6 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
m_SkinPath += L"\\Rainmeter\\"; m_SkinPath += L"\\Rainmeter\\";
CreateDirectory(m_SkinPath.c_str(), NULL); CreateDirectory(m_SkinPath.c_str(), NULL);
m_SkinPath += L"Skins\\"; m_SkinPath += L"Skins\\";
DWORD result = CreateDirectory(m_SkinPath.c_str(), NULL);
if (result)
{
// Folder just created, so copy default skins there
std::wstring from = GetDefaultSkinPath();
from += L"*.*";
CSystem::CopyFiles(from, m_SkinPath);
}
std::wstring themesPath = GetSettingsPath();
themesPath += L"Themes\\";
result = CreateDirectory(themesPath.c_str(), NULL);
if (result)
{
// Copy themes to %APPDATA%
std::wstring from = GetDefaultThemePath();
from += L"*.*";
CSystem::CopyFiles(from, themesPath);
}
WritePrivateProfileString(L"Rainmeter", L"SkinPath", m_SkinPath.c_str(), iniFile); WritePrivateProfileString(L"Rainmeter", L"SkinPath", m_SkinPath.c_str(), iniFile);
} }
@ -927,6 +910,9 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
m_SkinPath = m_Path + L"Skins\\"; m_SkinPath = m_Path + L"Skins\\";
} }
// Create user skins, themes, addons, and plugins folders if needed
CreateComponentFolders();
// Create a default Rainmeter.ini file if needed // Create a default Rainmeter.ini file if needed
if (_waccess(iniFile, 0) == -1) if (_waccess(iniFile, 0) == -1)
{ {
@ -1194,10 +1180,51 @@ void CRainmeter::CreateDataFile()
} }
} }
void CRainmeter::CreateComponentFolders()
{
if (CreateDirectory(m_SkinPath.c_str(), NULL))
{
// Folder just created, so copy default skins there
std::wstring from = GetDefaultSkinPath();
from += L"*.*";
CSystem::CopyFiles(from, m_SkinPath);
}
std::wstring path = GetThemePath();
if (_waccess(path.c_str(), 0) == -1)
{
std::wstring from = GetDefaultThemePath();
if (_waccess(from.c_str(), 0) != -1)
{
CSystem::CopyFiles(from, m_SettingsPath);
}
}
path = GetUserPluginPath();
if (_waccess(path.c_str(), 0) == -1)
{
std::wstring from = GetDefaultPluginPath();
if (_waccess(from.c_str(), 0) != -1)
{
CSystem::CopyFiles(from, m_SettingsPath);
}
}
path = GetAddonPath();
if (_waccess(path.c_str(), 0) == -1)
{
std::wstring from = GetDefaultAddonPath();
if (_waccess(from.c_str(), 0) != -1)
{
CSystem::CopyFiles(from, m_SettingsPath);
}
}
}
void CRainmeter::ReloadSettings() void CRainmeter::ReloadSettings()
{ {
ScanForSkins(m_SkinPath); ScanForSkins(m_SkinPath);
ScanForThemes(GetSettingsPath() + L"Themes"); ScanForThemes(GetThemePath());
ReadGeneralSettings(m_IniFile); ReadGeneralSettings(m_IniFile);
} }
@ -1339,6 +1366,7 @@ void CRainmeter::CreateMeterWindow(const std::wstring& folderPath, const std::ws
if (mw) if (mw)
{ {
// Note: May modify existing key
m_MeterWindows[folderPath] = mw; m_MeterWindows[folderPath] = mw;
try try

View File

@ -136,13 +136,17 @@ public:
const std::wstring& GetIniFile() { return m_IniFile; } const std::wstring& GetIniFile() { return m_IniFile; }
const std::wstring& GetDataFile() { return m_DataFile; } const std::wstring& GetDataFile() { return m_DataFile; }
const std::wstring& GetLogFile() { return m_LogFile; } const std::wstring& GetLogFile() { return m_LogFile; }
const std::wstring& GetSettingsPath() { return m_SettingsPath; }
const std::wstring& GetSkinPath() { return m_SkinPath; } const std::wstring& GetSkinPath() { return m_SkinPath; }
std::wstring GetSettingsPath() { return ExtractPath(m_IniFile); } std::wstring GetThemePath() { return m_SettingsPath + L"Themes\\"; }
std::wstring GetPluginPath() { return m_Path + L"Plugins\\"; } std::wstring GetPluginPath() { return m_Path + L"Plugins\\"; }
std::wstring GetAddonPath() { return m_Path + L"Addons\\"; } std::wstring GetUserPluginPath() { return m_SettingsPath + L"Plugins\\"; }
std::wstring GetAddonPath() { return m_SettingsPath + L"Addons\\"; }
std::wstring GetDefaultSkinPath() { return m_Path + L"Defaults\\Skins\\"; } std::wstring GetDefaultSkinPath() { return m_Path + L"Defaults\\Skins\\"; }
std::wstring GetDefaultThemePath() { return m_Path + L"Defaults\\Themes\\"; } std::wstring GetDefaultThemePath() { return m_Path + L"Defaults\\Themes\\"; }
std::wstring GetDefaultPluginPath() { return m_Path + L"Defaults\\Plugins\\"; }
std::wstring GetDefaultAddonPath() { return m_Path + L"Defaults\\Addons\\"; }
const std::wstring& GetDrive() { return m_Drive; } const std::wstring& GetDrive() { return m_Drive; }
@ -253,6 +257,7 @@ private:
void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow); void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow);
void CreateOptionsFile(); void CreateOptionsFile();
void CreateDataFile(); void CreateDataFile();
void CreateComponentFolders();
void SetLogging(bool logging); void SetLogging(bool logging);
void TestSettingsFile(bool bDefaultIniLocation); void TestSettingsFile(bool bDefaultIniLocation);
@ -268,6 +273,7 @@ private:
std::wstring m_DataFile; std::wstring m_DataFile;
std::wstring m_StatsFile; std::wstring m_StatsFile;
std::wstring m_LogFile; std::wstring m_LogFile;
std::wstring m_SettingsPath;
std::wstring m_SkinPath; std::wstring m_SkinPath;
std::wstring m_Drive; std::wstring m_Drive;