1 | /*
|
---|
2 | * synergy -- mouse and keyboard sharing utility
|
---|
3 | * Copyright (C) 2006 Chris Schoeneman
|
---|
4 | *
|
---|
5 | * This package is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU General Public License
|
---|
7 | * found in the file COPYING that should have accompanied this file.
|
---|
8 | *
|
---|
9 | * This package is distributed in the hope that it will be useful,
|
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
12 | * GNU General Public License for more details.
|
---|
13 | */
|
---|
14 |
|
---|
15 | #include "ProtocolTypes.h"
|
---|
16 | #include "CStringUtil.h"
|
---|
17 | #include "Version.h"
|
---|
18 | #include "CArch.h"
|
---|
19 | #include "CInfo.h"
|
---|
20 | #include "LaunchUtil.h"
|
---|
21 | #include "resource.h"
|
---|
22 |
|
---|
23 | //
|
---|
24 | // CInfo
|
---|
25 | //
|
---|
26 |
|
---|
27 | CInfo* CInfo::s_singleton = NULL;
|
---|
28 |
|
---|
29 | CInfo::CInfo(HWND parent) :
|
---|
30 | m_parent(parent)
|
---|
31 | {
|
---|
32 | assert(s_singleton == NULL);
|
---|
33 | s_singleton = this;
|
---|
34 | }
|
---|
35 |
|
---|
36 | CInfo::~CInfo()
|
---|
37 | {
|
---|
38 | s_singleton = NULL;
|
---|
39 | }
|
---|
40 |
|
---|
41 | void
|
---|
42 | CInfo::doModal()
|
---|
43 | {
|
---|
44 | // do dialog
|
---|
45 | DialogBoxParam(s_instance, MAKEINTRESOURCE(IDD_INFO),
|
---|
46 | m_parent, dlgProc, (LPARAM)this);
|
---|
47 | }
|
---|
48 |
|
---|
49 | void
|
---|
50 | CInfo::init(HWND hwnd)
|
---|
51 | {
|
---|
52 | // collect info
|
---|
53 | CString version =
|
---|
54 | CStringUtil::format(getString(IDS_TITLE).c_str(), VERSION);
|
---|
55 | CString hostname = ARCH->getHostName();
|
---|
56 | CString address = ARCH->addrToString(ARCH->nameToAddr(hostname));
|
---|
57 | CString userConfig = ARCH->getUserDirectory();
|
---|
58 | if (!userConfig.empty()) {
|
---|
59 | userConfig = ARCH->concatPath(userConfig, CONFIG_NAME);
|
---|
60 | }
|
---|
61 | CString sysConfig = ARCH->getSystemDirectory();
|
---|
62 | if (!sysConfig.empty()) {
|
---|
63 | sysConfig = ARCH->concatPath(sysConfig, CONFIG_NAME);
|
---|
64 | }
|
---|
65 |
|
---|
66 | // set info
|
---|
67 | HWND child;
|
---|
68 | child = getItem(hwnd, IDC_INFO_VERSION);
|
---|
69 | setWindowText(child, version);
|
---|
70 | child = getItem(hwnd, IDC_INFO_HOSTNAME);
|
---|
71 | setWindowText(child, hostname);
|
---|
72 | child = getItem(hwnd, IDC_INFO_IP_ADDRESS);
|
---|
73 | setWindowText(child, address);
|
---|
74 | child = getItem(hwnd, IDC_INFO_USER_CONFIG);
|
---|
75 | setWindowText(child, userConfig);
|
---|
76 | child = getItem(hwnd, IDC_INFO_SYS_CONFIG);
|
---|
77 | setWindowText(child, sysConfig);
|
---|
78 |
|
---|
79 | // focus on okay button
|
---|
80 | SetFocus(getItem(hwnd, IDOK));
|
---|
81 | }
|
---|
82 |
|
---|
83 | BOOL
|
---|
84 | CInfo::doDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM)
|
---|
85 | {
|
---|
86 | switch (message) {
|
---|
87 | case WM_INITDIALOG:
|
---|
88 | init(hwnd);
|
---|
89 | return FALSE;
|
---|
90 |
|
---|
91 | case WM_COMMAND:
|
---|
92 | switch (LOWORD(wParam)) {
|
---|
93 | case IDOK:
|
---|
94 | case IDCANCEL:
|
---|
95 | EndDialog(hwnd, 0);
|
---|
96 | return TRUE;
|
---|
97 | }
|
---|
98 | break;
|
---|
99 |
|
---|
100 | default:
|
---|
101 | break;
|
---|
102 | }
|
---|
103 |
|
---|
104 | return FALSE;
|
---|
105 | }
|
---|
106 |
|
---|
107 | BOOL CALLBACK
|
---|
108 | CInfo::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
---|
109 | {
|
---|
110 | return s_singleton->doDlgProc(hwnd, message, wParam, lParam);
|
---|
111 | }
|
---|