]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/console/console.h
Multiple directors are working. Still more todo. See TODO file.
[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 plus additions
13    that are listed 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 #include "restore.h"
40 #include "select.h"
41
42 #ifndef MAX_NAME_LENGTH
43 #define MAX_NAME_LENGTH 128
44 #endif
45
46 /*
47  * Structure for obtaining the defaults for a job
48  */
49 struct job_defaults {
50    QString job_name;
51    QString pool_name;
52    QString messages_name;
53    QString client_name;
54    QString store_name;
55    QString where;
56    QString level;
57    QString type;
58    QString fileset_name;
59    QString catalog_name;
60    bool enabled;
61 };
62
63 class DIRRES;
64 class BSOCK;
65 class JCR;
66 class CONRES;
67
68 class Console : public Pages, public Ui::ConsoleForm
69 {
70    Q_OBJECT 
71
72 public:
73    Console(QStackedWidget *parent);
74    ~Console();
75    void display_text(const char *buf);
76    void display_text(const QString buf);
77    void display_textf(const char *fmt, ...);
78    void update_cursor(void);
79    void write_dir(const char *buf);
80    bool dir_cmd(const char *cmd, QStringList &results);
81    bool dir_cmd(QString &cmd, QStringList &results);
82    bool sql_cmd(const char *cmd, QStringList &results);
83    bool sql_cmd(QString &cmd, QStringList &results);
84    bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons);
85    bool is_connected() { return m_sock != NULL; };
86    const QFont get_font();
87    void writeSettings();
88    void readSettings();
89    char *msg();
90    void notify(bool enable);
91    QStringList get_list(char *cmd);
92    bool get_job_defaults(struct job_defaults &);
93    void terminate();
94    void beginNewCommand();
95    void displayToPrompt();
96    void discardToPrompt();
97    void setDirectorTreeItem(QTreeWidgetItem *);
98    void setDirRes(DIRRES *dir);
99    QTreeWidgetItem *directorTreeItem() { return m_directorTreeItem; };
100
101    QStringList job_list;
102    QStringList client_list;
103    QStringList fileset_list;
104    QStringList messages_list;
105    QStringList pool_list;
106    QStringList storage_list;
107    QStringList type_list;
108    QStringList level_list;
109
110
111 public slots:
112    void connect();                     
113    void read_dir(int fd);
114    int read(void);
115    int write(const char *msg);
116    int write(QString msg);
117    void status_dir(void);
118    void set_font(void);
119    void poll_messages(void);
120
121 private:
122    QTextEdit *m_textEdit;
123    DIRRES *m_dir;
124    BSOCK *m_sock;   
125    bool m_at_prompt;
126    QSocketNotifier *m_notifier;
127    QTextCursor *m_cursor;
128    QTreeWidgetItem *m_directorTreeItem;
129    bool m_api_set;
130    bool m_messages_pending;
131    QTimer *m_timer;
132 };
133
134 #endif /* _CONSOLE_H_ */