]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/main.cpp
Create archivedir
[bacula/bacula] / bacula / src / wx-console / main.cpp
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2004-2008 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version two of the GNU General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /*
29  *
30  *    Bacula bwx-console application
31  *
32  *    Nicolas Boichat, April 2004
33  *
34  *    Version $Id$
35  */
36
37
38 // ============================================================================
39 // declarations
40 // ============================================================================
41
42 // ----------------------------------------------------------------------------
43 // headers
44 // ----------------------------------------------------------------------------
45
46 /*  Windows debug builds set _DEBUG which is used by wxWidgets to select their
47  *  debug memory allocator.  Unfortunately it conflicts with Bacula's SmartAlloc.
48  * So we turn _DEBUG off since we aren't interested in things it enables.
49  */
50
51 #undef _DEBUG
52
53 #include "bacula.h"
54
55 #include <wx/wxprec.h>
56 #include <wx/config.h>
57 #include <wx/intl.h>
58 #include "wxbmainframe.h"
59 #include "csprint.h"
60
61
62 /* Dummy functions */
63 int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
64 int generate_job_event(JCR *jcr, const char *event) { return 1; }
65
66
67 // ----------------------------------------------------------------------------
68 // resources
69 // ----------------------------------------------------------------------------
70
71 class MyApp : public wxApp
72 {
73 public:
74    virtual bool OnInit();
75 };
76
77 // ============================================================================
78 // implementation
79 // ============================================================================
80
81 IMPLEMENT_APP(MyApp)
82
83 // ----------------------------------------------------------------------------
84 // the application class
85 // ----------------------------------------------------------------------------
86
87 // 'Main program' equivalent: the program execution "starts" here
88 bool MyApp::OnInit()
89 {
90    /* wxWidgets internationalisation */
91    wxLocale m_locale;
92    m_locale.Init();
93    m_locale.AddCatalog(wxT("bacula"));
94    wxLocale::AddCatalogLookupPathPrefix(wxT(LOCALEDIR));
95
96    long posx, posy, sizex, sizey;
97    int displayx, displayy;
98    OSDependentInit();
99    wxConfig::Get()->Read(wxT("/Position/X"), &posx, 50);
100    wxConfig::Get()->Read(wxT("/Position/Y"), &posy, 50);
101    wxConfig::Get()->Read(wxT("/Size/Width"), &sizex, 780);
102    wxConfig::Get()->Read(wxT("/Size/Height"), &sizey, 500);
103    
104    wxDisplaySize(&displayx, &displayy);
105    
106    /* Check if we are on the screen... */
107    if ((posx+sizex > displayx) || (posy+sizey > displayy)) {
108       /* Try to move the top-left corner first */
109       posx = 50;
110       posy = 50;
111       if ((posx+sizex > displayx) || (posy+sizey > displayy)) {
112          posx = 25;
113          posy = 25;
114          sizex = displayx - 50;
115          sizey = displayy - 50;
116       }
117    }
118
119    wxbMainFrame *frame = wxbMainFrame::CreateInstance(_("Bacula bwx-console"),
120                          wxPoint(posx, posy), wxSize(sizex, sizey));
121
122    frame->Show(TRUE);
123
124    frame->Print(wxString::Format(_("Welcome to bacula bwx-console %s (%s)!\n"), wxT(VERSION), wxT(BDATE)), CS_DEBUG);
125
126    frame->StartConsoleThread(wxT(""));
127    
128    return TRUE;
129 }