| AnyConnect Secure Mobility Client 5.1.10.233

Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
MainDialog Class Reference

`#include <MainDialog.h>`

## Public Types
enum | { IDD = IDD_EXAMPLE4_DIALOG }

## Public Member Functions
| MainDialog (Gui *pParent=NULL)
void | HandlePromptCB (ConnectPromptInfo &connectPrompt)
void | HandleEventAvailable ()
void | showStatusbarText (const tstring &text)

## Public Attributes
CStatusBarCtrl * | m_statusBar
PromptDialog * | m_promptDialog
GUIClientImpl * | m_pApiImpl
ConnectPromptInfo * | m_pPromptInfo
std::list< tstring > | m_promptNames

## Protected Member Functions
virtual void | DoDataExchange (CDataExchange *pDX)
virtual BOOL | OnInitDialog ()
afx_msg void | OnSysCommand (UINT nID, LPARAM lParam)
afx_msg void | OnCbnSelchangeCombo1 ()
afx_msg void | OnBnClickedOk ()
afx_msg void | OnBnClickedCancel ()
afx_msg void | OnBnClickedDisconnect ()
LRESULT | OnEventAvailable (WPARAM wparam, LPARAM lparam)

## Protected Attributes
Gui * | m_pParent
tstring | m_hostName

## Detailed Description

MainDialog dialog

## Member Enumeration Documentation

## ◆ anonymous enum

anonymous enum

34{ IDD = IDD_EXAMPLE4_DIALOG };

## Constructor & Destructor Documentation

## ◆ MainDialog()

MainDialog::MainDialog | ( | Gui * | pParent = NULL | ) |

31 : CDialog(MainDialog::IDD, NULL),
32 m_pParent(pParent),
33 m_hostName(_T("")),
34 m_pApiImpl(NULL) { }

## Member Function Documentation

## ◆ DoDataExchange()

void MainDialog::DoDataExchange | ( | CDataExchange * | pDX | ) |
| protected virtual

37{
38 CDialog::DoDataExchange(pDX);
39 DDX_CBString(pDX, IDC_COMBO1, CString(m_hostName.c_str()));
40}

## ◆ HandleEventAvailable()

void MainDialog::HandleEventAvailable | ( |  | ) |

This method demonstrates the posting of an event once the API has indicated there is data available (see GUIClientImpl::EventAvailable).

After the posted event fires, the method MainDialog::OnEventAvailable is called.

114{
115 ::PostMessage( this->m_hWnd , MF_NEWEVENT, 0, 0);
116}

## ◆ HandlePromptCB()

void MainDialog::HandlePromptCB | ( | ConnectPromptInfo & | connectPrompt | ) |

119{
120 m_pPromptInfo = &ConnectPrompt;
121
122 // get the list of PromptEntry received.
123 //
124 ConnectPrompt.getListPromptNames(m_promptNames);
125
126 PromptDialog pdlg(this);
127 m_promptDialog = &pdlg;
128
129 INT_PTR nResponse = m_promptDialog->DoModal();
130 if (nResponse == IDOK)
131 {
132
133 }
134 else if (nResponse == IDCANCEL)
135 {
136 ::AfxMessageBox(_T("Connection cancelled"));
137 }
138
139}

## ◆ OnBnClickedCancel()

void MainDialog::OnBnClickedCancel | ( |  | ) |
| protected

94{
95 OnCancel();
96
97}

## ◆ OnBnClickedDisconnect()

void MainDialog::OnBnClickedDisconnect | ( |  | ) |
| protected

100{
101 if(m_pApiImpl->isConnected())
102 m_pApiImpl->disconnect();
103 else
104 showStatusbarText(_T("Disconnected"));
105}

## ◆ OnBnClickedOk()

void MainDialog::OnBnClickedOk | ( |  | ) |
| protected

85{
86 UpdateData(true);
87 if(!m_pApiImpl->isConnected())
88 m_pApiImpl->connect(m_hostName);
89 else
90 showStatusbarText(_T("Connected"));
91}

## ◆ OnCbnSelchangeCombo1()

void MainDialog::OnCbnSelchangeCombo1 | ( |  | ) |
| protected

108{
109 // TODO: Add your control notification handler code here
110}

## ◆ OnEventAvailable()

LRESULT MainDialog::OnEventAvailable | ( | WPARAM | wparam,
|  | LPARAM | lparam )
| protected

This method is invoked after the posted event from the method MainDialog::HandleEventAvailable fires.

This method invokes the API method ClientIfc::ProcessEvents which in turn causes all pending events (NoticeCB, UserPromptCB, etc.) to be delivered.

79{
80 m_pApiImpl->ProcessEvents();
81 return 0;
82}

## ◆ OnInitDialog()

BOOL MainDialog::OnInitDialog | ( |  | ) |
| protected virtual

55{
56 m_pApiImpl = new GUIClientImpl(this);
57 m_hostName = m_pApiImpl->getDefaultHostName();
58
59 CDialog::OnInitDialog();
60 m_statusBar = new CStatusBarCtrl();
61 m_statusBar->Create(WS_CHILD|WS_VISIBLE,CRect(0,0,0,0), this, IDC_STATUS_BAR);
62 m_statusBar->SetSimple( true );
63
64 if (!m_pApiImpl->attach())
65 {
66 ::AfxMessageBox(_T("Failed to contact vpn service"));
67 PostMessage(WM_QUIT, 0, 0);
68 exit(1);
69 }
70 return TRUE;
71}

## ◆ OnSysCommand()

void MainDialog::OnSysCommand | ( | UINT | nID,
|  | LPARAM | lParam )
| protected

74{
75 CDialog::OnSysCommand(nID, lParam);
76}

## ◆ showStatusbarText()

void MainDialog::showStatusbarText | ( | const tstring & | text | ) |

142{
143 m_statusBar->SetText( text.c_str(), 255, 0);
144}