#############################################################################
# Makefile for building: bat
-# Generated by qmake (2.01a) (Qt 4.2.1) on: Sat Feb 3 13:49:24 2007
+# Generated by qmake (2.01a) (Qt 4.2.1) on: Sun Feb 4 16:56:30 2007
# Project: bat.pro
# Template: app
# Command: /usr/bin/qmake -unix -o Makefile bat.pro
SOURCES = main.cpp \
bat_conf.cpp \
mainwin.cpp \
+ qstd.cpp \
console/authenticate.cpp \
console/console.cpp \
restore/brestore.cpp moc_mainwin.cpp \
OBJECTS = main.o \
bat_conf.o \
mainwin.o \
+ qstd.o \
authenticate.o \
console.o \
brestore.o \
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/console.h restore/restore.h .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.qrc .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.cpp bat_conf.cpp mainwin.cpp console/authenticate.cpp console/console.cpp restore/brestore.cpp .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.ui label.ui console/console.ui restore/brestore.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 qstd.h console/console.h restore/restore.h .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.qrc .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.cpp bat_conf.cpp mainwin.cpp qstd.cpp console/authenticate.cpp console/console.cpp restore/brestore.cpp .tmp/bat1.0.0/ && $(COPY_FILE) --parents main.ui label.ui console/console.ui restore/brestore.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:
main.o: main.cpp bat.h \
mainwin.h \
ui_main.h \
- bat_conf.h
+ bat_conf.h \
+ qstd.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
bat_conf.o: bat_conf.cpp bat_conf.h
mainwin.o: mainwin.cpp bat.h \
mainwin.h \
ui_main.h \
- bat_conf.h
+ bat_conf.h \
+ qstd.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwin.o mainwin.cpp
+qstd.o: qstd.cpp qstd.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o qstd.o qstd.cpp
+
authenticate.o: console/authenticate.cpp bat.h \
mainwin.h \
ui_main.h \
- bat_conf.h
+ bat_conf.h \
+ qstd.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o authenticate.o console/authenticate.cpp
console.o: console/console.cpp bat.h \
mainwin.h \
ui_main.h \
bat_conf.h \
+ qstd.h \
console/console.h \
ui_console.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o console.o console/console.cpp
mainwin.h \
ui_main.h \
bat_conf.h \
+ qstd.h \
restore/restore.h \
ui_brestore.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o brestore.o restore/brestore.cpp
#include "bat_conf.h"
#include "jcr.h"
#include "console.h"
+#include "qstd.h"
+
+using namespace qstd;
extern MainWin *mainWin;
extern QApplication *app;
FORMS += restore/brestore.ui
-HEADERS += mainwin.h bat.h bat_conf.h
-SOURCES += main.cpp bat_conf.cpp mainwin.cpp
+HEADERS += mainwin.h bat.h bat_conf.h qstd.h
+SOURCES += main.cpp bat_conf.cpp mainwin.cpp qstd.cpp
# Console
HEADERS += console/console.h
m_textEdit = textEdit; /* our console screen */
if (!m_dir) {
- mainWin->set_status("No Director found.");
+ mainWin->set_status(" No Director found.");
return;
}
if (m_sock) {
- mainWin->set_status("Already connected.");
+ mainWin->set_status(" Already connected.");
return;
}
mainWin->set_status(_(" Initializing ..."));
- bnet_fsend(m_sock, "autodisplay on");
-
/* Set up input notifier */
m_notifier = new QSocketNotifier(m_sock->fd, QSocketNotifier::Read, 0);
QObject::connect(m_notifier, SIGNAL(activated(int)), this, SLOT(read_dir(int)));
- /* Give GUI a chance */
- app->processEvents();
-
- /* *** FIXME ***
- * Query Directory for .jobs, .clients, .filesets, .msgs,
- * .pools, .storage, .types, .levels, ...
- */
+ job_list = get_list(".jobs");
+ client_list = get_list(".clients");
+ fileset_list = get_list(".filesets");
+ messages_list = get_list(".messages");
+ messages_list = get_list(".pools");
+ messages_list = get_list(".storages");
+ messages_list = get_list(".types");
+ messages_list = get_list(".levels");
mainWin->set_status(_(" Connected"));
return;
}
+/*
+ * Send a command to the director, and read all the resulting
+ * output into a list.
+ */
+QStringList Console::get_list(char *cmd)
+{
+ QStringList list;
+ int stat;
+
+ setEnabled(false);
+ write(cmd);
+ while ((stat = read()) > 0) {
+ strip_trailing_junk(msg());
+ list << msg();
+ }
+ setEnabled(true);
+ return list;
+}
+
+
void Console::writeSettings()
{
QFont font = get_font();
m_textEdit->ensureCursorVisible();
}
+char *Console::msg()
+{
+ if (m_sock) {
+ return m_sock->msg;
+ }
+ return NULL;
+}
/* Send a command to the Director */
void Console::write_dir(const char *msg)
}
}
+int Console::write(const char *msg)
+{
+ m_sock->msglen = strlen(msg);
+ pm_strcpy(&m_sock->msg, msg);
+ return bnet_send(m_sock);
+}
+
+/*
+ * Blocking read from director */
+int Console::read()
+{
+ int stat;
+ if (m_sock) {
+ for (;;) {
+ stat = bnet_wait_data_intr(m_sock, 1);
+ if (stat > 0) {
+ break;
+ }
+ app->processEvents();
+ if (stat < 0) {
+ return BNET_ERROR;
+ }
+ }
+ return bnet_recv(m_sock);
+ }
+ return BNET_HARDEOF;
+}
+
/* Called by signal when the Director has output for us */
void Console::read_dir(int fd)
{
const QFont get_font();
void writeSettings();
void readSettings();
+ char *msg();
+ void setEnabled(bool enable) { m_notifier->setEnabled(enable); };
+ QStringList get_list(char *cmd);
+
+ QStringList job_list;
+ QStringList client_list;
+ QStringList fileset_list;
+ QStringList messages_list;
+ QStringList pool_list;
+ QStringList storage_list;
+ QStringList type_list;
+ QStringList level_list;
public slots:
void connect(void);
void read_dir(int fd);
+ int read(void);
+ int write(const char *msg);
void status_dir(void);
void set_font(void);
mainWin = this;
setupUi(this); /* Setup UI defined by main.ui (designer) */
- statusBar()->showMessage("Director not connected. Click on connect button.");
-
m_console = new Console(stackedWidget);
stackedWidget->setCurrentIndex(0);
createConnections();
- readSettings();
-}
+ this->show();
-#ifdef xxx
- 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");
-
-static GList *get_list(char *cmd)
-{
- GList *options;
- char *msg;
-
- options = NULL;
- write_director(cmd);
- while (bnet_recv(UA_sock) > 0) {
- strip_trailing_junk(UA_sock->msg);
- msg = (char *)malloc(strlen(UA_sock->msg) + 1);
- strcpy(msg, UA_sock->msg);
- options = g_list_append(options, msg);
- }
- return options;
+ readSettings();
+ m_console->connect();
}
-#endif
+
void MainWin::createConnections()
{