-
Notifications
You must be signed in to change notification settings - Fork 8
/
UnixHostAddressDlg.cpp
132 lines (115 loc) · 3.18 KB
/
UnixHostAddressDlg.cpp
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//====================================================================================
// Open Computer and Software Inventory Next Generation
// Copyright (C) 2010 OCS Inventory NG Team. All rights reserved.
// Web: http://www.ocsinventory-ng.org
// This code is open source and may be copied and modified as long as the source
// code is always made freely available.
// Please refer to the General Public Licence V2 http://www.gnu.org/ or Licence.txt
//====================================================================================
// UnixHostAddressDlg.cpp : implementation file
//
#include "stdafx.h"
#include "AgentSettings.h"
#include "ocs_deploy_tool.h"
#include "UnixHostAddressDlg.h"
#include "FileVersion.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUnixHostAddressDlg dialog
CUnixHostAddressDlg::CUnixHostAddressDlg(CWnd* pParent /*=NULL*/)
: CDialog(CUnixHostAddressDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CUnixHostAddressDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CUnixHostAddressDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUnixHostAddressDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUnixHostAddressDlg, CDialog)
//{{AFX_MSG_MAP(CUnixHostAddressDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUnixHostAddressDlg message handlers
BOOL CUnixHostAddressDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
try
{
CString csMessage;
// Get tool version
CFileVersion fileVer;
CString csVersion;
// Get application path
if (GetModuleFileName( AfxGetInstanceHandle(), csVersion.GetBuffer( 4*_MAX_PATH+1), 4*_MAX_PATH) == 0)
{
csVersion.Empty();
}
else
{
csVersion.ReleaseBuffer();
// Open application file to get version from file
if (fileVer.Open( csVersion))
{
csVersion = fileVer.GetProductVersion();
csVersion.Remove( ' ');
csVersion.Replace( ',', '.');
fileVer.Close();
}
else
csVersion.Empty();
}
csMessage.FormatMessage( IDS_OCS_DEPLOY_TOOL, csVersion);
SetDlgItemText( IDC_STATUS, csMessage);
SetDlgItemText( IDC_EDIT_LOGIN, m_csHost);
}
catch( CException *pEx)
{
pEx->ReportError( MB_OK|MB_ICONSTOP);
pEx->Delete();
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CUnixHostAddressDlg::OnOK()
{
// TODO: Add extra validation here
try
{
GetDlgItemText( IDC_EDIT_LOGIN, m_csHost);
CDialog::OnOK();
}
catch( CException *pEx)
{
pEx->ReportError( MB_OK|MB_ICONSTOP);
pEx->Delete();
}
}
void CUnixHostAddressDlg::OnCancel()
{
// TODO: Add extra cleanup here
try
{
GetDlgItemText( IDC_EDIT_LOGIN, m_csHost);
CDialog::OnCancel();
}
catch( CException *pEx)
{
pEx->ReportError( MB_OK|MB_ICONSTOP);
pEx->Delete();
}
}
LPCTSTR CUnixHostAddressDlg::GetHost()
{
return m_csHost;
}