2 * Bacula File daemon Status Dialog box
4 * Inspired from the VNC code by ATT.
6 * Copyright (2000) Kern E. Sibbald
10 Bacula® - The Network Backup Solution
12 Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
14 The main author of Bacula is Kern Sibbald, with contributions from
15 many others, a complete list can be found in the file AUTHORS.
16 This program is Free Software; you can redistribute it and/or
17 modify it under the terms of version two of the GNU General Public
18 License as published by the Free Software Foundation plus additions
19 that are listed in the file LICENSE.
21 This program is distributed in the hope that it will be useful, but
22 WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
31 Bacula® is a registered trademark of John Walker.
32 The licensor of Bacula is the Free Software Foundation Europe
33 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
34 Switzerland, email:ftf@fsfeurope.org.
38 #include "winbacula.h"
42 extern void output_status(void sendit(const char *msg, int len, void *sarg), void *arg);
44 bacStatus::bacStatus()
47 m_hTextDisplay = NULL;
50 bacStatus::~bacStatus()
55 bacStatus::DisplayString(const char *msg, int len, void *context)
57 /* Get class pointer from user data */
58 bacStatus *_this = (bacStatus *)context;
62 for (pStart = msg, pCurrent = msg; ; pCurrent++) {
63 if (*pCurrent == '\n' || *pCurrent == '\0') {
64 int lenSubstring = pCurrent - pStart;
65 if (lenSubstring > 0) {
66 char *pSubString = (char *)alloca(lenSubstring + 1);
67 bstrncpy(pSubString, pStart, lenSubstring + 1);
69 SendMessage(_this->m_hTextDisplay, EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
70 SendMessage(_this->m_hTextDisplay, EM_REPLACESEL, 0, (LPARAM)pSubString);
73 if (*pCurrent == '\n') {
74 SendMessage(_this->m_hTextDisplay, EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
75 SendMessage(_this->m_hTextDisplay, EM_REPLACESEL, 0, (LONG)"\r\n");
78 if (*pCurrent == '\0'){
81 pStart = pCurrent + 1;
87 bacStatus::UpdateDisplay()
89 if (m_hTextDisplay != NULL) {
90 long lHorizontalPos = GetScrollPos(m_hTextDisplay, SB_HORZ);
91 long lVerticalPos = GetScrollPos(m_hTextDisplay, SB_VERT);
92 long selStart, selEnd;
94 SendMessage(m_hTextDisplay, EM_GETSEL, (WPARAM)&selStart, (LPARAM)&selEnd);
96 SetWindowText(m_hTextDisplay, "");
98 output_status(DisplayString, this);
100 SendMessage(m_hTextDisplay, EM_SETSEL, (WPARAM)selStart, (LPARAM)selEnd);
101 SendMessage(m_hTextDisplay, WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, lHorizontalPos), 0);
102 SendMessage(m_hTextDisplay, WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, lVerticalPos), 0);
106 /* Dialog box handling functions */
108 bacStatus::Show(BOOL show)
110 if (show && !m_bVisible) {
111 DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_STATUS), NULL,
112 (DLGPROC)DialogProc, (LONG)this);
117 bacStatus::ResizeChildren(HWND hDlg, WORD wWidth, WORD wHeight)
119 if (m_hTextDisplay != NULL) {
120 HWND hwndButton = GetDlgItem(hDlg, IDOK);
123 GetWindowRect(hwndButton, &rcWindow);
125 LONG lButtonWidth = rcWindow.right - rcWindow.left;
126 LONG lButtonHeight = rcWindow.bottom - rcWindow.top;
128 MoveWindow(m_hTextDisplay, 8, 8, wWidth - lButtonWidth - 24, wHeight - 16, TRUE);
129 MoveWindow(hwndButton, wWidth - lButtonWidth - 8, 8, lButtonWidth, lButtonHeight, TRUE);
135 bacStatus::DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
137 /* Get class pointer from user data */
138 bacStatus *_this = (bacStatus *)GetWindowLong(hDlg, GWL_USERDATA);
142 /* Set class pointer in user data */
143 SetWindowLong(hDlg, GWL_USERDATA, lParam);
144 _this = (bacStatus *)lParam;
145 _this->m_hTextDisplay = GetDlgItem(hDlg, IDC_TEXTDISPLAY);
147 /* show the dialog */
148 SetForegroundWindow(hDlg);
150 /* Update every 5 seconds */
151 SetTimer(hDlg, 1, 5000, NULL);
152 _this->m_bVisible = TRUE;
153 _this->UpdateDisplay();
157 _this->UpdateDisplay();
161 _this->ResizeChildren(hDlg, LOWORD(lParam), HIWORD(lParam));
165 switch (LOWORD(wParam)) {
169 EndDialog(hDlg, TRUE);
170 _this->m_bVisible = FALSE;
176 _this->m_hTextDisplay = NULL;
178 EndDialog(hDlg, FALSE);
179 _this->m_bVisible = FALSE;