aboutsummaryrefslogtreecommitdiffstats
path: root/win32/admin/PropMain.cpp
blob: f15af691c15936af131978072784861c624a337b (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
// PropMain.cpp : implementation file
//

#include <afxdlgs.h>
#include "PropMain.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPropMain property page

IMPLEMENT_DYNCREATE(CPropMain, CPropertyPage)

CPropMain::CPropMain() : CPropertyPage(CPropMain::IDD)
{
	//{{AFX_DATA_INIT(CPropMain)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CPropMain::~CPropMain()
{
}

void CPropMain::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPropMain)
	DDX_Control(pDX, IDC_STOPSERVICE, m_stopservice);
	DDX_Control(pDX, IDC_STARTSERVICE, m_startservice);
	DDX_Control(pDX, IDC_PING_INTERVAL, m_ping_interval);
	DDX_Control(pDX, IDC_VERBOSE, m_Verbose);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPropMain, CPropertyPage)
	//{{AFX_MSG_MAP(CPropMain)
	ON_BN_CLICKED(IDC_STARTSERVICE, OnStartService)
	ON_BN_CLICKED(IDC_STOPSERVICE, OnStopService)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPropMain message handlers

BOOL CPropMain::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	global.conf->verbose = GetProfileInt("verbose", 0);
	global.conf->ping_interval = GetProfileInt("ping_interval_timeout", 0);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CPropMain::OnOK() 
{	
	CPropertyPage::OnOK();

	WriteProfileInt("verbose", global.conf->verbose);
	
	WriteProfileInt("ping_interval_timeout", global.conf->ping_interval);
}

void CPropMain::OnStartService() 
{
	SC_HANDLE   schService;
	SC_HANDLE   schSCManager;
	SERVICE_STATUS status;

    schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS );
	schService = OpenService(schSCManager, "bitlbee", SERVICE_ALL_ACCESS);
	
	ControlService( schService, SERVICE_CONTROL_CONTINUE, &status );

    CloseServiceHandle(schService);
    CloseServiceHandle(schSCManager);
}

void CPropMain::OnStopService() 
{
		SC_HANDLE   schService;
	SC_HANDLE   schSCManager;
	SERVICE_STATUS status;

    schSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS );
	schService = OpenService(schSCManager, "bitlbee", SERVICE_ALL_ACCESS);
	
	ControlService( schService, SERVICE_CONTROL_PAUSE, &status );

    CloseServiceHandle(schService);
    CloseServiceHandle(schSCManager);
}