/************************************************************************
*
* Resource ID Organiser Core Library
*
* (c) Copyright 2000-2004 by Anna-Jayne Metcalfe (resorg@annasplace.me.uk)
* All rights reserved.
*
************************************************************************
*
* Filename : ResOrgOptions.cpp
*
* Description : CResOrgOptions - class to hold program options
*
* Compiler : Microsoft Visual C++ 6.0, Service Pack 3 or later
* Microsoft Visual C++ .NET 2003
*
* Target
* Environment : Windows 98/NT/2000/XP
*
* NOTE:
*
* This software is provided "as is" free for personal use. All
* title and copyrights in and to the software, including but not
* limited to any images, text, etc. incorporated into it, are
* owned by Anna-Jayne Metcalfe, except where acknowledged otherwise.
*
* Your may freely to use this code in your own products, PROVIDED
* this notice is not removed or modified.
*
*
* Visit http://www.annasplace.me.uk/resorg for latest updates
*
************************************************************************
*
* MODIFICATION HISTORY:
*
* This is a controlled document. See project configuration
* control tool for latest version and full version history.
*
* $Archive: /Projects/AddIns/ResOrg/ResOrgCore/ResOrgOptions.cpp $
* $Revision: 32 $
* $Date: 26/10/04 10:02 $
* $Author: Anna $
*
* $History: ResOrgOptions.cpp $
*
* ***************** Version 32 *****************
* User: Anna Date: 26/10/04 Time: 10:02
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Updated options to point to new website
*
* ***************** Version 31 *****************
* User: Anna Date: 29/08/04 Time: 21:32
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* 1. Added CResOrgOptions::UpdateBooleanOption() as a means of
* simplifying the CResOrgOptions implementation
* 2. Added "Auto save symbol file config" option
* 3. Fixed some miscellaneous bugs
*
* ***************** Version 30 *****************
* User: Anna Date: 21/08/04 Time: 19:29
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Added "Check For Out Of Range Symbols" option
*
* ***************** Version 29 *****************
* User: Anna Date: 11/05/04 Time: 22:50
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* 1. Improved handling of default fixed symbol lists
* 2. Corrected a couple of website URLs
*
* ***************** Version 28 *****************
* User: Anna Date: 11/05/04 Time: 0:22
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* By popular request...added support for "Fixed" symbols
*
* ***************** Version 27 *****************
* User: Anna Date: 21/06/03 Time: 11:32
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Replaced CResOrgVersionCheck::IsNewVersion() with
* CResOrgVersionCheck::CompareVersions(). This allows CResOrgOptions to
* also determine if the installed version is *newer* than the current
* release
*
* ***************** Version 26 *****************
* User: Anna Date: 20/04/03 Time: 15:33
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Added m_bAutoSaveSymbolFileConfig (reserved for future use)
*
* ***************** Version 25 *****************
* User: Anna Date: 19/03/03 Time: 18:42
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Moved the "OPTIONS" #define to ResOrgOptions.h so that CResOrgSplashWnd
* can see it
*
* ***************** Version 24 *****************
* User: Anna Date: 15/02/03 Time: 20:47
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Changed big BOOLs into little bools
*
* ***************** Version 23 *****************
* User: Anna Date: 3/01/03 Time: 7:36
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Added an option to filter multi-file Symbols Displays by default
*
* ***************** Version 22 *****************
* User: Anna Date: 25/11/02 Time: 20:28
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* 1. Updated website address on file banner and in the code
* 2. Added CResOrgOptions::GetEmailURL()
*
* ***************** Version 21 *****************
* User: Anna Date: 22/10/02 Time: 13:24
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Changed name/mail address (at last!)
*
* ***************** Version 20 *****************
* User: Andy Date: 11/06/02 Time: 11:14
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* The VC5/6 and .NET builds now use different sections in the version.txt
* file on the server
*
* ***************** Version 19 *****************
* User: Andy Date: 7/06/02 Time: 17:04
* Updated in $/Projects/AddIns/ResOrg/ResOrgCore
* Renamed the ResOrgUtils module to ResOrgCore. Updated file banners
* accordingly
*
* ***************** Version 18 *****************
* User: Andy Date: 7/06/02 Time: 9:39
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* The "Add-In" page is no longer used in the Visual C++.NET version
*
* ***************** Version 17 *****************
* User: Andy Date: 10/05/02 Time: 16:00
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added "Use Office XP style menus" option
*
* ***************** Version 16 *****************
* User: Andy Date: 12/28/01 Time: 12:52a
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added some new options and moved the others around a bit
*
* ***************** Version 15 *****************
* User: Andy Date: 11/15/01 Time: 1:43p
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added new option to determine whether development versions should be
* checked for updates
*
* ***************** Version 14 *****************
* User: Andy Date: 11/11/01 Time: 12:51p
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Corrected defaults for options
*
* ***************** Version 13 *****************
* User: Andy Date: 10/21/01 Time: 11:00p
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added "Warn if Next Symbol values are in use" option
*
* ***************** Version 12 *****************
* User: Andy Date: 8/07/01 Time: 8:35
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. CResOrgOptions::Configure() now allows the parent window of the
* Options dialog to be specified
* 2. CResOrgOptions::OnVersionCheckCompleted() now passes the HWND of
* the desktop to ShellExecute() when opening a browser window. This stops
* a download freezing when the app is closed
*
* ***************** Version 11 *****************
* User: Andy Date: 2/07/01 Time: 22:17
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added additional options for web URLs (updated from the version
* checker)
*
* ***************** Version 10 *****************
* User: Andy Date: 26/05/01 Time: 15:14
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added Mailing List prompt option
*
* ***************** Version 9 *****************
* User: Andy Date: 22/05/01 Time: 16:02
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Removed version check code from Initialise () to a new
* DoVersionCheck() method. This prevents problems with the "nag" screen
* displayed by the ResOrg app.
* 2. Made StartVersionCheck() a bit more fault tolerant
*
* ***************** Version 8 *****************
* User: Andy Date: 22/05/01 Time: 6:42
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* 1. Class now derived from CCmdTarget to allow it to receive WM_COMMAND
* notifications from the MainFrame
* 2. StartVersionCheck() now takes an extra parameter to allow dial-up
* networking prompts to be disabled
* 3. OnVersionCheckCompleted() now returns an error code instead of a
* boolean
* 4. Added OnExit()
*
* ***************** Version 7 *****************
* User: Andy Date: 16/05/01 Time: 20:56
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added "Updates" page and version checking
*
* ***************** Version 6 *****************
* User: Andy Date: 12/05/01 Time: 6:47
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added a registry entry to allow ResOrg to be forced to check a
* particular version of DevStudio
*
* ***************** Version 5 *****************
* User: Andy Date: 4/05/01 Time: 22:35
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Removed the "Apply" button from the Options Property Sheet
*
* ***************** Version 4 *****************
* User: Andy Date: 5/12/00 Time: 20:32
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added web URL to options
*
* ***************** Version 3 *****************
* User: Andy Date: 3/12/00 Time: 8:33
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added an option to determine whether to check if the add-in should be
* loaded by Visual Studio
*
* ***************** Version 2 *****************
* User: Andy Date: 29/11/00 Time: 18:38
* Updated in $/Projects/AddIns/ResOrg/ResOrgUtils
* Added file banners
*
* $Nokeywords: $
*
************************************************************************/
#include "StdAfx.h"
#include <Wininet.h>
#include "ResOrgCore_Priv.h"
#include "ResOrgOptionsGeneralPage.h"
#include "ResOrgOptionsSymbolsPage.h"
#include "ResOrgOptionsFixedSymbolsPage.h"
#include "ResOrgOptionsAddInPage.h"
#include "ResOrgOptionsUpdatesPage.h"
#include "ResOrgVersionCheck.h"
#include "ResOrgVersionUpdatedDlg.h"
#include "ResOrgOptions.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#if _MSC_VER >= 1300
#define VER_CHECK_SECTION_RELEASE _T("ResOrg.NET")
#define VER_CHECK_SECTION_DEV _T("ResOrg.NET Beta")
#else
#define VER_CHECK_SECTION_RELEASE _T("ResOrg")
#define VER_CHECK_SECTION_DEV _T("ResOrg Beta")
#endif
/////////////////////////////////////////////////////////////////////////////
// CResOrgOptions
CResOrgOptions::CResOrgOptions(void)
{
m_bWarnOnSymbolChanges = true;
m_bAutoFixNextSymbolValues = true;
m_bWarnIfNextSymbolValuesInUse = false;
m_bFilterMultiFileSymbolsDisplays = true;
m_bCheckForOutOfRangeSymbols = true;
m_bAskAboutLoading = true;
m_bAskAboutMailingList = true;
m_bShowTextOnToolbars = true;
m_bAutoReloadFiles = true;
m_bAutoHideWorkspace = true;
m_bXpStyleMenus = true;
m_bAutoSaveSymbolFileConfig = false;
m_sEmailURL = _T("support@riverblade.co.uk");
m_sWebURL = _T("http://www.riverblade.co.uk/products/resorg");
m_sFaqURL = m_sWebURL + _T("/faq.html");
m_sDiscussionBoardURL = m_sWebURL + _T("/forum");
m_sKnownBugsURL = m_sWebURL + _T("/limitations.html");
m_sMailingListURL = m_sWebURL + _T("/mailing_list.html");
m_sAboutMeURL = _T("http://www.annasplace.me.uk/aboutme.html");
m_sDevStudioVer = _T("");
m_bEnableVersionChecking = true;
m_nVersionCheckInterval = 7;
#ifdef _RESORG_EXPIRY_DATE
m_bCheckDevelopmentVersions = true;
#else
m_bCheckDevelopmentVersions = false;
#endif
m_timeLastUpdateCheck = CTime::GetCurrentTime();
m_pVersionChecker = NULL;
}
CResOrgOptions::~CResOrgOptions(void)
{
if (NULL != m_pVersionChecker)
{
delete m_pVersionChecker;
}
}
BEGIN_MESSAGE_MAP(CResOrgOptions, CResOrgOptions_BASE)
//{{AFX_MSG_MAP(CResOrgOptions)
ON_COMMAND( ID_RESORG_VERSION_CHECK, OnCmdResOrgUpdateCheckCompleted)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Virtual Overrides
bool CResOrgOptions::Initialise(void)
{
m_sEmailURL = ::AfxGetApp()->GetProfileString( OPTIONS,
OPTION_EMAIL_URL,
m_sEmailURL);
m_sWebURL = ::AfxGetApp()->GetProfileString( OPTIONS,
OPTION_WEB_URL,
m_sWebURL);
m_sFaqURL = ::AfxGetApp()->GetProfileString( OPTIONS,
OPTION_FAQ_URL,
m_sFaqURL);
m_sDiscussionBoardURL = ::AfxGetApp()->GetProfileString( OPTIONS,
OPTION_DISCUSSIONS_URL,
m_sDiscussionBoardURL);
m_sKnownBugsURL = ::AfxGetApp()->GetProfileString( OPTIONS,
OPTION_BUGS_URL,
m_sKnownBugsURL);
m_sMailingListURL = ::AfxGetApp()->GetProfileString( OPTIONS,
OPTION_MAILING_LIST_URL,
m_sMailingListURL);
m_sAboutMeURL = ::AfxGetApp()->GetProfileString( OPTIONS,
OPTION_ABOUTME_URL,
m_sAboutMeURL);
m_bWarnOnSymbolChanges = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_WARN_SYM_CHANGES,
m_bWarnOnSymbolChanges);
m_bAutoFixNextSymbolValues = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_AUTOFIX_NEXT_SYM_VALUES,
m_bAutoFixNextSymbolValues);
m_bWarnIfNextSymbolValuesInUse = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_WARN_NEXT_SYM_VALUES,
m_bWarnIfNextSymbolValuesInUse);
m_bCheckForOutOfRangeSymbols = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_CHECK_OUT_OF_RANGE_SYMBOLS,
m_bCheckForOutOfRangeSymbols);
m_bFilterMultiFileSymbolsDisplays = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_FILTER_MULTI_FILE_DISPLAYS,
m_bFilterMultiFileSymbolsDisplays);
m_bAutoSaveSymbolFileConfig = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_SAVE_CONFIG,
m_bShowTextOnToolbars);
m_bShowTextOnToolbars = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_DISPLAY_TOOLBAR_TEXT,
m_bShowTextOnToolbars);
m_bAutoReloadFiles = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_DISPLAY_AUTO_RELOAD,
m_bAutoReloadFiles);
m_bAutoHideWorkspace = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_DISPLAY_AUTO_HIDE_WORKSPACE,
m_bAutoHideWorkspace);
m_bAskAboutLoading = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_ADDIN_LOAD_PROMPT,
m_bAskAboutLoading);
m_bXpStyleMenus = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_DISPLAY_XP_MENUS,
m_bXpStyleMenus);
m_sDevStudioVer = ::AfxGetApp()->GetProfileString( OPTIONS,
OPTION_DS_VER);
m_bEnableVersionChecking = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_VERSION_CHECKING,
m_bEnableVersionChecking);
m_nVersionCheckInterval = ::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_VERSION_CHECK_INTERVAL,
m_nVersionCheckInterval);
m_bCheckDevelopmentVersions = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_VERSION_CHECK_DEV,
m_bCheckDevelopmentVersions);
m_timeLastUpdateCheck = (time_t)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_LAST_UPDATE_CHECK,
0);
m_bAskAboutMailingList = (bool)::AfxGetApp()->GetProfileInt( OPTIONS,
OPTION_MAILING_LIST_PROMPT,
m_bAskAboutMailingList);
CString sDefaultFixedSymbols = _T("IDR_MAINFRAME");
CString sFixedSymbols = ::AfxGetApp()->GetProfileString( OPTIONS,
OPTION_FIXED_SYMBOLS,
sDefaultFixedSymbols );
m_setDefaultFixedSymbols.insert(sDefaultFixedSymbols);
while (!sFixedSymbols.IsEmpty() )
{
CString sSymbol = ::Chomp(sFixedSymbols, _T(",") );
if (!sSymbol.IsEmpty() )
{
m_setFixedSymbols.insert(sSymbol);
}
}
return true;
}
int CResOrgOptions::Configure(CWnd* pParentWnd /*= NULL*/)
{
CNGPropertySheet dlg(IDS_RESORG_OPTIONS, pParentWnd);
dlg.m_psh.dwFlags |= PSH_NOAPPLYNOW; // Remove the "Apply" button
CResOrgOptionsGeneralPage GeneralPage;
CResOrgOptionsSymbolsPage SymbolsPage;
CResOrgOptionsFixedSymbolsPage FixedSymbolsPage;
CResOrgOptionsAddInPage AddInPage;
CResOrgOptionsUpdatesPage UpdatesPage;
GeneralPage.m_bShowTextOnToolbars = ShowTextOnToolbars();
GeneralPage.m_bAutoReloadFiles = AutoReloadFiles();
GeneralPage.m_bAutoHideWorkspace = AutoHideWorkspace();
GeneralPage.m_bXpStyleMenus = UseXpStyleMenus();
SymbolsPage.m_bWarnOnSymbolChanges = m_bWarnOnSymbolChanges;
SymbolsPage.m_bAutoFixNextSymbolValues = AutoFixNextSymbolValues();
SymbolsPage.m_bWarnIfNextSymbolValuesInUse = m_bWarnIfNextSymbolValuesInUse;
SymbolsPage.m_bCheckForOutOfRangeSymbols = m_bCheckForOutOfRangeSymbols;
SymbolsPage.m_bFilterMultiFileSymbolsDisplays = m_bFilterMultiFileSymbolsDisplays;
SymbolsPage.m_bAutoSaveSymbolFileConfig = m_bAutoSaveSymbolFileConfig;
FixedSymbolsPage.SetFixedSymbols(m_setFixedSymbols);
FixedSymbolsPage.SetDefaultFixedSymbols(m_setDefaultFixedSymbols);
AddInPage.m_bAskAboutLoading = m_bAskAboutLoading;
UpdatesPage.m_bEnableVersionCheck = m_bEnableVersionChecking;
UpdatesPage.m_nVersionCheckInterval = m_nVersionCheckInterval;
UpdatesPage.m_bCheckDevelopmentVersions = m_bCheckDevelopmentVersions;
dlg.AddPage(&GeneralPage);
dlg.AddPage(&SymbolsPage);
dlg.AddPage(&FixedSymbolsPage);
#if _MSC_VER < 1300
dlg.AddPage(&AddInPage);
#endif
dlg.AddPage(&UpdatesPage);
int nResult = dlg.DoModal();
if (IDOK == nResult)
{
ShowTextOnToolbars(GeneralPage.m_bShowTextOnToolbars);
AutoReloadFiles(GeneralPage.m_bAutoReloadFiles);
AutoHideWorkspace(GeneralPage.m_bAutoHideWorkspace);
UseXpStyleMenus(GeneralPage.m_bXpStyleMenus);
WarnOnSymbolChanges(SymbolsPage.m_bWarnOnSymbolChanges);
AutoFixNextSymbolValues(SymbolsPage.m_bAutoFixNextSymbolValues);
WarnIfNextSymbolValuesInUse(SymbolsPage.m_bWarnIfNextSymbolValuesInUse);
CheckForOutOfRangeSymbols(SymbolsPage.m_bCheckForOutOfRangeSymbols);
FilterMultiFileSymbolsDisplays(SymbolsPage.m_bFilterMultiFileSymbolsDisplays);
AutoSaveSymbolFileConfig(SymbolsPage.m_bAutoSaveSymbolFileConfig);
AskAboutLoadingAddIn(AddInPage.m_bAskAboutLoading);
EnableVersionChecking(UpdatesPage.m_bEnableVersionCheck);
m_nVersionCheckInterval = UpdatesPage.m_nVersionCheckInterval;
CheckDevelopmentVersions(UpdatesPage.m_bCheckDevelopmentVersions);
FixedSymbolsPage.GetFixedSymbols(m_setFixedSymbols);
::AfxGetApp()->WriteProfileInt( OPTIONS,
OPTION_VERSION_CHECK_INTERVAL,
m_nVersionCheckInterval);
CString sFixedSymbols;
for (std::set<CString>::const_iterator it = m_setFixedSymbols.begin();
it != m_setFixedSymbols.end();
it++)
{
sFixedSymbols += sFixedSymbols + *it + _T(",");
}
::AfxGetApp()->WriteProfileString( OPTIONS,
OPTION_FIXED_SYMBOLS,
sFixedSymbols);
}
return nResult;
}
/////////////////////////////////////////////////////////////////////////////
// Operations
bool CResOrgOptions::SetWebURL(const CString& sWebURL)
{
// For safety, don't accept a new URL if it is blank
// since we should NEVER lose the homepage URL
// (the others don't do this so we can disable them
// if need be)
if ( (sWebURL != m_sWebURL) && !sWebURL.IsEmpty())
{
m_sWebURL = sWebURL;
::AfxGetApp()->WriteProfileString(OPTIONS,
OPTION_WEB_URL,
m_sWebURL);
return true;
}
return false;
}
bool CResOrgOptions::SetEmailURL(const CString& sEmailURL)
{
// For safety, don't accept a new URL if it is blank
// since we should NEVER lose the homepage URL
// (the others don't do this so we can disable them
// if need be)
if ( (sEmailURL != m_sEmailURL) && !sEmailURL.IsEmpty())
{
m_sEmailURL = sEmailURL;
::AfxGetApp()->WriteProfileString(OPTIONS,
OPTION_EMAIL_URL,
m_sEmailURL);
return true;
}
return false;
}
bool CResOrgOptions::SetFaqURL(const CString& sFaqURL)
{
if (sFaqURL != m_sFaqURL)
{
m_sFaqURL = sFaqURL;
::AfxGetApp()->WriteProfileString(OPTIONS,
OPTION_FAQ_URL,
m_sFaqURL);
return true;
}
return false;
}
bool CResOrgOptions::SetDiscussionBoardURL(const CString& sDiscussionBoardURL)
{
if (sDiscussionBoardURL != m_sDiscussionBoardURL)
{
m_sDiscussionBoardURL = sDiscussionBoardURL;
::AfxGetApp()->WriteProfileString(OPTIONS,
OPTION_DISCUSSIONS_URL,
m_sDiscussionBoardURL);
return true;
}
return false;
}
bool CResOrgOptions::SetKnownBugsURL(const CString& sKnownBugsURL)
{
if (sKnownBugsURL != m_sKnownBugsURL)
{
m_sKnownBugsURL = sKnownBugsURL;
::AfxGetApp()->WriteProfileString(OPTIONS,
OPTION_BUGS_URL,
m_sKnownBugsURL);
return true;
}
return false;
}
bool CResOrgOptions::SetMailingListURL(const CString& sMailingListURL)
{
if (sMailingListURL != m_sMailingListURL)
{
m_sMailingListURL = sMailingListURL;
::AfxGetApp()->WriteProfileString( OPTIONS,
OPTION_MAILING_LIST_URL,
m_sMailingListURL);
return true;
}
return false;
}
bool CResOrgOptions::SetAboutMeURL(const CString& sAboutMeURL)
{
if (sAboutMeURL != m_sAboutMeURL)
{
m_sAboutMeURL = sAboutMeURL;
::AfxGetApp()->WriteProfileString( OPTIONS,
OPTION_ABOUTME_URL,
m_sAboutMeURL);
return true;
}
return false;
}
bool CResOrgOptions::WarnIfNextSymbolValuesInUse(bool bWarn)
{
return UpdateBooleanOption(OPTION_WARN_NEXT_SYM_VALUES, m_bWarnIfNextSymbolValuesInUse, bWarn);
}
bool CResOrgOptions::ShowTextOnToolbars(bool bShow)
{
return UpdateBooleanOption(OPTION_DISPLAY_TOOLBAR_TEXT, m_bShowTextOnToolbars, bShow);
}
bool CResOrgOptions::AutoReloadFiles(bool bEnable)
{
return UpdateBooleanOption(OPTION_DISPLAY_AUTO_RELOAD, m_bAutoReloadFiles, bEnable);
}
bool CResOrgOptions::AutoFixNextSymbolValues(bool bEnable)
{
return UpdateBooleanOption(OPTION_AUTOFIX_NEXT_SYM_VALUES, m_bAutoFixNextSymbolValues, bEnable);
}
bool CResOrgOptions::CheckForOutOfRangeSymbols(bool bCheck)
{
return UpdateBooleanOption(OPTION_CHECK_OUT_OF_RANGE_SYMBOLS, m_bCheckForOutOfRangeSymbols, bCheck);
}
bool CResOrgOptions::FilterMultiFileSymbolsDisplays(bool bFilter)
{
return UpdateBooleanOption(OPTION_FILTER_MULTI_FILE_DISPLAYS, m_bFilterMultiFileSymbolsDisplays, bFilter);
}
bool CResOrgOptions::WarnOnSymbolChanges(bool bWarn)
{
return UpdateBooleanOption(OPTION_FILTER_MULTI_FILE_DISPLAYS, m_bWarnOnSymbolChanges, bWarn);
}
bool CResOrgOptions::UseXpStyleMenus(bool bXpStyleMenus)
{
return UpdateBooleanOption(OPTION_DISPLAY_XP_MENUS, m_bXpStyleMenus, bXpStyleMenus);
}
bool CResOrgOptions::AutoHideWorkspace(bool bEnable)
{
return UpdateBooleanOption(OPTION_DISPLAY_AUTO_HIDE_WORKSPACE, m_bAutoHideWorkspace, bEnable);
}
bool CResOrgOptions::AutoSaveSymbolFileConfig(bool bEnable)
{
return UpdateBooleanOption(OPTION_SAVE_CONFIG, m_bAutoSaveSymbolFileConfig, bEnable);
}
bool CResOrgOptions::AskAboutLoadingAddIn(bool bAsk)
{
return UpdateBooleanOption(OPTION_ADDIN_LOAD_PROMPT, m_bAskAboutLoading, bAsk);
}
bool CResOrgOptions::EnableMailingListPrompt(bool bEnable)
{
return UpdateBooleanOption(OPTION_MAILING_LIST_PROMPT, m_bAskAboutMailingList, bEnable);
}
bool CResOrgOptions::EnableVersionChecking(bool bEnable)
{
return UpdateBooleanOption(OPTION_VERSION_CHECKING, m_bEnableVersionChecking, bEnable);
}
bool CResOrgOptions::CheckDevelopmentVersions(bool bCheck)
{
return UpdateBooleanOption(OPTION_VERSION_CHECK_DEV, m_bCheckDevelopmentVersions, bCheck);
}
bool CResOrgOptions::IsVersionCheckDue(void) const
{
bool bDue = false;
if (m_bEnableVersionChecking)
{
if (m_nVersionCheckInterval > 0)
{
CTime timeNow = CTime::GetCurrentTime();
CTimeSpan span(m_nVersionCheckInterval, 0, 0, 0);
bDue = (timeNow >= m_timeLastUpdateCheck + span);
}
else
{
bDue = true; // Interval = 0 => check every time we startup
}
}
return bDue;
}
bool CResOrgOptions::DoVersionCheck(void)
{
if (IsVersionCheckDue() )
{
StartVersionCheck( true,
AfxGetMainWnd(),
WM_COMMAND,
ID_RESORG_VERSION_CHECK);
return true;
}
return false;
}
CResOrgVersionCheck* CResOrgOptions::StartVersionCheck( bool bDisableDialupPrompt,
CWnd* pNotifyTarget /*= NULL*/,
UINT uMsg /*= 0*/,
UINT uID /*= 0*/)
{
if (NULL == m_pVersionChecker)
{
m_pVersionChecker = new CResOrgVersionCheck(bDisableDialupPrompt);
ASSERT_VALID(m_pVersionChecker);
}
if ( (NULL != m_pVersionChecker) && !m_pVersionChecker->IsDownloading() )
{
m_pVersionChecker->SetNotifyTarget( pNotifyTarget,
uMsg,
uID);
CString sURL = Options.GetWebURL() + _T("/version.txt");
m_pVersionChecker->StartDownload(sURL);
}
return m_pVersionChecker;
}
bool CResOrgOptions::IsVersionCheckRunning(void) const
{
if ( (NULL != m_pVersionChecker) && m_pVersionChecker->IsDownloading() )
{
return true;
}
return false;
}
void CResOrgOptions::OnOptionChanged(const CString& sOption) const
{
UINT uMsg = ::RegisterWindowMessage(sOption);
ASSERT(uMsg > 0);
CWnd* pWnd = AfxGetMainWnd();
if (NULL != pWnd)
{
AfxGetMainWnd()->PostMessage(uMsg, 0, 0L);
}
}
DWORD CResOrgOptions::OnVersionCheckCompleted(bool bCheckDevelopmentVersions /*= false*/,
bool bPromptAlways /*= false*/)
{
DWORD dwErrorCode = ERROR_INTERNET_CANNOT_CONNECT;
if (NULL != m_pVersionChecker)
{
dwErrorCode = m_pVersionChecker->GetErrorCode();
if (ERROR_SUCCESS == dwErrorCode)
{
m_timeLastUpdateCheck = CTime::GetCurrentTime();
::AfxGetApp()->WriteProfileInt( OPTIONS,
OPTION_LAST_UPDATE_CHECK,
(int)m_timeLastUpdateCheck.GetTime());
// Update website URLs
UpdateURLs();
CNGModuleVersion ver;
ver.GetFileVersionInfo();
CString sCurrentVer = ver.GetValue( _T("FileVersion") );
int nCompareVersionsRelease = 0;
int nCompareVersionsDevelopment = 0;
if (bCheckDevelopmentVersions)
{
nCompareVersionsDevelopment = m_pVersionChecker->CompareVersions(VER_CHECK_SECTION_DEV, sCurrentVer);
}
if (nCompareVersionsDevelopment <= 0)
{
nCompareVersionsRelease = m_pVersionChecker->CompareVersions(VER_CHECK_SECTION_RELEASE, sCurrentVer);
}
if ( (nCompareVersionsDevelopment > 0) || (nCompareVersionsRelease > 0) )
{
// A newer version is available - either development or release
bool bIsDevVersion = (nCompareVersionsDevelopment > 0);
CString sSection = bIsDevVersion ? VER_CHECK_SECTION_DEV : VER_CHECK_SECTION_RELEASE;
CString sVersion = m_pVersionChecker->GetValue( sSection,
_T("Version") );
CString sDescription = m_pVersionChecker->GetValue( sSection,
_T("Description") );
CString sDownLoadUrl = m_pVersionChecker->GetValue( sSection,
_T("Downloads") );
CNGMessageBox dlg;
dlg.FormatMsgEx(MAKEINTRESOURCE(IDS_RESORG_UPDATED),
_T("RTF"),
sVersion,
sDescription);
dlg.SetRtf();
dlg.SetTitle(bIsDevVersion ? IDP_RESORG_NEW_DEV_VER : IDP_RESORG_NEW_VER);
dlg.SetStandardIcon(IDI_INFORMATION);
dlg.AddButton(IDYES, false, false, _T("&Yes") );
dlg.AddButton(IDNO, true, true, _T("&No") );
if (IDYES == dlg.DoModal())
{
::ShellExecute( GetDesktopWindow(),
_T("open"),
sDownLoadUrl,
NULL,
NULL,
SW_SHOWNORMAL);
}
}
else if (bPromptAlways)
{
#ifdef _RESORG_EXPIRY_DATE
CString sBuildType = _T("development ");
#else
CString sBuildType;
#endif
if ( (0 == nCompareVersionsDevelopment) && (0 == nCompareVersionsRelease) )
{
CNGMessageBox dlg;
dlg.SetTitle(_T("Version up to date") );
dlg.FormatMsg(IDP_RESORG_VER_LATEST_INSTALLED);
dlg.SetStandardIcon(IDI_INFORMATION);
dlg.AddButton(IDOK, true, true, _T("OK") );
dlg.DoModal();
}
else if (nCompareVersionsDevelopment < 0)
{
CNGMessageBox dlg;
dlg.SetTitle(_T("Version more than up to date") );
CString sCurrentVersion = m_pVersionChecker->GetValue(VER_CHECK_SECTION_DEV, _T("Version") );
if (sCurrentVersion.IsEmpty() )
{
sCurrentVersion = m_pVersionChecker->GetValue(VER_CHECK_SECTION_RELEASE, _T("Version") );
}
dlg.FormatMsg(_T("Congratulations! This %sversion of ResOrg (%s) is newer than the current released version (%s)"),
sBuildType,
sCurrentVer,
sCurrentVersion);
dlg.SetStandardIcon(IDI_EXCLAMATION);
dlg.AddButton(IDOK, true, true, _T("OK") );
dlg.DoModal();
}
else if (nCompareVersionsRelease < 0)
{
CNGMessageBox dlg;
dlg.SetTitle(_T("Version up to date") );
dlg.FormatMsg(_T("This %sversion of ResOrg (%s) is newer than the current released version (%s)"),
sBuildType,
sCurrentVer,
m_pVersionChecker->GetValue(VER_CHECK_SECTION_RELEASE, _T("Version") ) );
dlg.SetStandardIcon(IDI_INFORMATION);
dlg.AddButton(IDOK, true, true, _T("OK") );
dlg.DoModal();
}
}
}
delete m_pVersionChecker;
m_pVersionChecker = NULL;
}
return dwErrorCode;
}
bool CResOrgOptions::OnExit(void)
{
// If a version check is running, Wait until it finishes
// before exiting (by now the main window has gone)
while (IsVersionCheckRunning()) { Sleep(100); }
return true;
}
/////////////////////////////////////////////////////////////////////////////
// Implementation
bool CResOrgOptions::UpdateBooleanOption(const CString& sOptionName,
bool& rbMemberVar,
bool bNewValue)
{
if (bNewValue != rbMemberVar)
{
rbMemberVar = bNewValue;
::AfxGetApp()->WriteProfileInt( OPTIONS,
sOptionName,
rbMemberVar);
OnOptionChanged(sOptionName);
return true;
}
return false;
}
void CResOrgOptions::OnCmdResOrgUpdateCheckCompleted(void)
{
OnVersionCheckCompleted(m_bCheckDevelopmentVersions);
}
bool CResOrgOptions::UpdateURLs(void)
{
if (NULL != m_pVersionChecker)
{
CString sSection = VER_CHECK_SECTION_RELEASE;
CString sWebURL = m_pVersionChecker->GetValue( sSection,
_T("WebSite") );
CString sEmailURL = m_pVersionChecker->GetValue( sSection,
_T("Email") );
CString sFaqURL = m_pVersionChecker->GetValue( sSection,
_T("FAQ") );
CString sDiscussionBoardURL = m_pVersionChecker->GetValue( sSection,
_T("DiscussionBoard") );
CString sKnownBugsURL = m_pVersionChecker->GetValue( sSection,
_T("KnownBugs") );
CString sMailingListURL = m_pVersionChecker->GetValue( sSection,
_T("MailingList") );
CString sAboutMeURL = m_pVersionChecker->GetValue( sSection,
_T("AboutMe") );
if (!sWebURL.IsEmpty() )
{
// Only set the website URL if we get one
// (I'm being extra careful with this one!)
SetWebURL(sWebURL);
}
if (!sEmailURL.IsEmpty() )
{
// Only set the website URL if we get one
// (I'm being extra careful with this one!)
SetEmailURL(sEmailURL);
}
SetFaqURL(sFaqURL);
SetDiscussionBoardURL(sDiscussionBoardURL);
SetKnownBugsURL(sKnownBugsURL);
SetMailingListURL(sMailingListURL);
if (!sAboutMeURL.IsEmpty() )
{
SetAboutMeURL(sAboutMeURL);
}
return true;
}
return false;
}
bool CResOrgOptions::IsFixedSymbol(const CString& sSymbolName)
{
if (m_setFixedSymbols.find(sSymbolName) != m_setFixedSymbols.end() )
{
return true;
}
return false;
}