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