#############################################################################
# Makefile for building: bat
-# Generated by qmake (2.01a) (Qt 4.2.1) on: Sat Jan 27 21:58:01 2007
+# Generated by qmake (2.01a) (Qt 4.2.1) on: Sun Jan 28 13:54:36 2007
# Project: bat.pro
# Template: app
# Command: /usr/bin/qmake -unix -o Makefile bat.pro
SOURCES = main.cpp \
authenticate.cpp \
bat_conf.cpp \
- mainwindow.cpp moc_mainwindow.cpp \
+ mainwin.cpp \
+ console.cpp moc_mainwin.cpp \
+ moc_console.cpp \
qrc_main.cpp
OBJECTS = main.o \
authenticate.o \
bat_conf.o \
- mainwindow.o \
- moc_mainwindow.o \
+ mainwin.o \
+ console.o \
+ moc_mainwin.o \
+ moc_console.o \
qrc_main.o
DIST = /usr/share/qt4/mkspecs/common/unix.conf \
/usr/share/qt4/mkspecs/common/g++.conf \
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 mainwindow.h bat.h bat_conf.h .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.qrc .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.cpp authenticate.cpp bat_conf.cpp mainwindow.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.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
yaccclean:
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
-compiler_moc_header_make_all: moc_mainwindow.cpp
+compiler_moc_header_make_all: moc_mainwin.cpp moc_console.cpp
compiler_moc_header_clean:
- -$(DEL_FILE) moc_mainwindow.cpp
-moc_mainwindow.cpp: ui_main.h \
- mainwindow.h \
+ -$(DEL_FILE) moc_mainwin.cpp moc_console.cpp
+moc_mainwin.cpp: ui_main.h \
+ mainwin.h \
/usr/bin/moc
- /usr/bin/moc $(DEFINES) $(INCPATH) mainwindow.h -o moc_mainwindow.cpp
+ /usr/bin/moc $(DEFINES) $(INCPATH) mainwin.h -o moc_mainwin.cpp
+
+moc_console.cpp: console.h \
+ /usr/bin/moc
+ /usr/bin/moc $(DEFINES) $(INCPATH) console.h -o moc_console.cpp
compiler_rcc_make_all: qrc_main.cpp
compiler_rcc_clean:
####### Compile
main.o: main.cpp bat.h \
- mainwindow.h \
+ mainwin.h \
ui_main.h \
- bat_conf.h
+ bat_conf.h \
+ console.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
authenticate.o: authenticate.cpp bat.h \
- mainwindow.h \
+ mainwin.h \
ui_main.h \
- bat_conf.h
+ bat_conf.h \
+ console.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o authenticate.o authenticate.cpp
bat_conf.o: bat_conf.cpp bat_conf.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o bat_conf.o bat_conf.cpp
-mainwindow.o: mainwindow.cpp bat.h \
- mainwindow.h \
+mainwin.o: mainwin.cpp bat.h \
+ mainwin.h \
ui_main.h \
- bat_conf.h
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o mainwindow.cpp
+ bat_conf.h \
+ console.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwin.o mainwin.cpp
+
+console.o: console.cpp bat.h \
+ mainwin.h \
+ ui_main.h \
+ bat_conf.h \
+ console.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o console.o console.cpp
+
+moc_mainwin.o: moc_mainwin.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_mainwin.o moc_mainwin.cpp
-moc_mainwindow.o: moc_mainwindow.cpp
- $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_mainwindow.o moc_mainwindow.cpp
+moc_console.o: moc_console.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_console.o moc_console.cpp
qrc_main.o: qrc_main.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o qrc_main.o qrc_main.cpp
#ifndef _BAT_H_
+#define _BAT_H_
-#include "mainwindow.h"
+#include "mainwin.h"
#include "config.h"
#include "bacula.h"
#include "bat_conf.h"
#include "jcr.h"
+#include "console.h"
-extern MainWindow *mainWin;
+extern MainWin *mainWin;
extern QApplication *app;
-extern BSOCK *UA_sock;
-
void set_textf(const char *fmt, ...);
void set_text(const char *buf);
# Input
FORMS += main.ui
-HEADERS += mainwindow.h bat.h bat_conf.h
+HEADERS += mainwin.h bat.h bat_conf.h console.h
SOURCES += main.cpp authenticate.cpp bat_conf.cpp
-SOURCES += mainwindow.cpp
+SOURCES += mainwin.cpp console.cpp
*/
/*
- * Connect to a Bacula daemon
+ * 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(QWidget *textEdit)
+bool Console::connect()
{
JCR jcr;
- m_textEdit = textEdit;
+ m_textEdit = mainWin->textEdit; /* our console screen */
-#ifdef xxx
- if (ndir > 1) {
- LockRes();
- foreach_res(dir, R_DIRECTOR) {
- dirs = g_list_append(dirs, dir->hdr.name);
- }
- UnlockRes();
- dir_dialog = create_SelectDirectorDialog();
- combo = lookup_widget(dir_dialog, "combo1");
- dir_select = lookup_widget(dir_dialog, "dirselect");
- if (dirs) {
- gtk_combo_set_popdown_strings(GTK_COMBO(combo), dirs);
- }
- gtk_widget_show(dir_dialog);
- gtk_main();
-
- if (reply == OK) {
- gchar *ecmd = gtk_editable_get_chars((GtkEditable *)dir_select, 0, -1);
- dir = (DIRRES *)GetResWithName(R_DIRECTOR, ecmd);
- if (ecmd) {
- g_free(ecmd); /* release director name string */
- }
- }
- if (dirs) {
- g_free(dirs);
- }
- gtk_widget_destroy(dir_dialog);
- dir_dialog = NULL;
- } else {
-#endif
- /* Just take the first Director */
- LockRes();
- m_dir = (DIRRES *)GetNextRes(R_DIRECTOR, NULL);
- UnlockRes();
+ /* 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,dir->DIRport);
- set_textf(_("Connecting to Director %s:%d\n\n"), m_dir->address,dir->DIRport);
+ 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();
-#ifdef xxx
- char buf[1024];
- /* Initialize Console TLS context */
- if (cons && (cons->tls_enable || cons->tls_require)) {
- /* Generate passphrase prompt */
- bsnprintf(buf, sizeof(buf), _("Passphrase for Console \"%s\" TLS private key: "), cons->hdr.name);
-
- /* Initialize TLS context:
- * Args: CA certfile, CA certdir, Certfile, Keyfile,
- * Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer */
- cons->tls_ctx = new_tls_context(cons->tls_ca_certfile,
- cons->tls_ca_certdir, cons->tls_certfile,
- cons->tls_keyfile, tls_pem_callback, &buf, NULL, true);
-
- if (!cons->tls_ctx) {
- bsnprintf(buf, sizeof(buf), _("Failed to initialize TLS context for Console \"%s\".\n"),
- dir->hdr.name);
- set_text(buf, strlen(buf));
- terminate_console(0);
- return true;
- }
-
- }
-
- /* Initialize Director TLS context */
- if (dir->tls_enable || dir->tls_require) {
- /* Generate passphrase prompt */
- bsnprintf(buf, sizeof(buf), _("Passphrase for Director \"%s\" TLS private key: "), dir->hdr.name);
-
- /* Initialize TLS context:
- * Args: CA certfile, CA certdir, Certfile, Keyfile,
- * Keyfile PEM Callback, Keyfile CB Userdata, DHfile, Verify Peer */
- dir->tls_ctx = new_tls_context(dir->tls_ca_certfile,
- dir->tls_ca_certdir, dir->tls_certfile,
- dir->tls_keyfile, tls_pem_callback, &buf, NULL, true);
-
- if (!dir->tls_ctx) {
- bsnprintf(buf, sizeof(buf), _("Failed to initialize TLS context for Director \"%s\".\n"),
- dir->hdr.name);
- set_text(buf, strlen(buf));
- terminate_console(0);
- return true;
- }
- }
-#endif
-
m_sock = bnet_connect(NULL, 5, 15, _("Director daemon"), m_dir->address,
NULL, m_dir->DIRport, 0);
- if (m__sock == NULL) {
+ 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(UA_sock->msg);
+ set_text(m_sock->msg);
}
/* Give GUI a chance */
app->processEvents();
-#ifdef xxx
- /* Fill the run_dialog combo boxes */
- job_list = get_and_fill_combo(run_dialog, "combo_job", ".jobs");
- client_list = get_and_fill_combo(run_dialog, "combo_client", ".clients");
- fileset_list = get_and_fill_combo(run_dialog, "combo_fileset", ".filesets");
- messages_list = get_and_fill_combo(run_dialog, "combo_messages", ".msgs");
- pool_list = get_and_fill_combo(run_dialog, "combo_pool", ".pools");
- storage_list = get_and_fill_combo(run_dialog, "combo_storage", ".storage");
- type_list = get_and_fill_combo(run_dialog, "combo_type", ".types");
- level_list = get_and_fill_combo(run_dialog, "combo_level", ".levels");
-
- /* Fill the label dialog combo boxes */
- fill_combo(label_dialog, "label_combo_storage", storage_list);
- fill_combo(label_dialog, "label_combo_pool", pool_list);
-
-
- /* Fill the restore_dialog combo boxes */
- fill_combo(restore_dialog, "combo_restore_job", job_list);
- fill_combo(restore_dialog, "combo_restore_client", client_list);
- fill_combo(restore_dialog, "combo_restore_fileset", fileset_list);
- fill_combo(restore_dialog, "combo_restore_pool", pool_list);
- fill_combo(restore_dialog, "combo_restore_storage", storage_list);
-#endif
+ /* 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)
{
#ifndef _CONSOLE_H_
#define _CONSOLE_H_
-#include "mainwindow.h"
-#include "config.h"
-#include "bacula.h"
-#include "console_conf.h"
-#include "jcr.h"
+#include <QtGui>
-extern MainWindow *mainWin;
-extern QApplication *app;
+class DIRRES;
+class BSOCK;
+class JCR;
+class CONRES;
-class Console(QWidget *textEdit)
+class Console : public QWidget
{
+ Q_OBJECT
public:
Console();
bool connect();
-// void setDirector()
-// void write();
-// void read();
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:
- QWidget *m_textEdit;
+ QTextEdit *m_textEdit;
DIRRES *m_dir;
BSOCK *m_sock;
};
-
-
-void set_textf(const char *fmt, ...);
-void set_text(const char *buf);
-
-int bvsnprintf(char *str, int32_t size, const char *format, va_list ap);
+extern int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons);
#endif /* _CONSOLE_H_ */
/* Static variables */
static char *configfile = NULL;
-MainWindow *mainWin;
+MainWin *mainWin;
QApplication *app;
BSOCK *UA_sock = NULL;
app = new QApplication(argc, argv);
app->setQuitOnLastWindowClosed(true);
- mainWin = new MainWindow;
-
- mainWin->show();
#ifdef ENABLE_NLS
setlocale(LC_ALL, "");
Emsg1(M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile);
}
+ mainWin = new MainWin;
+ mainWin->show();
+
return app->exec();
}
exit(1);
}
+#ifdef xxx
/*
* Call-back for reading a passphrase for an encrypted PEM file
* This function uses getpass(), which uses a static buffer and is NOT thread-safe.
return 0;
#endif
}
+#endif
/*
--- /dev/null
+/*
+ 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.
+*/
+
+/*
+ * Main Window control for bat (qt-console)
+ *
+ * Kern Sibbald, January MMVI
+ *
+ */
+
+#include "bat.h"
+
+MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
+{
+ mainWin = this;
+ setupUi(this); /* Setup UI defined by main.ui (designer) */
+ stackedWidget->setCurrentIndex(0);
+ /* 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(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line()));
+ connect(actionAbout_qt_console, SIGNAL(triggered()), this, SLOT(about()));
+
+ connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem *, int)), this,
+ SLOT(treeItemClicked(QTreeWidgetItem *, int)));
+ connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this,
+ SLOT(treeItemClicked(QTreeWidgetItem *, int)));
+ connect(treeWidget, SIGNAL(itemPressed(QTreeWidgetItem *, int)), this,
+ SLOT(treeItemClicked(QTreeWidgetItem *, int)));
+
+ m_console = new Console();
+
+}
+
+void MainWin::treeItemClicked(QTreeWidgetItem *item, int column)
+{
+ (void)column;
+ int index = item->text(1).toInt();
+ if (index >= 0 && index < 2) {
+ stackedWidget->setCurrentIndex(index);
+ }
+}
+
+
+/*
+ * The user just finished typing a line in the command line edit box
+ */
+void MainWin::input_line()
+{
+ QString cmdStr = lineEdit->text(); /* Get the text */
+ lineEdit->clear(); /* clear the lineEdit box */
+ textEdit->append(cmdStr); /* append text on screen */
+}
+void MainWin::about()
+{
+ QMessageBox::about(this, tr("About bat"),
+ tr("<h2>bat 0.1</h2>"
+ "<p>Copyright © " BYEAR " Free Software Foundation Europe e.V."
+ "<p>The <b>bat</b> is an administrative console"
+ " interface to the Director."));
+}
+
+void 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);
+ mainWin->textEdit->append(buf);
+}
+
+void set_text(const char *buf)
+{
+ mainWin->textEdit->append(buf);
+}
+
+void 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);
+// gtk_label_set_text(GTK_LABEL(status1), buf);
+// set_scroll_bar_to_end();
+// ready = false;
+}
+
+void set_status_ready()
+{
+ mainWin->statusBar()->showMessage("Ready");
+// ready = true;
+// set_scroll_bar_to_end();
+}
+
+void set_status(const char *buf)
+{
+ mainWin->statusBar()->showMessage(buf);
+// ready = false;
+}
--- /dev/null
+/*
+ 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.
+*/
+
+/*
+ * qt-console main window class definition.
+ *
+ * Written by Kern Sibbald, January MMVI
+ */
+
+#ifndef _MAINWIN_H_
+#define _MAINWIN_H_
+
+#include <QtGui>
+#include "ui_main.h"
+
+class Console;
+
+class MainWin : public QMainWindow, public Ui::MainForm
+{
+ Q_OBJECT
+
+public:
+ MainWin(QWidget *parent = 0);
+
+public slots:
+ void input_line();
+ void about();
+ void treeItemClicked(QTreeWidgetItem *item, int column);
+
+private:
+ QString m_UserInput;
+ Console *m_console;
+};
+
+#endif /* _MAINWIN_H_ */
+++ /dev/null
-/*
- 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.
-*/
-
-/*
- * Main Window control for bat (qt-console)
- *
- * Kern Sibbald, January MMVI
- *
- */
-
-#include "bat.h"
-
-MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
-{
- QTreeWidgetItem *item, *topItem;
- setupUi(this); /* Setup UI defined by main.ui (designer) */
- stackedWidget->setCurrentIndex(0);
- /* 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(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line()));
- connect(actionAbout_qt_console, SIGNAL(triggered()), this, SLOT(about()));
-
- connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem *, int)), this,
- SLOT(treeItemClicked(QTreeWidgetItem *, int)));
- connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this,
- SLOT(treeItemClicked(QTreeWidgetItem *, int)));
- connect(treeWidget, SIGNAL(itemPressed(QTreeWidgetItem *, int)), this,
- SLOT(treeItemClicked(QTreeWidgetItem *, int)));
-
-
- /* 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);
-}
-
-void MainWindow::treeItemClicked(QTreeWidgetItem *item, int column)
-{
- (void)column;
- int index = item->text(1).toInt();
- if (index >= 0 && index < 2) {
- stackedWidget->setCurrentIndex(index);
- }
-}
-
-
-/*
- * The user just finished typing a line in the command line edit box
- */
-void MainWindow::input_line()
-{
- QString cmdStr = lineEdit->text(); /* Get the text */
- lineEdit->clear(); /* clear the lineEdit box */
- textEdit->append(cmdStr); /* append text on screen */
-}
-void MainWindow::about()
-{
- QMessageBox::about(this, tr("About bat"),
- tr("<h2>bat 0.1</h2>"
- "<p>Copyright © " BYEAR " Free Software Foundation Europe e.V."
- "<p>The <b>bat</b> is an administrative console"
- " interface to the Director."));
-}
-
-void 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);
- mainWin->textEdit->append(buf);
-}
-
-void set_text(const char *buf)
-{
- mainWin->textEdit->append(buf);
-}
-
-void 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);
-// gtk_label_set_text(GTK_LABEL(status1), buf);
-// set_scroll_bar_to_end();
-// ready = false;
-}
-
-void set_status_ready()
-{
- mainWin->statusBar()->showMessage("Ready");
-// ready = true;
-// set_scroll_bar_to_end();
-}
-
-void set_status(const char *buf)
-{
- mainWin->statusBar()->showMessage(buf);
-// ready = false;
-}
+++ /dev/null
-/*
- 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.
-*/
-
-/*
- * qt-console main window class definition.
- *
- * Written by Kern Sibbald, January MMVI
- */
-
-#ifndef _MAINWINDOW_H_
-#define _MAINWINDOW_H_
-
-#include <QtGui>
-#include "ui_main.h"
-
-class MainWindow : public QMainWindow, public Ui::MainForm
-{
- Q_OBJECT
-
-public:
- MainWindow(QWidget *parent = 0);
-
-public slots:
- void input_line();
- void about();
- void treeItemClicked(QTreeWidgetItem *item, int column);
-
-private:
- QString m_UserInput;
-};
-
-#endif /* _MAINWINDOW_H_ */