OpRegister Class Reference

Manage registration of CD. More...

#include <menuops.h>

Inheritance diagram for OpRegister:

Operation MessageHandler ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 OpRegister ()
 Constructor for OpRegister.
void Do (OpDescriptor *)
 The default Register operation called from the menu.
void DoWithParam (OpDescriptor *, OpParam *Params)
 Either the user requested to register or it is an auto-check.

Static Public Member Functions

static BOOL Init ()
 Register an OpDescriptor.
static OpState GetState (String_256 *, OpDescriptor *)
static String_256 GetSerialNumber ()
 returns the serial number stored in the registry
static BOOL get_HasRegistered ()
 Read registry value to find out if the user has registered. This is no longer a Pref but stored with the serial number key so that it persists when the product is uninstalled.
static void put_HasRegistered (BOOL)
 Write registry value to find out if the user has registered.

Protected Member Functions

BOOL RegisterOnline ()
 Creates a StratusClient to actually perform online registration.

Static Protected Attributes

static BOOL RegisteredOnline = FALSE
static DATE LastCheck = (DATE)1.0
static INT32 DaysBetweenAutoChecks = 5

Detailed Description

Manage registration of CD.

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

Definition at line 307 of file menuops.h.


Constructor & Destructor Documentation

OpRegister::OpRegister  ) 
 

Constructor for OpRegister.

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

Definition at line 2623 of file menuops.cpp.

02623                       : Operation()
02624 {}


Member Function Documentation

void OpRegister::Do OpDescriptor od  )  [virtual]
 

The default Register operation called from the menu.

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

Reimplemented from Operation.

Definition at line 2693 of file menuops.cpp.

02694 {
02695     OpParam temp((INT32) TRUE, (void *)NULL);
02696     this->DoWithParam(od, &temp);
02697 }

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

Either the user requested to register or it is an auto-check.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/5/2004
Parameters:
(BOOL)OpParam->Param1 - User requested registration [INPUTS]

Reimplemented from Operation.

Definition at line 2642 of file menuops.cpp.

02643 {
02644 PORTNOTETRACE("other","OpRegister::DoWithParam - do nothing");
02645 #ifndef EXCLUDE_FROM_XARALX
02646     BOOL Requested = (BOOL)pOpParam->Param1;
02647     if(Requested)
02648     {
02649         if(RegisterOnline())
02650         {
02651             put_HasRegistered(TRUE);
02652         }
02653     }
02654     else
02655     {
02656         // an auto-check only prompts the user if it's long enough since we last nagged them
02657         if(!get_HasRegistered())
02658         {
02659             COleDateTimeSpan ts = COleDateTime::GetCurrentTime() - COleDateTime(LastCheck);
02660             INT32 DaysSinceLastCheck = ts.GetTotalDays();
02661             if( DaysSinceLastCheck >= DaysBetweenAutoChecks )
02662             {
02663                 CRegisterDialog RegisterDlg;
02664                 switch(RegisterDlg.DoModal())
02665                 {
02666                 case IDOK:
02667                     if(RegisterOnline())
02668                     {
02669                         put_HasRegistered(TRUE);
02670                     }
02671                     break;
02672                 case IDCANCEL:
02673                 default:
02674                     {
02675                         LastCheck = COleDateTime::GetCurrentTime().m_dt;
02676                     }
02677                     break;
02678                 }
02679             }
02680         }
02681     }
02682 #endif
02683 }

BOOL OpRegister::get_HasRegistered  )  [static]
 

Read registry value to find out if the user has registered. This is no longer a Pref but stored with the serial number key so that it persists when the product is uninstalled.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/Aug/2005

Definition at line 2790 of file menuops.cpp.

02791 {
02792 PORTNOTETRACE("other","OpRegister::get_HasRegistered - do nothing - always registered?");
02793 #ifndef EXCLUDE_FROM_XARALX
02794     // Open the key.
02795     HKEY    hKey = OpenRegKey(HKEY_CLASSES_ROOT,SERIALNO_REGPATH);
02796     BOOL    bRegistered = GetRegBool(hKey,TEXT("HasRegistered"));
02797     CloseRegKey(hKey);
02798     return bRegistered;
02799 #else
02800     return TRUE;
02801 #endif
02802 }

String_256 OpRegister::GetSerialNumber  )  [static]
 

returns the serial number stored in the registry

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

Definition at line 2742 of file menuops.cpp.

02743 {
02744     // We now use a registry key to hold serial number data, so use that if available. If not then
02745     // display nothing.
02746     String_256      serialNumber = "";
02747 
02748 PORTNOTETRACE("other","OpRegister::getSerialNumber - do nothing");
02749 #ifndef EXCLUDE_FROM_XARALX
02750 
02751     HKEY        hKey = NULL;
02752     INT32           i;
02753     char        unlockCode[32];
02754     DWORD       dwType = REG_SZ;
02755     DWORD       dwSize = sizeof(unlockCode);
02756 
02757     // Initialise unlock code buffer.
02758     for(i=0;i<32;i++)
02759     {
02760         unlockCode[i] = NULL;
02761     }
02762 
02763     // Open the key.
02764     hKey = OpenRegKey(HKEY_CLASSES_ROOT,SERIALNO_REGPATH);
02765     if(hKey != NULL)
02766     {
02767         GetRegValue(hKey,"ulc",&dwType,unlockCode,&dwSize);
02768 
02769         serialNumber = unlockCode;
02770 
02771         // Close the key.
02772         RegCloseKey(hKey);
02773     }
02774 #endif
02775 
02776     return serialNumber;
02777 }

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

Definition at line 313 of file menuops.h.

00313 {return OpState();}

BOOL OpRegister::Init void   )  [static]
 

Register an OpDescriptor.

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

Reimplemented from SimpleCCObject.

Definition at line 2707 of file menuops.cpp.

02708 {
02709 PORTNOTETRACE("other","OpRegister::Init - do nothing");
02710 #ifndef EXCLUDE_FROM_XARALX
02711     if (! 
02712         RegisterOpDescriptor(
02713             0, 
02714             _R(IDS_REGISTER_MENUTEXT),
02715             CC_RUNTIME_CLASS(OpRegister), 
02716             OPTOKEN_REGISTER,
02717             OpRegister::GetState
02718         )
02719     )
02720     {
02721         return FALSE;
02722     }
02723     if (!Camelot.DeclareSection(TEXT("Register"), 2)    
02724         || !Camelot.DeclarePref(TEXT("Register"), TEXT("LastCheck"), &LastCheck)
02725         )
02726     {
02727         return FALSE;
02728     }
02729 #endif
02730 
02731     return TRUE;
02732 }

void OpRegister::put_HasRegistered BOOL  bHasRegistered  )  [static]
 

Write registry value to find out if the user has registered.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/Aug/2005

Definition at line 2812 of file menuops.cpp.

02813 {
02814 PORTNOTETRACE("other","OpRegister::get_HasRegistered - do nothing - always registered?");
02815 #ifndef EXCLUDE_FROM_XARALX
02816     HKEY    hKey = OpenRegKey(HKEY_CLASSES_ROOT,SERIALNO_REGPATH);
02817     SetRegBool(hKey, TEXT("HasRegistered"), bHasRegistered);
02818     CloseRegKey(hKey);
02819 #endif
02820 }

BOOL OpRegister::RegisterOnline  )  [protected]
 

Creates a StratusClient to actually perform online registration.

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

Definition at line 2832 of file menuops.cpp.

02833 {
02834 PORTNOTETRACE("other","OpRegister::RegsiterOnline - do nothing");
02835 #ifndef EXCLUDE_FROM_XARALX
02836     BOOL RegSuccess = FALSE; 
02837     IStratusClient2Ptr pStratusClient;
02838     HRESULT hr = pStratusClient.CreateInstance(__uuidof(StratusClient_1_0_2)) ;
02839     ERROR2IF(FAILED(hr), FALSE, "Stratus Client didn't create") ;
02840 
02841     pStratusClient->put_ParentWindow((INT32)(GetMainFrame()->GetSafeHwnd()));
02842     pStratusClient->put_SerialNumber(_bstr_t(OpRegister::GetSerialNumber())) ;
02843     pStratusClient->put_RegistryKey(_bstr_t(_T("\\" PRODUCT_REGISTRYKEY_FULLPATH "Connect")));
02844     pStratusClient->put_HintText(_bstr_t(_T("")));// need to blank the default
02845     pStratusClient->put_ShowStorePassword(FALSE) ;
02846     pStratusClient->put_ConnectButtonText(_bstr_t(String_256((LPCSTR)_R(IDS_REGISTER_BUTTON))));
02847     pStratusClient->put_ConnectTitle(_bstr_t(String_256((LPCSTR)_R(IDS_REGISTER_TITLE))));
02848     pStratusClient->put_JoinTitle(_bstr_t(String_256((LPCSTR)_R(IDS_REGISTER_TITLE))));
02849     pStratusClient->put_ConnectText(_bstr_t(String_256((LPCSTR)_R(IDS_REGISTER_MAINTEXT))));
02850     pStratusClient->put_JoinText(_bstr_t(String_256((LPCSTR)_R(IDS_REGISTER_JOINTEXT))));
02851 
02852     try
02853     {
02854         // registration succeeds if the sign-in method is successfully invoked
02855         pStratusClient->SignIn((BSTR)NULL,(BSTR)NULL);
02856         RegSuccess = TRUE;
02857     }
02858     catch(_com_error e)
02859     {
02860         if (e.Error() != E_XM_CONNECTCANCELLED)
02861         {
02862             String_256 strError;
02863             strError.Format(String_256((LPCSTR)_R(IDS_REGISTER_CONNECTPROBLEM)),e.Error());
02864             ::MessageBox(NULL, strError, PRODUCT_NAME, MB_OK);
02865         }
02866     }
02867 
02868     if(RegSuccess)
02869         ::MessageBox(NULL, String_256((LPCSTR)_R(IDS_REGISTER_REGSUCCESS)), PRODUCT_NAME, MB_OK);
02870 
02871     return RegSuccess;
02872 #else
02873     return TRUE;
02874 #endif
02875 }


Member Data Documentation

INT32 OpRegister::DaysBetweenAutoChecks = 5 [static, protected]
 

Definition at line 331 of file menuops.h.

DATE OpRegister::LastCheck = (DATE)1.0 [static, protected]
 

Definition at line 328 of file menuops.h.

BOOL OpRegister::RegisteredOnline = FALSE [static, protected]
 

Definition at line 324 of file menuops.h.


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