//
//  Copyright © 2001 - 2002, RESON Inc. All Rights Reserved.
//
//  No part of this file may be reproduced or transmitted in any form or by
//  any means, electronic or mechanical, including photocopy, recording, or
//  information storage or retrieval system, without permission in writing
//  from RESON Inc.
//
//  Filename:   RegistryKeys.h
//
//  Project:    6046.
//
//  Author(s):  W. Arcus
//
//  Purpose:    Defines the unified 6046 Payload Controller's registry keys.
//
//  Notes:
//

#if !defined(AFX_LOGGER_H__6892EF84_ABDC_4598_A211_D2B496815624__INCLUDED_)
#define AFX_LOGGER_H__6892EF84_ABDC_4598_A211_D2B496815624__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <atlbase.h>

namespace N6046RegistryKeys
{
    ///////////////
    // Keys and strings.

    // Main 6046 keys. Note: registry key is now HKEY_USERS\.DEFAULT\SOFTWARE\RESON\6046 was 
    // previously HKEY_CURRENT_USER\SOFTWARE\6046.

    static const HKEY   hKey6046_c                                  = HKEY_USERS;
    static LPCTSTR      lpsz6046RegistryKey_c                       = _T( ".DEFAULT\\Software\\RESON\\6046" );

    // Used by CLogger.

    static LPCTSTR      lpszActivateOnStartKey_c                    = _T( "ActivateOnStart" );
    static LPCTSTR      lpszSessionIdKey_c                          = _T( "SessionId" );
    static LPCTSTR      lpszUserNameKey_c                           = _T( "UserName" );
    static LPCTSTR      lpszUserNotesKey_c                          = _T( "UserNotes" );
    static LPCTSTR      lpszRoutingIndexKey_c                       = _T( "RoutingIndex" );
    static LPCTSTR      lpszRoutingEnableKey_c                      = _T( "RoutingEnable" );
    static LPCTSTR      lpszRemoteControlPortKey_c                  = _T( "RemoteControlPort" );
    static LPCTSTR      lpszTimeSyncModeKey_c                       = _T( "TimeSyncMode" );

    // Used by CDisk.

    static LPCTSTR      lpsz6046DataPathRegistryKey_c               = _T( "DataPath" );
    static LPCTSTR      lpsz6046MaxFileSizeRegistryKey_c            = _T( "MaxFileSizeInMBytes" );
    static LPCTSTR      lpsz6046LoggingRecordOverlapRegistryKey_c   = _T( "RecordOverlap" );

    // Used by CSurveyEventLog.

    static LPCTSTR      lpszDiagnosticsModeKey_c                    = _T( "DiagnosticsMode" );

    // Used by CSystemMonitor.

    static LPCTSTR      lpsz6046CheckPeriodRegistryKey_c            = _T( "AutoHealthCheckPeriod" );
    static LPCTSTR      lpsz6046CheckEnableRegistryKey_c            = _T( "AutoHealthCheckEnable" );

    // Used by CTimeEmitter.

    static LPCTSTR      lpsz6046TimeMessageEmissionKey_c            = _T( "TimeMessageEmission" );

    ///////////////
    // Helper template functions.

    template <class tData>
    bool SetRegistryKeyValue( LPCTSTR lpszKeyName, LPCTSTR lpszValueName, const tData &rtData, const bool &rbCreate = true )
    {
        ASSERT( lpszKeyName   != NULL );
        ASSERT( lpszValueName != NULL );

        bool bSuccess = false;      // Assume failure for now.

        CRegKey Key;

        Key.Attach( hKey6046_c );

        if ( Key.Open( static_cast<HKEY>( Key ), lpszKeyName ) == ERROR_SUCCESS )
        {
            bSuccess = ( Key.SetValue( rtData, lpszValueName ) == ERROR_SUCCESS );
        }
        else if ( rbCreate )
        {
            if ( Key.Create( static_cast<HKEY>( Key ), lpszKeyName ) == ERROR_SUCCESS )
            {
                bSuccess = ( Key.SetValue( rtData, lpszValueName ) == ERROR_SUCCESS );
            }
        }
        else
        {
            bSuccess = false;
        }

        Key.Close();

        return bSuccess;
    }

}       // end namespace N6046RegistryKeys

#endif // !defined(AFX_LOGGER_H__6892EF84_ABDC_4598_A211_D2B496815624__INCLUDED_)
