2 * Bacula File daemon Status Dialog box
4 * Inspired from the VNC code by ATT.
9 Bacula® - The Network Backup Solution
11 Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
13 The main author of Bacula is Kern Sibbald, with contributions from
14 many others, a complete list can be found in the file AUTHORS.
15 This program is Free Software; you can redistribute it and/or
16 modify it under the terms of version two of the GNU General Public
17 License as published by the Free Software Foundation plus additions
18 that are listed in the file LICENSE.
20 This program is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30 Bacula® is a registered trademark of John Walker.
31 The licensor of Bacula is the Free Software Foundation Europe
32 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
33 Switzerland, email:ftf@fsfeurope.org.
37 #include "winbacula.h"
41 extern void output_status(void sendit(const char *msg, int len, void *sarg), void *arg);
43 bacStatus::bacStatus()
46 m_hTextDisplay = NULL;
49 bacStatus::~bacStatus()
54 bacStatus::DisplayString(const char *msg, int len, void *context)
56 /* Get class pointer from user data */
57 bacStatus *_this = (bacStatus *)context;
61 for (pStart = msg, pCurrent = msg; ; pCurrent++) {
62 if (*pCurrent == '\n' || *pCurrent == '\0') {
63 int lenSubstring = pCurrent - pStart;
64 if (lenSubstring > 0) {
65 char *pSubString = (char *)alloca(lenSubstring + 1);
66 bstrncpy(pSubString, pStart, lenSubstring + 1);
68 SendMessage(_this->m_hTextDisplay, EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
69 SendMessage(_this->m_hTextDisplay, EM_REPLACESEL, 0, (LPARAM)pSubString);
72 if (*pCurrent == '\n') {
73 SendMessage(_this->m_hTextDisplay, EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
74 SendMessage(_this->m_hTextDisplay, EM_REPLACESEL, 0, (LONG)"\r\n");
77 if (*pCurrent == '\0'){
80 pStart = pCurrent + 1;
86 bacStatus::UpdateDisplay()
88 if (m_hTextDisplay != NULL) {
89 long lHorizontalPos = GetScrollPos(m_hTextDisplay, SB_HORZ);
90 long lVerticalPos = GetScrollPos(m_hTextDisplay, SB_VERT);
91 long selStart, selEnd;
93 SendMessage(m_hTextDisplay, EM_GETSEL, (WPARAM)&selStart, (LPARAM)&selEnd);
95 SetWindowText(m_hTextDisplay, "");
97 output_status(DisplayString, this);
99 SendMessage(m_hTextDisplay, EM_SETSEL, (WPARAM)selStart, (LPARAM)selEnd);
100 SendMessage(m_hTextDisplay, WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, lHorizontalPos), 0);
101 SendMessage(m_hTextDisplay, WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, lVerticalPos), 0);
105 /* Dialog box handling functions */
107 bacStatus::Show(BOOL show)
109 if (show && !m_bVisible) {
110 DialogBoxParam(hAppInstance, MAKEINTRESOURCE(IDD_STATUS), NULL,
111 (DLGPROC)DialogProc, (LONG)this);
116 bacStatus::ResizeChildren(HWND hDlg, WORD wWidth, WORD wHeight)
118 if (m_hTextDisplay != NULL) {
119 HWND hwndButton = GetDlgItem(hDlg, IDOK);
122 GetWindowRect(hwndButton, &rcWindow);
124 LONG lButtonWidth = rcWindow.right - rcWindow.left;
125 LONG lButtonHeight = rcWindow.bottom - rcWindow.top;
127 MoveWindow(m_hTextDisplay, 8, 8, wWidth - lButtonWidth - 24, wHeight - 16, TRUE);
128 MoveWindow(hwndButton, wWidth - lButtonWidth - 8, 8, lButtonWidth, lButtonHeight, TRUE);
134 bacStatus::DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
136 /* Get class pointer from user data */
137 bacStatus *_this = (bacStatus *)GetWindowLong(hDlg, GWL_USERDATA);
141 /* Set class pointer in user data */
142 SetWindowLong(hDlg, GWL_USERDATA, lParam);
143 _this = (bacStatus *)lParam;
144 _this->m_hTextDisplay = GetDlgItem(hDlg, IDC_TEXTDISPLAY);
146 /* show the dialog */
147 SetForegroundWindow(hDlg);
149 /* Update every 5 seconds */
150 SetTimer(hDlg, 1, 5000, NULL);
151 _this->m_bVisible = TRUE;
152 _this->UpdateDisplay();
156 _this->UpdateDisplay();
160 _this->ResizeChildren(hDlg, LOWORD(lParam), HIWORD(lParam));
164 switch (LOWORD(wParam)) {
168 EndDialog(hDlg, TRUE);
169 _this->m_bVisible = FALSE;
175 _this->m_hTextDisplay = NULL;
177 EndDialog(hDlg, FALSE);
178 _this->m_bVisible = FALSE;