]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/bcomm/dircomm.h
Fix bat from eating all Dir connections -- fixes bug #1872
[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-2009 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 three of the GNU Affero 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 Affero 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 Kern Sibbald.
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  *   Kern Sibbald, January 2007
34  */
35
36 #include <QtGui>
37 #include "pages.h"
38 #include "ui_console.h"
39 #include <QObject>
40
41 #ifndef MAX_NAME_LENGTH
42 #define MAX_NAME_LENGTH 128
43 #endif
44
45 class DIRRES;
46 class BSOCK;
47 class JCR;
48 class CONRES;
49
50 //class DirComm : public QObject
51 class DirComm : public QObject
52 {
53    Q_OBJECT
54    friend class Console;
55 public:
56    DirComm(Console *parent, int conn);
57    ~DirComm();
58    Console *m_console;
59    int  sock_read();
60    bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons, 
61           char *buf, int buflen);
62    bool is_connected() { return m_sock != NULL; };
63    bool is_ready() { return is_connected() && m_at_prompt && m_at_main_prompt; };
64    char *msg();
65    bool notify(bool enable); // enables/disables socket notification - returns the previous state
66    bool is_notify_enabled() const;
67    bool is_in_command() const { return m_in_command > 0; };
68    void terminate();
69    bool connect_dir();                     
70    int read(void);
71    int write(const char *msg);
72    int write(QString msg);
73
74 public slots:
75    void notify_read_dir(int fd);
76
77 private:
78    BSOCK *m_sock;   
79    bool m_at_prompt;
80    bool m_at_main_prompt;
81    bool m_sent_blank;
82    bool m_notify;
83    int  m_in_command;
84    QSocketNotifier *m_notifier;
85    bool m_api_set;
86    int m_conn;
87    bool m_in_select;
88 };
89
90 #endif /* _DIRCOMM_H_ */