]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/console/console.h
216439c74e15b514dea6f0b278811d6ff0fb080a
[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-2009 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 three of the GNU Affero 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 Affero 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 Kern Sibbald.
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 "bcomm/dircomm.h"
40
41 #ifndef MAX_NAME_LENGTH
42 #define MAX_NAME_LENGTH 128
43 #endif
44
45 /*
46  * Structure for obtaining the defaults for a job
47  */
48 struct job_defaults {
49    QString job_name;
50    QString pool_name;
51    QString messages_name;
52    QString client_name;
53    QString store_name;
54    QString where;
55    QString level;
56    QString type;
57    QString fileset_name;
58    QString catalog_name;
59    bool enabled;
60 };
61
62 //class DIRRES;
63 //class BSOCK;
64 //class JCR;
65 //class CONRES;
66
67 class Console : public Pages, public Ui::ConsoleForm
68 {
69    Q_OBJECT 
70    friend class DirComm;
71
72 public:
73    Console(QTabWidget *parent);
74    ~Console();
75    int read(int conn);
76    char *msg(int conn);
77    void discardToPrompt(int conn);
78    int write(int conn, const char *msg);
79    int write(int conn, QString msg);
80    int notifyOff(); // enables/disables socket notification - returns the previous state
81    bool notify(int conn, bool enable); // enables/disables socket notification - returns the previous state
82    bool is_notify_enabled(int conn) const;
83    bool getDirComm(int &conn);  
84    bool findDirComm(int &conn);
85    void displayToPrompt(int conn);
86    QString returnFromPrompt(int conn);
87
88    bool dir_cmd(int conn, const char *cmd, QStringList &results);
89    bool dir_cmd(const char *cmd, QStringList &results);
90    bool dir_cmd(QString &cmd, QStringList &results);
91    bool sql_cmd(const char *cmd, QStringList &results);
92    bool sql_cmd(QString &cmd, QStringList &results);
93    bool sql_cmd(int &conn, QString &cmd, QStringList &results);
94    bool sql_cmd(int &conn, const char *cmd, QStringList &results, bool donotify);
95    int write_dir(const char *buf);
96    int write_dir(const char *buf, bool dowait);
97    void write_dir(int conn, const char *buf);
98    void write_dir(int conn, const char *buf, bool dowait);
99    void getDirResName(QString &);
100    void setDirRes(DIRRES *dir);
101    void writeSettings();
102    void readSettings();
103    void setDirectorTreeItem(QTreeWidgetItem *);
104    void terminate();
105    bool is_messagesPending() { return m_messages_pending; };
106    bool is_connected();
107    bool is_connected(int conn);
108    QTreeWidgetItem *directorTreeItem() { return m_directorTreeItem; };
109    void startTimer();
110    void display_text(const char *buf);
111    void display_text(const QString buf);
112    void display_textf(const char *fmt, ...);
113    void display_html(const QString buf);
114    bool get_job_defaults(struct job_defaults &);
115    bool get_job_defaults(int &conn, struct job_defaults &);
116    const QFont get_font();
117    void beginNewCommand(int conn);
118    void populateLists(bool forcenew);
119
120 private:
121    bool get_job_defaults(int &conn, struct job_defaults &, bool donotify);
122    void update_cursor(void);
123    void stopTimer();
124    bool is_connectedGui();
125    bool newDirComm(int &conn);
126    void populateLists(int conn);
127
128 public:
129    QStringList job_list;
130    QStringList client_list;
131    QStringList fileset_list;
132    QStringList messages_list;
133    QStringList pool_list;
134    QStringList storage_list;
135    QStringList type_list;
136    QStringList level_list;
137    QStringList volstatus_list;
138    QStringList mediatype_list;
139    QStringList location_list;
140
141 public slots:
142    void connect_dir();                     
143    void status_dir(void);
144    void messages(void);
145    void set_font(void);
146    void poll_messages(void);
147    void consoleHelp();
148    void consoleReload();
149
150 public:
151    DIRRES *m_dir;                  /* so various pages can reference it */
152    bool m_warningPrevent;
153
154 private:
155    QTextEdit *m_textEdit;
156    QTextCursor *m_cursor;
157    QTreeWidgetItem *m_directorTreeItem;
158    bool m_messages_pending;
159    QTimer *m_timer;
160    bool messagesPending(bool pend);
161    bool hasFocus();
162    QHash<int, DirComm*> m_dircommHash;
163    int m_dircommCounter;
164 };
165
166 #endif /* _CONSOLE_H_ */