From 92f204bec1941613b3e9253103b6a699065c0042 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 28 Jan 2007 18:25:10 +0000 Subject: [PATCH] Bat now connecting to Bacula git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4069 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/console/console.cpp | 23 ++++--- bacula/src/qt-console/console/console.h | 4 +- bacula/src/qt-console/main.cpp | 1 - bacula/src/qt-console/main.ui | 73 ++++++++++++++++++----- bacula/src/qt-console/mainwin.cpp | 13 ++-- 5 files changed, 86 insertions(+), 28 deletions(-) diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index eeff11fc95..3127c9c8d1 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -41,6 +41,7 @@ Console::Console() QTreeWidgetItem *item, *topItem; QTreeWidget *treeWidget = mainWin->treeWidget; + m_sock = NULL; m_textEdit = mainWin->textEdit; /* our console screen */ /* Just take the first Director */ @@ -67,15 +68,19 @@ Console::Console() * Connect to Director. If there are more than one, put up * a modal dialog so that the user chooses one. */ -bool Console::connect() +void Console::connect() { JCR jcr; m_textEdit = mainWin->textEdit; /* our console screen */ - - if (!m_dir) { - return false; + if (!m_dir) { + set_text("No Director to connect to.\n"); + return; + } + if (m_sock) { + set_text("Already connected.\n"); + return; } memset(&jcr, 0, sizeof(jcr)); @@ -94,14 +99,15 @@ bool Console::connect() m_sock = bnet_connect(NULL, 5, 15, _("Director daemon"), m_dir->address, NULL, m_dir->DIRport, 0); if (m_sock == NULL) { - return false; + set_text("Connection failed\n"); + return; } jcr.dir_bsock = m_sock; if (!authenticate_director(&jcr, m_dir, cons)) { set_text(m_sock->msg); - return false; + return; } /* Give GUI a chance */ @@ -124,7 +130,9 @@ bool Console::connect() */ set_status(_(" Connected")); - return true; + set_text("Connected\n"); + + return; } void Console::set_textf(const char *fmt, ...) @@ -163,6 +171,7 @@ void Console::set_status_ready() void Console::set_status(const char *buf) { mainWin->statusBar()->showMessage(buf); + set_text(buf); // ready = false; } diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index b5b8ba79e3..138f7e5537 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -14,13 +14,15 @@ 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); +public slots: + void connect(); + private: QTextEdit *m_textEdit; DIRRES *m_dir; diff --git a/bacula/src/qt-console/main.cpp b/bacula/src/qt-console/main.cpp index 0c802c7378..502d303cbf 100644 --- a/bacula/src/qt-console/main.cpp +++ b/bacula/src/qt-console/main.cpp @@ -53,7 +53,6 @@ static char *configfile = NULL; MainWin *mainWin; QApplication *app; -BSOCK *UA_sock = NULL; int main(int argc, char *argv[]) diff --git a/bacula/src/qt-console/main.ui b/bacula/src/qt-console/main.ui index a071dfc00b..6451ea78e8 100644 --- a/bacula/src/qt-console/main.ui +++ b/bacula/src/qt-console/main.ui @@ -218,13 +218,13 @@ - Help + &Help - + - Edit + &Edit @@ -232,17 +232,24 @@ - File + &File - + - + + + Current Status + + + Current Status + + @@ -250,6 +257,9 @@ 39 + + Tool Bar + Qt::Horizontal @@ -261,15 +271,22 @@ + - + - Quit + &Quit + + + Ctrl+Q + + + QAction::QuitRole - + - About bat + &About bat @@ -277,7 +294,7 @@ images/copy.png - Copy + &Copy @@ -285,7 +302,7 @@ images/cut.png - Cut + Cu&t @@ -309,7 +326,7 @@ images/paste.png - Paste + &Paste @@ -317,7 +334,7 @@ images/print.png - Print + &Print @@ -325,7 +342,7 @@ images/save.png - Save + &Save @@ -343,6 +360,12 @@ Label + + Label a Volume + + + Label a Volume + @@ -351,6 +374,26 @@ Restore + + Restore Files + + + + + false + + + images/run.png + + + Run Job + + + Run Job + + + Run Job + diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 4d50408b2f..b995aea71c 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -40,12 +40,17 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) mainWin = this; setupUi(this); /* Setup UI defined by main.ui (designer) */ stackedWidget->setCurrentIndex(0); + + m_console = new Console(); + /* Dummy message ***FIXME*** remove a bit later */ textEdit->setPlainText("Hello Baculites\nThis is the main console window."); lineEdit->setFocus(); - /* Connect command line edit to input_line */ + + + /* Connect signals to slots */ connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line())); - connect(actionAbout_qt_console, SIGNAL(triggered()), this, SLOT(about())); + connect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about())); connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int))); @@ -53,8 +58,8 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) SLOT(treeItemClicked(QTreeWidgetItem *, int))); connect(treeWidget, SIGNAL(itemPressed(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int))); - - m_console = new Console(); + connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows())); + connect(actionConnect, SIGNAL(triggered()), m_console, SLOT(connect())); } -- 2.39.5