OpUpdate Class Reference

This class represents the Update operation. More...

#include <menuops.h>

Inheritance diagram for OpUpdate:

Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpUpdate ()
 OpUpdate constructor.
void Do (OpDescriptor *)
 The default operation is called from the menu.
void DoWithParam (OpDescriptor *, OpParam *Params)
 Show the Update or Special boards.
void CheckForNewFiles ()
 record change of version of update/specials in preferences data to be shown at next appropriate time

Static Public Member Functions

static BOOL Init ()
 Initialise the Update operation and preferences.
static OpState GetState (String_256 *, OpDescriptor *)
static String_256 GetSpecialsFile ()
 Get the specials file name, which varies according to whether the user is running the Free Trial or not.
static BOOL UpdateFiles (BOOL bForeground)
 Call the WebFileUpdater to download any new files from our servers.
static String_256 GetWebFilePath (LPCTSTR p)
 Returns the full .web file path for a given .web file. Reverts to ENG default if locale scoped file not found.
static String_256 GetWebFileRoot ()
 Returns the base .web file path.
static String_256 GetUpdateURL ()
 returns the Update URL. Notes: The update URL is scoped to the Major product version to minimise the number of update folders required
static BOOL UpdateFiles (BOOL bForeground, const String_256 &strClientFolder, const String_256 &strURL, const String_256 &strIndexLeafName, const String_256 &strRegKeyName)
 Call the WebFileUpdater to download any new files from our servers.

Static Public Attributes

static String_256 IndexBaseURL = _T("http://xara.xaraonline.com/XaraX2/WebFiles/")
static String_32 IndexLeafName = _T("index.xml")

Static Protected Attributes

static BOOL UpdateDontShowAgain = TRUE
static BOOL SpecialsDontShowAgain = TRUE
static INT32 UpdateFileDate = 0
static INT32 SpecialsFileDate = 0

Detailed Description

This class represents the Update operation.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
?/4/2004
See also:
Operation

Definition at line 346 of file menuops.h.


Constructor & Destructor Documentation

OpUpdate::OpUpdate  ) 
 

OpUpdate constructor.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/3/04
Parameters:
[INPUTS] 

Definition at line 2181 of file menuops.cpp.

02181                   : Operation()
02182 {}


Member Function Documentation

void OpUpdate::CheckForNewFiles  ) 
 

record change of version of update/specials in preferences data to be shown at next appropriate time

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/2004

Definition at line 2345 of file menuops.cpp.

02346 {
02347     PORTNOTETRACE("other","OpUpdate::CheckForNewFiles - do nothing");
02348 #ifndef EXCLUDE_FROM_XARALX
02349     // *** Important note *** For updating this code to Win64, ensure that
02350     // the 64 bit time_t value is NOT truncated to (32bit) integer.
02351 
02352     String_256 sUpgradeFile = GetWebFilePath(_T("UpgradeLX.web"));
02353     String_256 sSpecialsFileName = GetSpecialsFile();
02354     String_256 sSpecialsFilePath = GetWebFilePath(sSpecialsFileName);
02355 
02356     CFileStatus status;
02357 
02358     if (CFile::GetStatus(sUpgradeFile, status))
02359     {
02360         if (status.m_mtime.GetTime() > UpdateFileDate)
02361         {
02362             // only force the update check if it is NOT the installed file
02363             if (UpdateFileDate != 0)
02364                 UpdateDontShowAgain = FALSE;
02365 
02366             UpdateFileDate = status.m_mtime.GetTime();
02367         }
02368     }
02369     if (CFile::GetStatus(sSpecialsFilePath, status))
02370     {
02371         if (status.m_mtime.GetTime() > SpecialsFileDate)
02372         {
02373             SpecialsDontShowAgain = FALSE;
02374             SpecialsFileDate = status.m_mtime.GetTime();
02375         }
02376     }
02377 #endif
02378 }

void OpUpdate::Do OpDescriptor od  )  [virtual]
 

The default operation is called from the menu.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/3/04
Returns:

Reimplemented from Operation.

Definition at line 2266 of file menuops.cpp.

02267 {
02268 PORTNOTETRACE("other","OpUpdate::Do - do nothing");
02269 #ifndef EXCLUDE_FROM_XARALX
02270     this->DoWithParam(od,&OpParam((INT32) TRUE, NULL));
02271 #endif
02272 }

void OpUpdate::DoWithParam OpDescriptor ,
OpParam pOpParam
[virtual]
 

Show the Update or Special boards.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/3/04
Parameters:
OpParam - (BOOL) Param1 Whether the request was from the user or automatic [INPUTS]

Reimplemented from Operation.

Definition at line 2195 of file menuops.cpp.

02196 {
02197     PORTNOTETRACE("other","OpUpdate::DoWithParam - do nothing");
02198 #ifndef EXCLUDE_FROM_XARALX
02199     BOOL forcedByUser = (BOOL)pOpParam->Param1;
02200 
02201     if (!forcedByUser)
02202     {
02203         // This is an automatic (background) check
02204         CheckForNewFiles();
02205 
02206         // update takes priority over specials - don't show both
02207 
02208         if (!UpdateDontShowAgain)
02209         {
02210             CWebDialogDlg webdlg(TRUE, _T("UpgradeLX.web"), TRUE, NULL, 0, FALSE);
02211             webdlg.DoModal();
02212             UpdateDontShowAgain = webdlg.DontShowAgain();
02213         }
02214         else if (!SpecialsDontShowAgain)
02215         {
02216             CWebDialogDlg webdlg(TRUE, GetSpecialsFile());
02217             webdlg.DoModal();
02218             SpecialsDontShowAgain = webdlg.DontShowAgain();
02219         }
02220     }
02221     else
02222         Progress::Start(FALSE, _R(IDS_UPDATING_SPECIALS), -1);
02223 
02224     // kick off the web updater to find new versions of the files 
02225     // (to appear the next time we run)
02226     BOOL bOK = UpdateFiles(forcedByUser);
02227 
02228     if (forcedByUser)
02229         Progress::Stop();
02230 
02231     if (bOK && forcedByUser)
02232     {
02233         // This is a deliberate (foreground) check, so we must show the user something...
02234         CheckForNewFiles();
02235 
02236         // Don't show the "DontShowAgain" flag
02237         // Don't show the window's surround
02238         // Do show the "follow up" message
02239         CWebDialogDlg webdlg(FALSE, _T("UpgradeLX.web"), FALSE, NULL, 0, TRUE);
02240         webdlg.DoModal();
02241 // Don't change the state of the DontShowAgain flag because we didn't show it...
02242 //      UpdateDontShowAgain = webdlg.DontShowAgain();
02243     }
02244 
02245     // If invoked deliberately by the user then tag the HelpAndSupport downloads onto
02246     // the end of this operation...
02247     if (forcedByUser)
02248     {
02249         HelpDownloadOp::CheckForNewFiles(forcedByUser);
02250     } 
02251 #endif
02252     End();
02253 }

String_256 OpUpdate::GetSpecialsFile  )  [static]
 

Get the specials file name, which varies according to whether the user is running the Free Trial or not.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/3/2004

Definition at line 2391 of file menuops.cpp.

02392 {
02393     String_256 SpecialsFile;
02394 
02395     SpecialsFile = _T("SpecialsLX.web");
02396 
02397     return SpecialsFile;
02398 }

static OpState OpUpdate::GetState String_256 ,
OpDescriptor
[inline, static]
 

Definition at line 356 of file menuops.h.

00356 {return OpState();}

String_256 OpUpdate::GetUpdateURL  )  [static]
 

returns the Update URL. Notes: The update URL is scoped to the Major product version to minimise the number of update folders required

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/4/2004

Definition at line 2594 of file menuops.cpp.

02595 {
02596 PORTNOTETRACE("other","OpUpdate::GetUpdateURL() - do nothing");
02597 #ifndef EXCLUDE_FROM_XARALX
02598     String_256 sTemp;
02599     sTemp = IndexBaseURL;
02600     sTemp += PRODUCT_RETAIL_VERSION_NO;
02601     LPCTSTR szURL = sTemp;
02602     String_256 strURLEnc(szURL);
02603     DWORD dwLen = camStrlen(szURL) * 3; // max buffer length for encoded URL
02604 
02605     // Since the version may include illegal URL characters, canonicalise it.
02606     InternetCanonicalizeUrl(szURL, strURLEnc.GetBuffer(dwLen), &dwLen, 0);
02607     strURLEnc.ReleaseBuffer();
02608 
02609     return strURLEnc;
02610 #else
02611     return String_256(_T(""));
02612 #endif
02613 }

String_256 OpUpdate::GetWebFilePath LPCTSTR  filename  )  [static]
 

Returns the full .web file path for a given .web file. Reverts to ENG default if locale scoped file not found.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/3/2004

Definition at line 2449 of file menuops.cpp.

02450 {
02451     String_256          webfilepath;
02452 
02453     PORTNOTETRACE("other","OpUpdate::GetWebFilePath - do nothing");
02454 #ifndef EXCLUDE_FROM_XARALX
02455     CFileStatus         TempStatus;
02456 
02457     // the path to the locale scoped file  ...
02458     webfilepath = GetWebFileRoot() + _T("\\") + CResDll::GetCurrentLocale();
02459     webfilepath += _T("\\") + String_256(filename);
02460 
02461     // if it doesn't exist, revert to the ENG default folder
02462     if (!CFile::GetStatus(webfilepath, TempStatus))
02463     {
02464         webfilepath = GetWebFileRoot() + _T("\\ENG\\") + String_256(filename);
02465     }
02466     TRACEUSER( "Marc", _T("webfilepath = %s\n"),webfilepath);
02467 #endif
02468     return webfilepath;
02469 }

String_256 OpUpdate::GetWebFileRoot  )  [static]
 

Returns the base .web file path.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>

Definition at line 2408 of file menuops.cpp.

02409 {
02410     String_256 exepath;
02411 PORTNOTETRACE("other","OpUpdate::GetWebFileRoot - do nothing");
02412 #ifndef EXCLUDE_FROM_XARALX
02413     
02414 PORTNOTE("other","Removed CResDll usage")
02415 #ifndef EXCLUDE_FROM_XARALX
02416     CResDll::GetExecutablePath(exepath);
02417 #endif
02418     return String_256(exepath) + _T("\\WebFiles");
02419 #else
02420     return exepath;
02421 #endif
02422 
02423 /*
02424 // Save into AppData folder in Documents and Settings:
02425     DWORD CSInfo = CSIDL_APPDATA|CSIDL_FLAG_CREATE;
02426 
02427     String_256 sPartialPath(_T(""),MAX_PATH);
02428     TCHAR* Path = sPartialPath.GetBuffer(MAX_PATH);
02429     SHGetFolderPath(NULL, CSInfo, NULL, 0, Path);
02430     sPartialPath.ReleaseBuffer();
02431     String_256 sPath;
02432     sPath.Format("%s\\Xara\\%s\\%s", sPartialPath, PROGRAM_NAME, _T("\\WebFiles"));
02433 
02434     return sPath;
02435 */
02436 }

BOOL OpUpdate::Init void   )  [static]
 

Initialise the Update operation and preferences.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/3/04
Returns:
TRUE / FALSE

Reimplemented from SimpleCCObject.

Definition at line 2297 of file menuops.cpp.

02298 {
02299 PORTNOTETRACE("other","OpUpdate::Init - do nothing");
02300 #ifndef EXCLUDE_FROM_XARALX
02301     if (! 
02302         RegisterOpDescriptor(
02303             0, 
02304             _T( _R(IDS_APP_UPDATE) ),
02305             CC_RUNTIME_CLASS(OpUpdate), 
02306             OPTOKEN_UPDATE,
02307             OpUpdate::GetState
02308         )
02309     )
02310     {
02311         return FALSE;
02312     }
02313     if (!Camelot.DeclareSection(TEXT("Update"), 12) // 12 because HelpDownloadOp also puts 6 entris here...
02314         || !Camelot.DeclarePref(TEXT("Update"), TEXT("UpdateDontShowAgain"), &UpdateDontShowAgain)
02315         || !Camelot.DeclarePref(TEXT("Update"), TEXT("SpecialsDontShowAgain"), &SpecialsDontShowAgain)
02316         || !Camelot.DeclarePref(TEXT("Update"), TEXT("UpdateFileDate"), &UpdateFileDate)
02317         || !Camelot.DeclarePref(TEXT("Update"), TEXT("SpecialsFileDate"), &SpecialsFileDate)
02318         || !Camelot.DeclarePref(TEXT("Update"), TEXT("WebFilesIndexLeafName"), &IndexLeafName)
02319 
02320 // Only allow the base URL to be configurable in DEBUG builds
02321 // Thus the value assigned to IndexBaseURL above is hardwired into Release builds
02322 #ifdef _DEBUG
02323         || !Camelot.DeclarePref(TEXT("Update"), TEXT("WebFilesBaseURL"), &IndexBaseURL)
02324 #endif
02325         )
02326     {
02327         return FALSE;
02328     }
02329 #endif
02330 
02331     return TRUE;
02332 }

BOOL OpUpdate::UpdateFiles BOOL  bForeground,
const String_256 strClientFolder,
const String_256 strURL,
const String_256 strIndexLeafName,
const String_256 strRegKeyName
[static]
 

Call the WebFileUpdater to download any new files from our servers.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/3/2004

Definition at line 2505 of file menuops.cpp.

02511 {
02512     PORTNOTETRACE("other","OpUpdate::UpdateFiles - do nothing");
02513 #ifndef EXCLUDE_FROM_XARALX
02514     WEBFILEUPDATERLib::IWebFileUpdaterPtr pWebFileUpdater;
02515     HRESULT hr = pWebFileUpdater.CreateInstance(__uuidof(WebFileUpdater));
02516     ERROR2IF(FAILED(hr), FALSE, "Failed To create WebFileUpdater object");
02517 
02518     pWebFileUpdater->put_ClientFolder(_bstr_t(strClientFolder));
02519     pWebFileUpdater->put_ServerURL(_bstr_t(strURL));
02520     pWebFileUpdater->put_IndexName(_bstr_t(strIndexLeafName));
02521 
02522 #ifndef _DEBUG
02523     // Don't let the WFU know about it's stored state in debug builds
02524     // This forces it to download a file every time - good for debugging
02525     //
02526     // Must ensure that the key exists because WFU doesn't create it if it's missing
02527     // (And doesn't DO ANYTHING if it's missing!)
02528     HKEY hKey = CreateRegKey(hAppStateRegKey, strRegKeyName);
02529     if (hKey)
02530     {
02531         // If ServerCheck doesn't exist yet, GetRegDword returns 0
02532         if (GetRegDword(hKey, _T("ServerCheck"))==0)
02533             SetRegDword(hKey, _T("ServerCheck"), 0);
02534         CloseRegKey(hKey);
02535 
02536         String_256 strFullRegKeyPath = _T(PRODUCT_REGISTRYKEY_USERPATH) + strRegKeyName;
02537         pWebFileUpdater->put_RegistryKeyPath(_bstr_t(strFullRegKeyPath));
02538     }
02539 #endif
02540 
02541     hr = pWebFileUpdater->raw_Update((BSTR)NULL, !bForeground);
02542     if (FAILED(hr))
02543     {
02544         UINT32 idMessage = 0;
02545 
02546 //      if (hr==E_XM_CLIENTFOLDERREADONLY)
02547         if (hr==0x80041008)
02548             idMessage = _R(IDS_WARN_PROGRAMFOLDER_READONLY);
02549 //      else if (hr==E_XM_CLIENTFOLDERUNAVAILABLE)
02550         else if (hr==0x80041009)
02551             idMessage = _R(IDS_WARN_PROGRAMFOLDER_UNAVAILABLE);
02552 //      else if (hr==E_XM_COULDNOTWRITEINDEX)
02553         else if (hr==0x80041007)
02554             idMessage = _R(IDS_WARN_PROGRAMFOLDER_NOTWRITABLE);
02555 
02556         if (idMessage!=0)
02557         {
02558             if (bForeground)
02559                 idMessage = idMessage+1;        // NOTE! Message IDs must be interleaved correctly!
02560             ErrorInfo error;
02561             error.ErrorMsg = idMessage;
02562             error.Button[0] = _R(IDS_CONTINUE);
02563             INT32 ret = InformWarning(&error);
02564         }
02565         else if (bForeground)
02566         {
02567 //          String_256 strError(_T(""));
02568 //          strError.Format(_T("Failed to contact xara.com or failed to read update information (0x%08x)."),e.Error());
02569 //          ::MessageBox(NULL, strError, PRODUCT_NAME, MB_OK);
02570             ErrorInfo error;
02571             error.ErrorMsg = _R(IDE_FAILEDTOUPDATEHANDS);
02572             error.Button[0] = _R(IDS_CONTINUE);
02573             INT32 ret = InformWarning(&error);
02574         }
02575         return FALSE;
02576     }
02577 #endif
02578     return TRUE;
02579 }

BOOL OpUpdate::UpdateFiles BOOL  bForeground  )  [static]
 

Call the WebFileUpdater to download any new files from our servers.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/3/2004

Definition at line 2483 of file menuops.cpp.

02484 {
02485     return UpdateFiles(bForeground, GetWebFileRoot(), GetUpdateURL(), (String_256)IndexLeafName, _T("UpdateMessages"));
02486 }


Member Data Documentation

String_256 OpUpdate::IndexBaseURL = _T("http://xara.xaraonline.com/XaraX2/WebFiles/") [static]
 

Definition at line 373 of file menuops.h.

String_32 OpUpdate::IndexLeafName = _T("index.xml") [static]
 

Definition at line 374 of file menuops.h.

BOOL OpUpdate::SpecialsDontShowAgain = TRUE [static, protected]
 

Definition at line 379 of file menuops.h.

INT32 OpUpdate::SpecialsFileDate = 0 [static, protected]
 

Definition at line 381 of file menuops.h.

BOOL OpUpdate::UpdateDontShowAgain = TRUE [static, protected]
 

Definition at line 378 of file menuops.h.

INT32 OpUpdate::UpdateFileDate = 0 [static, protected]
 

Definition at line 380 of file menuops.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:59:11 2007 for Camelot by  doxygen 1.4.4