summaryrefslogtreecommitdiff
path: root/Common/ComponentHolder.h
blob: 66b90e2c7307abb6b09b53659dcfb0e406cb1f29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//////////////////////////////////////////////////////////////////
//  
// ComponentHolder.h: interface for the CComponentHolder class.
//
// Holds one componet (either DOS or Windows)
//
// Is Initialized when either DOS or Windows pointer is valid
//
// virtual functions make it possible to override the funtionality
// and create host based app specific components.
// See shutdown.exe program for example of this
//
//////////////////////////////////////////////////////////////////////

#if !defined(COMPONENTHOLDER_H__FDBF1422_18AE_11D2_B2D4_0020182B97FC__INCLUDED_)
#define COMPONENTHOLDER_H__FDBF1422_18AE_11D2_B2D4_0020182B97FC__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "../common/defines.h"
#include "../common/interfaces.h"
#include "../common/ComponentData.h"

#include <mystring.h>

#define CComObjectMember CComObjectGlobal

class CComponentHolder
{

public:
	CComponentHolder();
	virtual ~CComponentHolder();

	// Calls main component function for Windows Components
	virtual HRESULT DoShutdown(DWORD dwMode, HWND hwndParent = NULL);
	// Calls main component function for DOS Components
	virtual HRESULT GetBatchText(string& sBatchText);


	// Initialization 
	// Needs  Registry Key to Initialize and Save the Component Data
	virtual bool IsInitialized();
	virtual HRESULT Initialize(const CLSID& clsid, const string& sRegKey);
	virtual HRESULT Initialize(const string& sID, const string& sRegKey);


	virtual HRESULT Release();

	// Returns type (DOS or Windows)
	virtual UINT GetType();

	// Get's a IUnknown to the Component
	virtual IUnknown* GetUnknown();

protected:
	ISecureShutdownDOS* m_pComponentDOS;
	ISecureShutdownWin* m_pComponentWin;

	// Component ID
protected:
	string m_sID;
public:
	virtual const string& GetID() const { return m_sID; };

	// Name
protected:
	string m_sName;
public:
	const string& GetName() const { return m_sName; };

/*
#ifndef NS_NO_PROPPAGE
	// Component Property Page
protected:
	CComObjectMember<CPropPageHolder> m_PropPage;
public:
//	virtual HRESULT GetPropPage(CPropPageHolder** pPropPage);
//	bool HasPropPage();
#endif // NS_NO_PROPPAGE
*/

	// Component's Data
protected:
	CComObjectMember<CComponentData> m_Data;
public:
	virtual CComponentData* GetData() { return &m_Data; };


	// Host specific Funtions for accessing component data
public:
	int GetInfoInt(NightSecInfo nsItem, int nDefault);
	string GetInfoStr(NightSecInfo nsItem, const string& sDefault);
	CComVariant GetInfo(NightSecInfo nsItem);
	virtual bool IsEnabled() { return m_Data.GetInt(ENABLED_KEY, false) ? true : false; };
	virtual bool Enable(bool bEnable) { return m_Data.WriteInt(ENABLED_KEY, bEnable); } ;
	virtual int GetPos() { return m_Data.GetInt(POSITION_KEY, 1); } ;
	virtual bool SetPos(int nPos) { return m_Data.WriteInt(POSITION_KEY, nPos); } ;

};

#endif // !defined(COMPONENTHOLDER_H__FDBF1422_18AE_11D2_B2D4_0020182B97FC__INCLUDED_)