Updating a skin should work now even if the current version is missing. This should solve the issue 121.

The default tray icon is shown if custom tray measure cannot be created.
This commit is contained in:
Kimmo Pekkola 2009-10-30 19:10:55 +00:00
parent fd9cac7add
commit 46570b6025
3 changed files with 47 additions and 35 deletions

View File

@ -995,47 +995,62 @@ void CRainmeter::CheckSkinVersions()
if (CompareVersions(strVersionNew, strVersionInIni) == 1 &&
CompareVersions(strVersionNew, strVersionCurrent) == 1)
{
std::wstring strMessage = L"The config called \"" + menu[i].name + L"\" is newer\nthan the one you are currently using.\n\n";
strMessage += L"New config: " + (strVersionNew.empty() ? L"Unknown" : strVersionNew) + L"\n";
strMessage += L"Current config: " + (strVersionCurrent.empty() ? L"Unknown" : strVersionCurrent) + L"\n";
strMessage += L"\n";
strMessage += L"Do you want to upgrade it?";
strMessage += L"\n\n";
strMessage += L"(If you select 'Yes' your old config\nwill be moved to the 'Backup' folder)";
if (IDYES == MessageBox(NULL, strMessage.c_str(), APPNAME, MB_YESNO | MB_ICONQUESTION))
// Check if the old skin exists at all
struct _stat64i32 s;
std::wstring strSkinPath = m_SkinPath + menu[i].name;
if (_wstat(strSkinPath.c_str(), &s) == 0)
{
// Make sure that the folder exists
CreateDirectory(std::wstring(m_SkinPath + L"Backup").c_str(), NULL);
std::wstring strMessage = L"The config called \"" + menu[i].name + L"\" is newer\nthan the one you are currently using.\n\n";
strMessage += L"New config: " + (strVersionNew.empty() ? L"Unknown" : strVersionNew) + L"\n";
strMessage += L"Current config: " + (strVersionCurrent.empty() ? L"Unknown" : strVersionCurrent) + L"\n";
strMessage += L"\n";
strMessage += L"Do you want to upgrade it?";
strMessage += L"\n\n";
strMessage += L"(If you select 'Yes' your old config\nwill be moved to the 'Backup' folder)";
// Check for illegal characters from the version number
if (strVersionCurrent.find_first_of(L"\\/\"*:?<>|") == std::wstring::npos)
if (IDYES == MessageBox(NULL, strMessage.c_str(), APPNAME, MB_YESNO | MB_ICONQUESTION))
{
std::wstring strTarget = m_SkinPath + L"Backup\\" + menu[i].name + L"-" + strVersionCurrent;
if (CopyFiles(m_SkinPath + menu[i].name, strTarget, true)) // Move the folder to "backup"
{
// Upgrade the skin
CopyFiles(strMainSkinsPath + menu[i].name, m_SkinPath);
// Make sure that the folder exists
CreateDirectory(std::wstring(m_SkinPath + L"Backup").c_str(), NULL);
// TODO: Temporary 'fix': If this was Enigma upgrade the themes too
if (menu[i].name == L"Enigma")
// Check for illegal characters from the version number
if (strVersionCurrent.find_first_of(L"\\/\"*:?<>|") == std::wstring::npos)
{
std::wstring strTarget = m_SkinPath + L"Backup\\" + menu[i].name + L"-" + strVersionCurrent;
if (CopyFiles(m_SkinPath + menu[i].name, strTarget, true)) // Move the folder to "backup"
{
std::wstring strMainThemes = m_Path + L"Themes";
std::wstring strCurrentThemes = GetSettingsPath();
CopyFiles(strMainThemes, strCurrentThemes);
// Upgrade the skin
CopyFiles(strMainSkinsPath + menu[i].name, m_SkinPath);
// TODO: Temporary 'fix': If this was Enigma upgrade the themes too
if (menu[i].name == L"Enigma")
{
std::wstring strMainThemes = m_Path + L"Themes";
std::wstring strCurrentThemes = GetSettingsPath();
CopyFiles(strMainThemes, strCurrentThemes);
}
// End of temporary 'fix'
}
else
{
std::wstring strMessage = L"Failed to upgrade the config.\nUnable to backup the current config.";
MessageBox(NULL, strMessage.c_str(), APPNAME, MB_OK | MB_ICONERROR);
}
// End of temporary 'fix'
}
else
{
std::wstring strMessage = L"Failed to upgrade the config.\nUnable to backup the current config.";
std::wstring strMessage = L"Failed to upgrade the config.\nThe version number contains illegal characters.";
MessageBox(NULL, strMessage.c_str(), APPNAME, MB_OK | MB_ICONERROR);
}
}
else
}
else
{
std::wstring strMessage = L"A new version of config called \"" + menu[i].name + L"\" is available\n";
strMessage += L"Do you want to add it to your skin library?";
if (IDYES == MessageBox(NULL, strMessage.c_str(), APPNAME, MB_YESNO | MB_ICONQUESTION))
{
std::wstring strMessage = L"Failed to upgrade the config.\nThe version number contains illegal characters.";
MessageBox(NULL, strMessage.c_str(), APPNAME, MB_OK | MB_ICONERROR);
CopyFiles(strMainSkinsPath + menu[i].name, m_SkinPath);
}
}

View File

@ -195,11 +195,7 @@ BOOL CTrayWindow::ShowBalloonHelp()
HICON CTrayWindow::CreateTrayIcon(double value)
{
if (m_Measure == NULL)
{
return LoadIcon(m_Instance, MAKEINTRESOURCE(IDI_TRAY));
}
else
if (m_Measure != NULL)
{
if (m_MeterType == TRAY_METER_TYPE_HISTOGRAM)
{
@ -290,7 +286,8 @@ HICON CTrayWindow::CreateTrayIcon(double value)
}
}
return NULL;
// Return the default icon if there is no valid measure
return LoadIcon(m_Instance, MAKEINTRESOURCE(IDI_TRAY));
}
void CTrayWindow::ReadConfig(CConfigParser& parser)

View File

@ -1,2 +1,2 @@
#pragma once
const int revision_number = 291;
const int revision_number = 292;