summaryrefslogtreecommitdiffabout
path: root/ACLTargetCombo.cpp
blob: cdbd07579be3b725edb29fad607d58348ac3ebb2 (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
// ACLTargetCombo.cpp : implementation file
//

#include "stdafx.h"
#include "PumpKIN.h"
#include "PumpKINDlg.h"
#include "ACLTargetCombo.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CACLTargetCombo

CACLTargetCombo::CACLTargetCombo()
: m_op(-1)
{
}

CACLTargetCombo::~CACLTargetCombo()
{
}


BEGIN_MESSAGE_MAP(CACLTargetCombo, CComboBox)
	//{{AFX_MSG_MAP(CACLTargetCombo)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CACLTargetCombo message handlers

void CACLTargetCombo::SetOp(int op)
{
	m_op=op;
	ResetContent();
	switch(op) {
	case tftp::opRRQ:
		m_tmap.RemoveAll();
		SetItemData(m_tmap[acl_rule::rrqNone]=AddString("fallback to global"),acl_rule::rrqNone);
		SetItemData(m_tmap[acl_rule::rrqDeny]=AddString("deny access"),acl_rule::rrqDeny);
		SetItemData(m_tmap[acl_rule::rrqPrompt]=AddString("prompt"),acl_rule::rrqPrompt);
		SetItemData(m_tmap[acl_rule::rrqGrant]=AddString("grant access"),CPumpKINDlg::rrqGrant);
		SetCurSel(0);
		EnableWindow(TRUE);
		break;
	case tftp::opWRQ:
		m_tmap.RemoveAll();
		SetItemData(m_tmap[acl_rule::wrqNone]=AddString("fallback to global"),acl_rule::wrqNone);
		SetItemData(m_tmap[acl_rule::wrqDeny]=AddString("deny access"),acl_rule::wrqDeny);
		SetItemData(m_tmap[acl_rule::wrqPrompt]=AddString("prompt"),acl_rule::wrqPrompt);
		SetItemData(m_tmap[acl_rule::wrqPromptIfExists]=AddString("prompt if file exists"),acl_rule::wrqPromptIfExists);
		SetItemData(m_tmap[acl_rule::wrqGrant]=AddString("grant access"),acl_rule::wrqGrant);
		SetCurSel(0);
		EnableWindow(TRUE);
		break;
	default:
		EnableWindow(FALSE);
		break;
	}
}

int CACLTargetCombo::GetTarget()
{
	int cs=GetCurSel();
	if(cs==CB_ERR)
		return -1;
	return GetItemData(cs);
}

void CACLTargetCombo::SetTarget(int t,int op)
{
	if(op>=0)
		SetOp(op);
	ASSERT(m_op>=0);
	int i;
	if(m_tmap.Lookup(t,i))
		SetCurSel(i);
	else
		SetCurSel(0);
}