]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/bcomm/dircomm.h
Backport from Bacula Enterprise
[bacula/bacula] / bacula / src / qt-console / bcomm / dircomm.h
1 #ifndef _DIRCOMM_H_
2 #define _DIRCOMM_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 <QObject>
30
31 #ifndef MAX_NAME_LENGTH
32 #define MAX_NAME_LENGTH 128
33 #endif
34
35 class DIRRES;
36 class BSOCK;
37 class JCR;
38 class CONRES;
39
40 //class DirComm : public QObject
41 class DirComm : public QObject
42 {
43    Q_OBJECT
44    friend class Console;
45 public:
46    DirComm(Console *parent, int conn);
47    ~DirComm();
48    Console *m_console;
49    int  sock_read();
50    bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons, 
51           char *buf, int buflen);
52    bool is_connected() { return m_sock != NULL; };
53    bool is_ready() { return is_connected() && m_at_prompt && m_at_main_prompt; };
54    char *msg();
55    bool notify(bool enable); // enables/disables socket notification - returns the previous state
56    bool is_notify_enabled() const;
57    bool is_in_command() const { return m_in_command > 0; };
58    void terminate();
59    bool connect_dir();                     
60    int read(void);
61    int write(const char *msg);
62    int write(QString msg);
63
64 public slots:
65    void notify_read_dir(int fd);
66
67 private:
68    BSOCK *m_sock;   
69    bool m_at_prompt;
70    bool m_at_main_prompt;
71    bool m_sent_blank;
72    bool m_notify;
73    int  m_in_command;
74    QSocketNotifier *m_notifier;
75    bool m_api_set;
76    int m_conn;
77    bool m_in_select;
78 };
79
80 #endif /* _DIRCOMM_H_ */