]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/console/console.h
Oops. When I changed the contents of the field earlier, I forgot to make this change
[bacula/bacula] / bacula / src / qt-console / console / console.h
1 #ifndef _CONSOLE_H_
2 #define _CONSOLE_H_
3 /*
4    Bacula® - The Network Backup Solution
5
6    Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
7
8    The main author of Bacula is Kern Sibbald, with contributions from
9    many others, a complete list can be found in the file AUTHORS.
10    This program is Free Software; you can redistribute it and/or
11    modify it under the terms of version two of the GNU General Public
12    License as published by the Free Software Foundation and included
13    in the file LICENSE.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Bacula® is a registered trademark of John Walker.
26    The licensor of Bacula is the Free Software Foundation Europe
27    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
28    Switzerland, email:ftf@fsfeurope.org.
29 */
30 /*
31  *   Version $Id$
32  *
33  *   Kern Sibbald, January 2007
34  */
35
36 #include <QtGui>
37 #include "pages.h"
38 #include "ui_console.h"
39
40 #ifndef MAX_NAME_LENGTH
41 #define MAX_NAME_LENGTH 128
42 #endif
43
44 /*
45  * Structure for obtaining the defaults for a job
46  */
47 struct job_defaults {
48    QString job_name;
49    QString pool_name;
50    QString messages_name;
51    QString client_name;
52    QString store_name;
53    QString where;
54    QString level;
55    QString type;
56    QString fileset_name;
57    QString catalog_name;
58    bool enabled;
59 };
60
61 class DIRRES;
62 class BSOCK;
63 class JCR;
64 class CONRES;
65
66 class Console : public Pages, public Ui::ConsoleForm
67 {
68    Q_OBJECT 
69
70 public:
71    Console(QStackedWidget *parent);
72    ~Console();
73    void display_text(const char *buf);
74    void display_text(const QString buf);
75    void display_textf(const char *fmt, ...);
76    void display_html(const QString buf);
77    void update_cursor(void);
78    void write_dir(const char *buf);
79    bool dir_cmd(const char *cmd, QStringList &results);
80    bool dir_cmd(QString &cmd, QStringList &results);
81    bool sql_cmd(const char *cmd, QStringList &results);
82    bool sql_cmd(QString &cmd, QStringList &results);
83    bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons, 
84           char *buf, int buflen);
85    bool is_connected() { return m_sock != NULL; };
86    bool is_ready() { return is_connected() && m_at_prompt && m_at_main_prompt; };
87    bool is_connectedGui();
88    bool preventInUseConnect();
89    const QFont get_font();
90    void writeSettings();
91    void readSettings();
92    char *msg();
93    void notify(bool enable);
94    QStringList get_list(char *cmd);
95    bool get_job_defaults(struct job_defaults &);
96    void terminate();
97    void beginNewCommand();
98    void displayToPrompt();
99    void discardToPrompt();
100    void setDirectorTreeItem(QTreeWidgetItem *);
101    void setDirRes(DIRRES *dir);
102    QTreeWidgetItem *directorTreeItem() { return m_directorTreeItem; };
103    void getDirResName(QString &);
104    void startTimer();
105    void stopTimer();
106    void getVolumeList(QStringList &);
107    void getStatusList(QStringList &);
108
109    QStringList job_list;
110    QStringList client_list;
111    QStringList fileset_list;
112    QStringList messages_list;
113    QStringList pool_list;
114    QStringList storage_list;
115    QStringList type_list;
116    QStringList level_list;
117
118
119 public slots:
120    void connect_dir();                     
121    void read_dir(int fd);
122    int read(void);
123    int write(const char *msg);
124    int write(QString msg);
125    void status_dir(void);
126    void messages(void);
127    void set_font(void);
128    void poll_messages(void);
129    void consoleHelp();
130    void consoleReload();
131
132 public:
133    DIRRES *m_dir;                  /* so various pages can reference it */
134
135 private:
136    QTextEdit *m_textEdit;
137    BSOCK *m_sock;   
138    bool m_at_prompt;
139    bool m_at_main_prompt;
140    QSocketNotifier *m_notifier;
141    QTextCursor *m_cursor;
142    QTreeWidgetItem *m_directorTreeItem;
143    bool m_api_set;
144    bool m_messages_pending;
145    QTimer *m_timer;
146 };
147
148 #endif /* _CONSOLE_H_ */