]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/console/console.h
Backport from BEE
[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-2014 Free Software Foundation Europe e.V.
7
8    The main author of Bacula is Kern Sibbald, with contributions from many
9    others, a complete list can be found in the file AUTHORS.
10
11    You may use this file and others of this release according to the
12    license defined in the LICENSE file, which includes the Affero General
13    Public License, v3.0 ("AGPLv3") and some additional permissions and
14    terms pursuant to its AGPLv3 Section 7.
15
16    Bacula® is a registered trademark of Kern Sibbald.
17 */
18 /*
19  *   Version $Id$
20  *
21  *   Kern Sibbald, January 2007
22  */
23
24 #include <QtGui>
25 #include "pages.h"
26 #include "ui_console.h"
27 #include "bcomm/dircomm.h"
28
29 #ifndef MAX_NAME_LENGTH
30 #define MAX_NAME_LENGTH 128
31 #endif
32
33 /*
34  * Structure for obtaining the defaults for a job
35  */
36 struct job_defaults {
37    QString job_name;
38    QString pool_name;
39    QString messages_name;
40    QString client_name;
41    QString store_name;
42    QString where;
43    QString level;
44    QString type;
45    QString fileset_name;
46    QString catalog_name;
47    bool enabled;
48 };
49
50 //class DIRRES;
51 //class BSOCK;
52 //class JCR;
53 //class CONRES;
54
55 class Console : public Pages, public Ui::ConsoleForm
56 {
57    Q_OBJECT
58    friend class DirComm;
59
60 public:
61    Console(QTabWidget *parent);
62    ~Console();
63    int read(int conn);
64    char *msg(int conn);
65    void discardToPrompt(int conn);
66    int write(int conn, const char *msg);
67    int write(int conn, QString msg);
68    int notifyOff(); // enables/disables socket notification - returns the previous state
69    bool notify(int conn, bool enable); // enables/disables socket notification - returns the previous state
70    bool is_notify_enabled(int conn) const;
71    bool getDirComm(int &conn);
72    bool findDirComm(int &conn);
73    void displayToPrompt(int conn);
74    QString returnFromPrompt(int conn);
75
76    bool dir_cmd(int conn, const char *cmd, QStringList &results);
77    bool dir_cmd(const char *cmd, QStringList &results);
78    bool dir_cmd(QString &cmd, QStringList &results);
79    bool sql_cmd(const char *cmd, QStringList &results);
80    bool sql_cmd(QString &cmd, QStringList &results);
81    bool sql_cmd(int &conn, QString &cmd, QStringList &results);
82    bool sql_cmd(int &conn, const char *cmd, QStringList &results, bool donotify);
83    int write_dir(const char *buf);
84    int write_dir(const char *buf, bool dowait);
85    void write_dir(int conn, const char *buf);
86    void write_dir(int conn, const char *buf, bool dowait);
87    void getDirResName(QString &);
88    void setDirRes(DIRRES *dir);
89    void writeSettings();
90    void readSettings();
91    void setDirectorTreeItem(QTreeWidgetItem *);
92    void terminate();
93    bool is_messagesPending() { return m_messages_pending; };
94    bool is_connected();
95    bool is_connected(int conn);
96    QTreeWidgetItem *directorTreeItem() { return m_directorTreeItem; };
97    void startTimer();
98    void display_text(const char *buf);
99    void display_text(const QString buf);
100    void display_textf(const char *fmt, ...);
101    void display_html(const QString buf);
102    bool get_job_defaults(struct job_defaults &);
103    bool get_job_defaults(int &conn, struct job_defaults &);
104    const QFont get_font();
105    void beginNewCommand(int conn);
106    void populateLists(bool forcenew);
107
108 private:
109    bool get_job_defaults(int &conn, struct job_defaults &, bool donotify);
110    void update_cursor(void);
111    void stopTimer();
112    bool is_connectedGui();
113    bool newDirComm(int &conn);
114    void populateLists(int conn);
115
116 public:
117    QStringList job_list;
118    QStringList restore_list;
119    QStringList client_list;
120    QStringList fileset_list;
121    QStringList messages_list;
122    QStringList pool_list;
123    QStringList storage_list;
124    QStringList type_list;
125    QStringList level_list;
126    QStringList volstatus_list;
127    QStringList mediatype_list;
128    QStringList location_list;
129
130 public slots:
131    void connect_dir();
132    void status_dir(void);
133    void messages(void);
134    void set_font(void);
135    void poll_messages(void);
136    void consoleHelp();
137    void consoleReload();
138
139 public:
140    DIRRES *m_dir;                  /* so various pages can reference it */
141    bool m_warningPrevent;
142
143 private:
144    QTextEdit *m_textEdit;
145    QTextCursor *m_cursor;
146    QTreeWidgetItem *m_directorTreeItem;
147    bool m_messages_pending;
148    QTimer *m_timer;
149    bool messagesPending(bool pend);
150    bool hasFocus();
151    QHash<int, DirComm*> m_dircommHash;
152    int m_dircommCounter;
153 };
154
155 #endif /* _CONSOLE_H_ */