]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/bcomm/dircomm.h
kes Add first (not yet tested) cut of bcomm to the qt-console directory.
[bacula/bacula] / bacula / src / qt-console / bcomm / dircomm.h
1 #ifndef _DIRCOMM_H_
2 #define _DIRCOMM_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 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 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  *   This is an attempt to move the higher level read/write type
34  *     functionality to the Director out of the Console class into
35  *     a Bacula Communications class.  This class builds on the 
36  *     BSOCK class.
37  * 
38  *
39  *   Kern Sibbald, May 2007
40  */
41
42 #include "bat.h"
43 #include "pages.h"
44
45 class DIRRES;
46 class BSOCK;
47 class CONRES;
48
49 class DirComm : public Pages
50 {
51    Q_OBJECT
52
53 public:
54    DirComm(Console *console);
55    ~DirComm();
56    void display_text(const char *buf);
57    void display_text(const QString buf);
58    void display_textf(const char *fmt, ...);
59    void display_html(const QString buf);
60    void update_cursor(void);
61    void write_dir(const char *buf);
62    bool dir_cmd(const char *cmd, QStringList &results);
63    bool dir_cmd(QString &cmd, QStringList &results);
64    bool sql_cmd(const char *cmd, QStringList &results);
65    bool sql_cmd(QString &cmd, QStringList &results);
66    bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons, 
67           char *buf, int buflen);
68    bool is_connected() { return m_sock != NULL; };
69    bool is_connectedGui();
70    char *msg();
71    void notify(bool enable);
72    void terminate();
73    void beginNewCommand();
74    void displayToPrompt();
75    void discardToPrompt();
76    void setDirectorTreeItem(QTreeWidgetItem *);
77    void setDirRes(DIRRES *dir);
78    void getDirResName(QString &);
79    void startTimer();
80    void stopTimer();
81
82 public slots:
83    void connect_dir(DIRRES *dir, CONRES *cons);
84    void read_dir(int fd);
85    int read(void);
86    int write(const char *msg);
87    int write(QString msg);
88    void poll_messages(void);
89
90 public:
91
92 private:
93    DIRRES *m_dir;
94    BSOCK *m_sock;   
95    bool m_at_prompt;
96    bool m_at_main_prompt;
97    QSocketNotifier *m_notifier;
98    Console *m_console;
99    bool m_api_set;
100    bool m_messages_pending;
101    QTimer *m_timer;
102 };
103
104 #endif /* _DIRCOMM_H_ */