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