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"
${EndIf}
; Cleanup old stuff
Delete "$INSTDIR\Rainmeter.exe.config"
Delete "$INSTDIR\Rainmeter.chm"
Delete "$INSTDIR\Default.ini"
RMDir /r "$INSTDIR\Addons\Rainstaller"
RMDir /r "$INSTDIR\Addons\RainBackup"
${If} $InstallPortable != 1
${AndIfNot} ${FileExists} "$INSTDIR\Defaults"
SetOutPath "$INSTDIR\Defaults"
CreateDirectory "$INSTDIR\Defaults"
Rename "$INSTDIR\Skins" "$INSTDIR\Defaults\Skins"
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}
!ifdef INCLUDEFILES
@ -719,8 +731,6 @@ SkipIniMove:
SetOutPath "$INSTDIR\Languages"
File "..\..\TestBench\x32\Release\Languages\*.*"
RMDir /r "$INSTDIR\Addons\Rainstaller"
SetOutPath "$INSTDIR\Defaults\Skins"
RMDir /r "$INSTDIR\Skins\illustro"
Delete "$INSTDIR\Skins\*.txt"
@ -805,6 +815,35 @@ Function CopyIniToAppData
${EndIf}
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
!insertmacro RemoveStartMenuShortcuts "$SMPROGRAMS\Rainmeter"
FunctionEnd
@ -901,35 +940,20 @@ Section Uninstall
Sleep 500
${Next}
RMDir /r "$TEMP\Rainmeter-Cache"
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\Defaults"
RMDir /r "$INSTDIR\Languages"
RMDir /r "$INSTDIR\Themes"
Delete "$INSTDIR\*.*"
RMDir /r "$INSTDIR\Plugins"
Delete "$INSTDIR\Rainmeter.dll"
Delete "$INSTDIR\Rainmeter.exe"
Delete "$INSTDIR\SkinInstaller.exe"
RMDir "$INSTDIR"
${If} $un.DeleteAll == 1
RMDir /r "$INSTDIR\Skins"
RMDir /r "$INSTDIR\Addons"
RMDir /r "$INSTDIR\Plugins"
RMDir /r "$INSTDIR\Fonts"
${EndIf}
RMDir "$INSTDIR"
SetShellVarContext all
RMDir /r "$APPDATA\Rainstaller"

View File

@ -937,111 +937,112 @@ void CDialogAbout::CTabPlugins::Initialize()
vitem.iItem = 0;
vitem.iSubItem = 0;
// Scan for plugins
WIN32_FIND_DATA fileData; // Data structure describes the file found
HANDLE hSearch; // Search handle returned by FindFirstFile
std::wstring files = Rainmeter->GetPluginPath() + L"*.dll";
// Start searching for .ini files in the given directory.
hSearch = FindFirstFile(files.c_str(), &fileData);
int index = 0;
do
auto findPlugins = [&](const std::wstring& path)
{
if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
std::wstring filter = path + L"*.dll";
// Try to get the version and author
std::wstring tmpSz = Rainmeter->GetPluginPath() + fileData.cFileName;
const WCHAR* path = tmpSz.c_str();
vitem.iItem = index;
vitem.pszText = fileData.cFileName;
// Try to get version and author from file resources first
DWORD handle;
DWORD versionSize = GetFileVersionInfoSize(path, &handle);
if (versionSize)
WIN32_FIND_DATA fd;
HANDLE hSearch = FindFirstFile(filter.c_str(), &fd);
int index = 0;
do
{
bool found = false;
void* data = new BYTE[versionSize];
if (GetFileVersionInfo(path, 0, versionSize, data))
if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
// Try to get the version and author
std::wstring tmpSz = path + fd.cFileName;
const WCHAR* path = tmpSz.c_str();
vitem.iItem = index;
vitem.pszText = fd.cFileName;
// Try to get version and author from file resources first
DWORD handle;
DWORD versionSize = GetFileVersionInfoSize(path, &handle);
if (versionSize)
{
UINT len;
struct LANGCODEPAGE
bool found = false;
void* data = new BYTE[versionSize];
if (GetFileVersionInfo(path, 0, versionSize, data))
{
WORD wLanguage;
WORD wCodePage;
} *lcp;
if (VerQueryValue(data, L"\\VarFileInfo\\Translation", (LPVOID*)&lcp, &len))
{
WCHAR key[64];
LPWSTR value;
_snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\ProductName", lcp[0].wLanguage, lcp[0].wCodePage);
if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len) &&
wcscmp(value, L"Rainmeter") == 0)
UINT len;
struct LANGCODEPAGE
{
ListView_InsertItem(item, &vitem);
++index;
found = true;
WORD wLanguage;
WORD wCodePage;
} *lcp;
_snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\FileVersion", lcp[0].wLanguage, lcp[0].wCodePage);
if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len))
{
ListView_SetItemText(item, vitem.iItem, 1, value);
}
if (VerQueryValue(data, L"\\VarFileInfo\\Translation", (LPVOID*)&lcp, &len))
{
WCHAR key[64];
LPWSTR value;
_snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\LegalCopyright", lcp[0].wLanguage, lcp[0].wCodePage);
if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len))
_snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\ProductName", lcp[0].wLanguage, lcp[0].wCodePage);
if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len) &&
wcscmp(value, L"Rainmeter") == 0)
{
ListView_SetItemText(item, vitem.iItem, 2, value);
ListView_InsertItem(item, &vitem);
++index;
found = true;
_snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\FileVersion", lcp[0].wLanguage, lcp[0].wCodePage);
if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len))
{
ListView_SetItemText(item, vitem.iItem, 1, value);
}
_snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\LegalCopyright", lcp[0].wLanguage, lcp[0].wCodePage);
if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len))
{
ListView_SetItemText(item, vitem.iItem, 2, value);
}
}
}
}
delete [] data;
if (found) continue;
}
delete [] data;
if (found) continue;
}
// Try old calling GetPluginVersion/GetPluginAuthor for backwards compatibility
DWORD err = 0;
HMODULE dll = CSystem::RmLoadLibrary(path, &err, true);
if (dll)
{
ListView_InsertItem(item, &vitem);
++index;
GETPLUGINVERSION GetVersionFunc = (GETPLUGINVERSION)GetProcAddress(dll, "GetPluginVersion");
if (GetVersionFunc)
// Try old calling GetPluginVersion/GetPluginAuthor for backwards compatibility
DWORD err = 0;
HMODULE dll = CSystem::RmLoadLibrary(path, &err, true);
if (dll)
{
UINT version = GetVersionFunc();
WCHAR buffer[64];
_snwprintf_s(buffer, _TRUNCATE, L"%u.%u", version / 1000, version % 1000);
ListView_SetItemText(item, vitem.iItem, 1, buffer);
}
ListView_InsertItem(item, &vitem);
++index;
GETPLUGINAUTHOR GetAuthorFunc = (GETPLUGINAUTHOR)GetProcAddress(dll, "GetPluginAuthor");
if (GetAuthorFunc)
{
LPCTSTR author = GetAuthorFunc();
if (author && *author)
GETPLUGINVERSION GetVersionFunc = (GETPLUGINVERSION)GetProcAddress(dll, "GetPluginVersion");
if (GetVersionFunc)
{
ListView_SetItemText(item, vitem.iItem, 2, (LPWSTR)author);
UINT version = GetVersionFunc();
WCHAR buffer[64];
_snwprintf_s(buffer, _TRUNCATE, L"%u.%u", version / 1000, version % 1000);
ListView_SetItemText(item, vitem.iItem, 1, buffer);
}
GETPLUGINAUTHOR GetAuthorFunc = (GETPLUGINAUTHOR)GetProcAddress(dll, "GetPluginAuthor");
if (GetAuthorFunc)
{
LPCTSTR author = GetAuthorFunc();
if (author && *author)
{
ListView_SetItemText(item, vitem.iItem, 2, (LPWSTR)author);
}
}
FreeLibrary(dll);
}
else
{
LogWithArgs(LOG_ERROR, L"Unable to load plugin: %s (%u)", tmpSz.c_str(), err);
}
FreeLibrary(dll);
}
else
{
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,22 +117,30 @@ void CMeasurePlugin::ReadOptions(CConfigParser& parser, const WCHAR* section)
}
const std::wstring& plugin = parser.ReadString(section, L"Plugin", L"");
std::wstring pluginFile = Rainmeter->GetPluginPath();
size_t pos = plugin.find_last_of(L"\\/");
std::wstring pluginName;
if (pos != std::wstring::npos)
{
pluginFile.append(plugin, pos, plugin.length() - pos);
pluginName.assign(plugin, pos, plugin.length() - pos);
}
else
{
pluginFile += plugin;
pluginName = plugin;
}
// First try from program path
std::wstring pluginFile = Rainmeter->GetPluginPath() + pluginName;
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());
return;
// 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;
}
}
FARPROC initializeFunc = GetProcAddress(m_Plugin, "Initialize");

View File

@ -804,6 +804,8 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
// Set file locations
{
m_SettingsPath = ExtractPath(m_IniFile);
size_t len = m_IniFile.length();
if (len > 4 && _wcsicmp(iniFile + (len - 4), L".ini") == 0)
{
@ -900,25 +902,6 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
m_SkinPath += L"\\Rainmeter\\";
CreateDirectory(m_SkinPath.c_str(), NULL);
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);
}
@ -927,6 +910,9 @@ int CRainmeter::Initialize(LPCWSTR iniPath)
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
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()
{
ScanForSkins(m_SkinPath);
ScanForThemes(GetSettingsPath() + L"Themes");
ScanForThemes(GetThemePath());
ReadGeneralSettings(m_IniFile);
}
@ -1339,6 +1366,7 @@ void CRainmeter::CreateMeterWindow(const std::wstring& folderPath, const std::ws
if (mw)
{
// Note: May modify existing key
m_MeterWindows[folderPath] = mw;
try

View File

@ -136,13 +136,17 @@ public:
const std::wstring& GetIniFile() { return m_IniFile; }
const std::wstring& GetDataFile() { return m_DataFile; }
const std::wstring& GetLogFile() { return m_LogFile; }
const std::wstring& GetSettingsPath() { return m_SettingsPath; }
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 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 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; }
@ -253,6 +257,7 @@ private:
void CreateMonitorMenu(HMENU monitorMenu, CMeterWindow* meterWindow);
void CreateOptionsFile();
void CreateDataFile();
void CreateComponentFolders();
void SetLogging(bool logging);
void TestSettingsFile(bool bDefaultIniLocation);
@ -268,6 +273,7 @@ private:
std::wstring m_DataFile;
std::wstring m_StatsFile;
std::wstring m_LogFile;
std::wstring m_SettingsPath;
std::wstring m_SkinPath;
std::wstring m_Drive;