From: Kern Sibbald Date: Sun, 28 Jan 2007 15:43:04 +0000 (+0000) Subject: Move console into subdir X-Git-Tag: Release-7.0.0~6990 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d14350adddf830dfc1d4778d5171866838eac93a;p=bacula%2Fbacula Move console into subdir git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4066 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/Makefile b/bacula/src/qt-console/Makefile index ab5da4f5ab..e59111f8c6 100644 --- a/bacula/src/qt-console/Makefile +++ b/bacula/src/qt-console/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: bat -# Generated by qmake (2.01a) (Qt 4.2.1) on: Sun Jan 28 16:32:50 2007 +# Generated by qmake (2.01a) (Qt 4.2.1) on: Sun Jan 28 16:40:37 2007 # Project: bat.pro # Template: app # Command: /usr/bin/qmake -unix -o Makefile bat.pro @@ -17,7 +17,7 @@ CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES) LEXFLAGS = YACCFLAGS = -d -INCPATH = -I/usr/share/qt4/mkspecs/default -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include -I. -I.. -I. -I. +INCPATH = -I/usr/share/qt4/mkspecs/default -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include -I. -Iconsole -I.. -I. -I. LINK = g++ LFLAGS = LIBS = $(SUBLIBS) -L/usr/lib -L../lib -lbac -lssl -lcrypto -lQtGui -L/usr/lib -L/usr/X11R6/lib -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz -lm -ldl -lpthread @@ -49,7 +49,7 @@ SOURCES = main.cpp \ authenticate.cpp \ bat_conf.cpp \ mainwin.cpp \ - console.cpp moc_mainwin.cpp \ + console/console.cpp moc_mainwin.cpp \ moc_console.cpp \ qrc_main.cpp OBJECTS = main.o \ @@ -150,7 +150,7 @@ qmake: FORCE dist: @$(CHK_DIR_EXISTS) .tmp/bat1.0.0 || $(MKDIR) .tmp/bat1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/bat1.0.0/ && $(COPY_FILE) --parents mainwin.h bat.h bat_conf.h console.h .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.qrc .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.cpp authenticate.cpp bat_conf.cpp mainwin.cpp console.cpp .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.ui .tmp/bat1.0.0/ && (cd `dirname .tmp/bat1.0.0` && $(TAR) bat1.0.0.tar bat1.0.0 && $(COMPRESS) bat1.0.0.tar) && $(MOVE) `dirname .tmp/bat1.0.0`/bat1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/bat1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/bat1.0.0/ && $(COPY_FILE) --parents mainwin.h bat.h bat_conf.h console/console.h .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.qrc .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.cpp authenticate.cpp bat_conf.cpp mainwin.cpp console/console.cpp .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.ui .tmp/bat1.0.0/ && (cd `dirname .tmp/bat1.0.0` && $(TAR) bat1.0.0.tar bat1.0.0 && $(COMPRESS) bat1.0.0.tar) && $(MOVE) `dirname .tmp/bat1.0.0`/bat1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/bat1.0.0 yaccclean: @@ -182,9 +182,9 @@ moc_mainwin.cpp: ui_main.h \ /usr/bin/moc /usr/bin/moc $(DEFINES) $(INCPATH) mainwin.h -o moc_mainwin.cpp -moc_console.cpp: console.h \ +moc_console.cpp: console/console.h \ /usr/bin/moc - /usr/bin/moc $(DEFINES) $(INCPATH) console.h -o moc_console.cpp + /usr/bin/moc $(DEFINES) $(INCPATH) console/console.h -o moc_console.cpp compiler_rcc_make_all: qrc_main.cpp compiler_rcc_clean: @@ -218,15 +218,13 @@ compiler_clean: compiler_moc_header_clean compiler_rcc_clean compiler_image_coll main.o: main.cpp bat.h \ mainwin.h \ ui_main.h \ - bat_conf.h \ - console.h + bat_conf.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp authenticate.o: authenticate.cpp bat.h \ mainwin.h \ ui_main.h \ - bat_conf.h \ - console.h + bat_conf.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o authenticate.o authenticate.cpp bat_conf.o: bat_conf.cpp bat_conf.h @@ -235,16 +233,15 @@ bat_conf.o: bat_conf.cpp bat_conf.h mainwin.o: mainwin.cpp bat.h \ mainwin.h \ ui_main.h \ - bat_conf.h \ - console.h + bat_conf.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwin.o mainwin.cpp -console.o: console.cpp bat.h \ +console.o: console/console.cpp bat.h \ mainwin.h \ ui_main.h \ bat_conf.h \ - console.h - $(CXX) -c $(CXXFLAGS) $(INCPATH) -o console.o console.cpp + console/console.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o console.o console/console.cpp moc_mainwin.o: moc_mainwin.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_mainwin.o moc_mainwin.cpp diff --git a/bacula/src/qt-console/bat.pro b/bacula/src/qt-console/bat.pro index e7e092f31b..1d537f90fa 100644 --- a/bacula/src/qt-console/bat.pro +++ b/bacula/src/qt-console/bat.pro @@ -5,7 +5,7 @@ TEMPLATE = app TARGET = bat DEPENDPATH += . -INCLUDEPATH += . +INCLUDEPATH += . ./console INCLUDEPATH += .. LIBS += -L../lib LIBS += -lbac @@ -14,6 +14,6 @@ RESOURCES = main.qrc # Input FORMS += main.ui -HEADERS += mainwin.h bat.h bat_conf.h console.h +HEADERS += mainwin.h bat.h bat_conf.h console/console.h SOURCES += main.cpp authenticate.cpp bat_conf.cpp -SOURCES += mainwin.cpp console.cpp +SOURCES += mainwin.cpp console/console.cpp diff --git a/bacula/src/qt-console/console.cpp b/bacula/src/qt-console/console.cpp deleted file mode 100644 index 46fff3c01e..0000000000 --- a/bacula/src/qt-console/console.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* - Bacula® - The Network Backup Solution - - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. - - The main author of Bacula is Kern Sibbald, with contributions from - many others, a complete list can be found in the file AUTHORS. - This program is Free Software; you can redistribute it and/or - modify it under the terms of version two of the GNU General Public - License as published by the Free Software Foundation plus additions - that are listed in the file LICENSE. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA. - - Bacula® is a registered trademark of John Walker. - The licensor of Bacula is the Free Software Foundation Europe - (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, - Switzerland, email:ftf@fsfeurope.org. -*/ - -/* - * Console Class - * - * Kern Sibbald, January MMVI - * - */ - -#include "bat.h" -#include "console.h" - -Console::Console() -{ - QTreeWidgetItem *item, *topItem; - QTreeWidget *treeWidget = mainWin->treeWidget; - - m_textEdit = mainWin->textEdit; /* our console screen */ - - /* Dummy setup of treeWidget */ - treeWidget->clear(); - treeWidget->setColumnCount(1); - treeWidget->setHeaderLabel("Selection"); - topItem = new QTreeWidgetItem(treeWidget); - topItem->setText(0, "Rufus"); - item = new QTreeWidgetItem(topItem); - item->setText(0, "Console"); - item->setText(1, "0"); - item = new QTreeWidgetItem(topItem); - item->setText(0, "Restore"); - item->setText(1, "1"); - treeWidget->expandItem(topItem); -} - -/* - * Connect to Director. If there are more than one, put up - * a modal dialog so that the user chooses one. - */ -bool Console::connect() -{ - JCR jcr; - - m_textEdit = mainWin->textEdit; /* our console screen */ - - /* Just take the first Director */ - LockRes(); - m_dir = (DIRRES *)GetNextRes(R_DIRECTOR, NULL); - UnlockRes(); - - if (!m_dir) { - return false; - } - - memset(&jcr, 0, sizeof(jcr)); - - set_statusf(_(" Connecting to Director %s:%d"), m_dir->address, m_dir->DIRport); - set_textf(_("Connecting to Director %s:%d\n\n"), m_dir->address, m_dir->DIRport); - - /* Give GUI a chance */ - app->processEvents(); - - LockRes(); - /* If cons==NULL, default console will be used */ - CONRES *cons = (CONRES *)GetNextRes(R_CONSOLE, (RES *)NULL); - UnlockRes(); - - m_sock = bnet_connect(NULL, 5, 15, _("Director daemon"), m_dir->address, - NULL, m_dir->DIRport, 0); - if (m_sock == NULL) { - return false; - } - - jcr.dir_bsock = m_sock; - - if (!authenticate_director(&jcr, m_dir, cons)) { - set_text(m_sock->msg); - return false; - } - - /* Give GUI a chance */ - app->processEvents(); - - set_status(_(" Initializing ...")); - - bnet_fsend(m_sock, "autodisplay on"); - - /* Read and display all initial messages */ - while (bnet_recv(m_sock) > 0) { - set_text(m_sock->msg); - } - - /* Give GUI a chance */ - app->processEvents(); - - /* Query Directory for .jobs, .clients, .filesets, .msgs, - * .pools, .storage, .types, .levels, ... - */ - - set_status(_(" Connected")); - return true; -} - -void Console::set_textf(const char *fmt, ...) -{ - va_list arg_ptr; - char buf[1000]; - int len; - va_start(arg_ptr, fmt); - len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr); - va_end(arg_ptr); - m_textEdit->append(buf); -} - -void Console::set_text(const char *buf) -{ - m_textEdit->append(buf); -} - -void Console::set_statusf(const char *fmt, ...) -{ - va_list arg_ptr; - char buf[1000]; - int len; - va_start(arg_ptr, fmt); - len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr); - va_end(arg_ptr); - set_status(buf); -} - -void Console::set_status_ready() -{ - mainWin->statusBar()->showMessage("Ready"); -// ready = true; -} - -void Console::set_status(const char *buf) -{ - mainWin->statusBar()->showMessage(buf); -// ready = false; -} - - -#ifdef xxx -void write_director(const gchar *msg) -{ - if (UA_sock) { - at_prompt = false; - set_status(_(" Processing command ...")); - UA_sock->msglen = strlen(msg); - pm_strcpy(&UA_sock->msg, msg); - bnet_send(UA_sock); - } - if (strcmp(msg, ".quit") == 0 || strcmp(msg, ".exit") == 0) { - disconnect_from_director((gpointer)NULL); - gtk_main_quit(); - } -} - -extern "C" -void read_director(gpointer data, gint fd, GdkInputCondition condition) -{ - int stat; - - if (!UA_sock || UA_sock->fd != fd) { - return; - } - stat = bnet_recv(UA_sock); - if (stat >= 0) { - if (at_prompt) { - set_text("\n", 1); - at_prompt = false; - } - set_text(UA_sock->msg, UA_sock->msglen); - return; - } - if (is_bnet_stop(UA_sock)) { /* error or term request */ - gtk_main_quit(); - return; - } - /* Must be a signal -- either do something or ignore it */ - if (UA_sock->msglen == BNET_PROMPT) { - at_prompt = true; - set_status(_(" At prompt waiting for input ...")); - } - if (UA_sock->msglen == BNET_EOD) { - set_status_ready(); - } - return; -} - -static gint tag; - -void start_director_reader(gpointer data) -{ - - if (director_reader_running || !UA_sock) { - return; - } - tag = gdk_input_add(UA_sock->fd, GDK_INPUT_READ, read_director, NULL); - director_reader_running = true; -} - -void stop_director_reader(gpointer data) -{ - if (!director_reader_running) { - return; - } - gdk_input_remove(tag); - director_reader_running = false; -} -#endif diff --git a/bacula/src/qt-console/console.h b/bacula/src/qt-console/console.h deleted file mode 100644 index b5b8ba79e3..0000000000 --- a/bacula/src/qt-console/console.h +++ /dev/null @@ -1,32 +0,0 @@ - -#ifndef _CONSOLE_H_ -#define _CONSOLE_H_ - -#include - -class DIRRES; -class BSOCK; -class JCR; -class CONRES; - -class Console : public QWidget -{ - Q_OBJECT -public: - Console(); - bool connect(); - void set_text(const char *buf); - void set_textf(const char *fmt, ...); - void set_statusf(const char *fmt, ...); - void set_status_ready(); - void set_status(const char *buf); - -private: - QTextEdit *m_textEdit; - DIRRES *m_dir; - BSOCK *m_sock; -}; - -extern int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons); - -#endif /* _CONSOLE_H_ */ diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp new file mode 100644 index 0000000000..46fff3c01e --- /dev/null +++ b/bacula/src/qt-console/console/console.cpp @@ -0,0 +1,237 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ + +/* + * Console Class + * + * Kern Sibbald, January MMVI + * + */ + +#include "bat.h" +#include "console.h" + +Console::Console() +{ + QTreeWidgetItem *item, *topItem; + QTreeWidget *treeWidget = mainWin->treeWidget; + + m_textEdit = mainWin->textEdit; /* our console screen */ + + /* Dummy setup of treeWidget */ + treeWidget->clear(); + treeWidget->setColumnCount(1); + treeWidget->setHeaderLabel("Selection"); + topItem = new QTreeWidgetItem(treeWidget); + topItem->setText(0, "Rufus"); + item = new QTreeWidgetItem(topItem); + item->setText(0, "Console"); + item->setText(1, "0"); + item = new QTreeWidgetItem(topItem); + item->setText(0, "Restore"); + item->setText(1, "1"); + treeWidget->expandItem(topItem); +} + +/* + * Connect to Director. If there are more than one, put up + * a modal dialog so that the user chooses one. + */ +bool Console::connect() +{ + JCR jcr; + + m_textEdit = mainWin->textEdit; /* our console screen */ + + /* Just take the first Director */ + LockRes(); + m_dir = (DIRRES *)GetNextRes(R_DIRECTOR, NULL); + UnlockRes(); + + if (!m_dir) { + return false; + } + + memset(&jcr, 0, sizeof(jcr)); + + set_statusf(_(" Connecting to Director %s:%d"), m_dir->address, m_dir->DIRport); + set_textf(_("Connecting to Director %s:%d\n\n"), m_dir->address, m_dir->DIRport); + + /* Give GUI a chance */ + app->processEvents(); + + LockRes(); + /* If cons==NULL, default console will be used */ + CONRES *cons = (CONRES *)GetNextRes(R_CONSOLE, (RES *)NULL); + UnlockRes(); + + m_sock = bnet_connect(NULL, 5, 15, _("Director daemon"), m_dir->address, + NULL, m_dir->DIRport, 0); + if (m_sock == NULL) { + return false; + } + + jcr.dir_bsock = m_sock; + + if (!authenticate_director(&jcr, m_dir, cons)) { + set_text(m_sock->msg); + return false; + } + + /* Give GUI a chance */ + app->processEvents(); + + set_status(_(" Initializing ...")); + + bnet_fsend(m_sock, "autodisplay on"); + + /* Read and display all initial messages */ + while (bnet_recv(m_sock) > 0) { + set_text(m_sock->msg); + } + + /* Give GUI a chance */ + app->processEvents(); + + /* Query Directory for .jobs, .clients, .filesets, .msgs, + * .pools, .storage, .types, .levels, ... + */ + + set_status(_(" Connected")); + return true; +} + +void Console::set_textf(const char *fmt, ...) +{ + va_list arg_ptr; + char buf[1000]; + int len; + va_start(arg_ptr, fmt); + len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr); + va_end(arg_ptr); + m_textEdit->append(buf); +} + +void Console::set_text(const char *buf) +{ + m_textEdit->append(buf); +} + +void Console::set_statusf(const char *fmt, ...) +{ + va_list arg_ptr; + char buf[1000]; + int len; + va_start(arg_ptr, fmt); + len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr); + va_end(arg_ptr); + set_status(buf); +} + +void Console::set_status_ready() +{ + mainWin->statusBar()->showMessage("Ready"); +// ready = true; +} + +void Console::set_status(const char *buf) +{ + mainWin->statusBar()->showMessage(buf); +// ready = false; +} + + +#ifdef xxx +void write_director(const gchar *msg) +{ + if (UA_sock) { + at_prompt = false; + set_status(_(" Processing command ...")); + UA_sock->msglen = strlen(msg); + pm_strcpy(&UA_sock->msg, msg); + bnet_send(UA_sock); + } + if (strcmp(msg, ".quit") == 0 || strcmp(msg, ".exit") == 0) { + disconnect_from_director((gpointer)NULL); + gtk_main_quit(); + } +} + +extern "C" +void read_director(gpointer data, gint fd, GdkInputCondition condition) +{ + int stat; + + if (!UA_sock || UA_sock->fd != fd) { + return; + } + stat = bnet_recv(UA_sock); + if (stat >= 0) { + if (at_prompt) { + set_text("\n", 1); + at_prompt = false; + } + set_text(UA_sock->msg, UA_sock->msglen); + return; + } + if (is_bnet_stop(UA_sock)) { /* error or term request */ + gtk_main_quit(); + return; + } + /* Must be a signal -- either do something or ignore it */ + if (UA_sock->msglen == BNET_PROMPT) { + at_prompt = true; + set_status(_(" At prompt waiting for input ...")); + } + if (UA_sock->msglen == BNET_EOD) { + set_status_ready(); + } + return; +} + +static gint tag; + +void start_director_reader(gpointer data) +{ + + if (director_reader_running || !UA_sock) { + return; + } + tag = gdk_input_add(UA_sock->fd, GDK_INPUT_READ, read_director, NULL); + director_reader_running = true; +} + +void stop_director_reader(gpointer data) +{ + if (!director_reader_running) { + return; + } + gdk_input_remove(tag); + director_reader_running = false; +} +#endif diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h new file mode 100644 index 0000000000..b5b8ba79e3 --- /dev/null +++ b/bacula/src/qt-console/console/console.h @@ -0,0 +1,32 @@ + +#ifndef _CONSOLE_H_ +#define _CONSOLE_H_ + +#include + +class DIRRES; +class BSOCK; +class JCR; +class CONRES; + +class Console : public QWidget +{ + Q_OBJECT +public: + Console(); + bool connect(); + void set_text(const char *buf); + void set_textf(const char *fmt, ...); + void set_statusf(const char *fmt, ...); + void set_status_ready(); + void set_status(const char *buf); + +private: + QTextEdit *m_textEdit; + DIRRES *m_dir; + BSOCK *m_sock; +}; + +extern int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons); + +#endif /* _CONSOLE_H_ */