#############################################################################
# Makefile for building: bat
-# Generated by qmake (2.01a) (Qt 4.2.1) on: Sun Feb 11 21:47:13 2007
+# Generated by qmake (2.01a) (Qt 4.2.1) on: Wed Feb 21 10:11:16 2007
# Project: bat.pro
# Template: app
# Command: /usr/bin/qmake -unix -o Makefile bat.pro
CXX = g++
LEX = flex
YACC = yacc
-DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
-CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
-CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
+DEFINES = -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
+CFLAGS = -pipe -g -D_REENTRANT -Wall -W $(DEFINES)
+CXXFLAGS = -pipe -g -D_REENTRANT -Wall -W $(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. -Iconsole -Irestore -I.. -Imoc -I.
/usr/share/qt4/mkspecs/features/qt_config.prf \
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
/usr/share/qt4/mkspecs/features/default_pre.prf \
- /usr/share/qt4/mkspecs/features/release.prf \
+ /usr/share/qt4/mkspecs/features/debug.prf \
/usr/share/qt4/mkspecs/features/default_post.prf \
- /usr/share/qt4/mkspecs/features/warn_on.prf \
/usr/share/qt4/mkspecs/features/qt.prf \
/usr/share/qt4/mkspecs/features/unix/thread.prf \
/usr/share/qt4/mkspecs/features/moc.prf \
+ /usr/share/qt4/mkspecs/features/warn_on.prf \
/usr/share/qt4/mkspecs/features/resources.prf \
/usr/share/qt4/mkspecs/features/uic.prf \
bat.pro
/usr/share/qt4/mkspecs/features/qt_config.prf \
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
/usr/share/qt4/mkspecs/features/default_pre.prf \
- /usr/share/qt4/mkspecs/features/release.prf \
+ /usr/share/qt4/mkspecs/features/debug.prf \
/usr/share/qt4/mkspecs/features/default_post.prf \
- /usr/share/qt4/mkspecs/features/warn_on.prf \
/usr/share/qt4/mkspecs/features/qt.prf \
/usr/share/qt4/mkspecs/features/unix/thread.prf \
/usr/share/qt4/mkspecs/features/moc.prf \
+ /usr/share/qt4/mkspecs/features/warn_on.prf \
/usr/share/qt4/mkspecs/features/resources.prf \
/usr/share/qt4/mkspecs/features/uic.prf \
/usr/lib/libQtGui.prl \
/usr/share/qt4/mkspecs/features/qt_config.prf:
/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
/usr/share/qt4/mkspecs/features/default_pre.prf:
-/usr/share/qt4/mkspecs/features/release.prf:
+/usr/share/qt4/mkspecs/features/debug.prf:
/usr/share/qt4/mkspecs/features/default_post.prf:
-/usr/share/qt4/mkspecs/features/warn_on.prf:
/usr/share/qt4/mkspecs/features/qt.prf:
/usr/share/qt4/mkspecs/features/unix/thread.prf:
/usr/share/qt4/mkspecs/features/moc.prf:
+/usr/share/qt4/mkspecs/features/warn_on.prf:
/usr/share/qt4/mkspecs/features/resources.prf:
/usr/share/qt4/mkspecs/features/uic.prf:
/usr/lib/libQtGui.prl:
ui_label.h \
run/run.h \
ui_run.h \
+ restore/restore.h \
+ ui_brestore.h \
+ ui_restore.h \
+ ui_prerestore.h \
mainwin.h \
/usr/bin/moc
/usr/bin/moc $(DEFINES) $(INCPATH) mainwin.h -o moc/moc_mainwin.cpp
ui_label.h \
run/run.h \
ui_run.h \
+ restore/restore.h \
+ ui_brestore.h \
+ ui_restore.h \
+ ui_prerestore.h \
bat_conf.h \
qstd.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/main.o main.cpp
ui_label.h \
run/run.h \
ui_run.h \
+ restore/restore.h \
+ ui_brestore.h \
+ ui_restore.h \
+ ui_prerestore.h \
bat_conf.h \
qstd.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/mainwin.o mainwin.cpp
ui_label.h \
run/run.h \
ui_run.h \
+ restore/restore.h \
+ ui_brestore.h \
+ ui_restore.h \
+ ui_prerestore.h \
bat_conf.h \
qstd.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/authenticate.o console/authenticate.cpp
ui_label.h \
run/run.h \
ui_run.h \
+ restore/restore.h \
+ ui_brestore.h \
+ ui_restore.h \
+ ui_prerestore.h \
bat_conf.h \
qstd.h \
console/console.h \
ui_label.h \
run/run.h \
ui_run.h \
- bat_conf.h \
- qstd.h \
restore/restore.h \
ui_brestore.h \
ui_restore.h \
- ui_prerestore.h
+ ui_prerestore.h \
+ bat_conf.h \
+ qstd.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/restore.o restore/restore.cpp
obj/brestore.o: restore/brestore.cpp bat.h \
ui_label.h \
run/run.h \
ui_run.h \
- bat_conf.h \
- qstd.h \
restore/restore.h \
ui_brestore.h \
ui_restore.h \
- ui_prerestore.h
+ ui_prerestore.h \
+ bat_conf.h \
+ qstd.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/brestore.o restore/brestore.cpp
obj/label.o: label/label.cpp bat.h \
ui_label.h \
run/run.h \
ui_run.h \
+ restore/restore.h \
+ ui_brestore.h \
+ ui_restore.h \
+ ui_prerestore.h \
bat_conf.h \
qstd.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/label.o label/label.cpp
ui_label.h \
run/run.h \
ui_run.h \
+ restore/restore.h \
+ ui_brestore.h \
+ ui_restore.h \
+ ui_prerestore.h \
bat_conf.h \
qstd.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/run.o run/run.cpp
extern MainWin *mainWin;
extern QApplication *app;
-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);
#endif /* _BAT_H_ */
######################################################################
-# Automatically generated by qmake (2.01a) Thu Jan 18 09:40:56 2007
-######################################################################
+
+CONFIG += qt debug
TEMPLATE = app
TARGET = bat
!cram_md5_challenge(dir, password, tls_local_need, compatible)) {
stop_bsock_timer(tid);
printf(_("%s: Director authorization problem.\n"), my_name);
- set_text(_("Director authorization problem.\n"));
- set_text(_(
+ display_text(_("Director authorization problem.\n"));
+ display_text(_(
"Please see http://www.bacula.org/rel-manual/faq.html#AuthorizationErrors for help.\n"));
return false;
}
Dmsg1(6, ">dird: %s", dir->msg);
if (bnet_recv(dir) <= 0) {
stop_bsock_timer(tid);
- set_textf(_("Bad response to Hello command: ERR=%s\n"),
+ display_textf(_("Bad response to Hello command: ERR=%s\n"),
bnet_strerror(dir));
printf(_("%s: Bad response to Hello command: ERR=%s\n"),
my_name, bnet_strerror(dir));
- set_text(_("The Director is probably not running.\n"));
+ display_text(_("The Director is probably not running.\n"));
return false;
}
stop_bsock_timer(tid);
Dmsg1(10, "<dird: %s", dir->msg);
if (strncmp(dir->msg, OKhello, sizeof(OKhello)-1) != 0) {
- set_text(_("Director rejected Hello command\n"));
+ display_text(_("Director rejected Hello command\n"));
return false;
} else {
- set_text(dir->msg);
+ display_text(dir->msg);
}
return true;
}
}
+/* Terminate any open socket */
+void Console::terminate()
+{
+ if (m_sock) {
+ m_sock->close();
+ m_sock = NULL;
+ }
+}
+
/*
* Connect to Director. If there are more than one, put up
* a modal dialog so that the user chooses one.
memset(&jcr, 0, sizeof(jcr));
mainWin->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);
+ display_textf(_("Connecting to Director %s:%d\n\n"), m_dir->address, m_dir->DIRport);
/* Give GUI a chance */
app->processEvents();
jcr.dir_bsock = m_sock;
if (!authenticate_director(&jcr, m_dir, cons)) {
- set_text(m_sock->msg);
+ display_text(m_sock->msg);
return;
}
char *def;
setEnabled(false);
- bsnprintf(cmd, sizeof(cmd), ".defaults job=\"%s\"", job_defs.job_name);
+ bsnprintf(cmd, sizeof(cmd), ".defaults job=\"%s\"", job_defs.job_name.toUtf8().data());
write(cmd);
while ((stat = read()) > 0) {
def = strchr(msg(), '=');
strip_trailing_junk(def);
if (strcmp(msg(), "job") == 0) {
- if (strcmp(def, job_defs.job_name) != 0) {
+ if (strcmp(def, job_defs.job_name.toUtf8().data()) != 0) {
goto bail_out;
}
continue;
}
if (strcmp(msg(), "pool") == 0) {
- bstrncpy(job_defs.pool_name, def, sizeof(job_defs.pool_name));
+ job_defs.pool_name = def;
continue;
}
if (strcmp(msg(), "messages") == 0) {
- bstrncpy(job_defs.messages_name, def, sizeof(job_defs.messages_name));
+ job_defs.messages_name = def;
continue;
}
if (strcmp(msg(), "client") == 0) {
- bstrncpy(job_defs.client_name, def, sizeof(job_defs.client_name));
+ job_defs.client_name = def;
continue;
}
if (strcmp(msg(), "storage") == 0) {
- bstrncpy(job_defs.store_name, def, sizeof(job_defs.store_name));
+ job_defs.store_name = def;
continue;
}
if (strcmp(msg(), "where") == 0) {
- bstrncpy(job_defs.where, def, sizeof(job_defs.where));
+ job_defs.where = def;
continue;
}
if (strcmp(msg(), "level") == 0) {
- bstrncpy(job_defs.level, def, sizeof(job_defs.level));
+ job_defs.level = def;
continue;
}
if (strcmp(msg(), "type") == 0) {
- bstrncpy(job_defs.type, def, sizeof(job_defs.type));
+ job_defs.type = def;
continue;
}
if (strcmp(msg(), "fileset") == 0) {
- bstrncpy(job_defs.fileset_name, def, sizeof(job_defs.fileset_name));
+ job_defs.fileset_name = def;
continue;
}
if (strcmp(msg(), "catalog") == 0) {
- bstrncpy(job_defs.catalog_name, def, sizeof(job_defs.catalog_name));
+ job_defs.catalog_name = def;
continue;
}
if (strcmp(msg(), "enabled") == 0) {
}
bsnprintf(cmd, sizeof(cmd), "job=%s pool=%s client=%s storage=%s where=%s\n"
"level=%s type=%s fileset=%s catalog=%s enabled=%d\n",
- job_defs.job_name, job_defs.pool_name, job_defs.client_name,
- job_defs.pool_name, job_defs.messages_name, job_defs.store_name,
- job_defs.where, job_defs.level, job_defs.type, job_defs.fileset_name,
- job_defs.catalog_name, job_defs.enabled);
+ job_defs.job_name.toUtf8().data(), job_defs.pool_name.toUtf8().data(),
+ job_defs.client_name.toUtf8().data(),
+ job_defs.pool_name.toUtf8().data(), job_defs.messages_name.toUtf8().data(),
+ job_defs.store_name.toUtf8().data(),
+ job_defs.where.toUtf8().data(), job_defs.level.toUtf8().data(),
+ job_defs.type.toUtf8().data(), job_defs.fileset_name.toUtf8().data(),
+ job_defs.catalog_name.toUtf8().data(), job_defs.enabled);
setEnabled(true);
return true;
/*
- * Save user settings
+ * Save user settings associated with this console
*/
void Console::writeSettings()
{
QFont font = get_font();
QSettings settings("bacula.org", "bat");
+ /* ***FIXME*** make console name unique */
settings.beginGroup("Console");
settings.setValue("consoleFont", font.family());
settings.setValue("consolePointSize", font.pointSize());
}
/*
- * Read and restore user settings
+ * Read and restore user settings associated with this console
*/
void Console::readSettings()
{
/*
* Put text into the console window
*/
-void Console::set_textf(const char *fmt, ...)
+void Console::display_textf(const char *fmt, ...)
{
va_list arg_ptr;
char buf[1000];
va_start(arg_ptr, fmt);
len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr);
va_end(arg_ptr);
- set_text(buf);
+ display_text(buf);
}
-void Console::set_text(const QString buf)
+void Console::display_text(const QString buf)
{
m_cursor->movePosition(QTextCursor::End);
m_cursor->insertText(buf);
}
-void Console::set_text(const char *buf)
+void Console::display_text(const char *buf)
{
m_cursor->movePosition(QTextCursor::End);
m_cursor->insertText(buf);
stat = bnet_recv(m_sock);
if (stat >= 0) {
if (m_at_prompt) {
- set_text("\n");
+ display_text("\n");
m_at_prompt = false;
}
- set_text(m_sock->msg);
+ display_text(m_sock->msg);
return;
}
if (is_bnet_stop(m_sock)) { /* error or term request */
- bnet_close(m_sock);
+ m_sock->close();
m_sock = NULL;
mainWin->actionConnect->setIcon(QIcon(QString::fromUtf8("images/disconnected.png")));
QBrush redBrush(Qt::red);
#define MAX_NAME_LENGTH 128
#endif
+/*
+ * Structure for obtaining the defaults for a job
+ */
struct job_defaults {
- char job_name[MAX_NAME_LENGTH];
+ QString job_name;
+ QString pool_name;
+ QString messages_name;
+ QString client_name;
+ QString store_name;
+ QString where;
+ QString level;
+ QString type;
+ QString fileset_name;
+ QString catalog_name;
+#ifdef xxx
char pool_name[MAX_NAME_LENGTH];
char messages_name[MAX_NAME_LENGTH];
char client_name[MAX_NAME_LENGTH];
char type[MAX_NAME_LENGTH];
char fileset_name[MAX_NAME_LENGTH];
char catalog_name[MAX_NAME_LENGTH];
+#endif
bool enabled;
};
public:
Console(QStackedWidget *parent);
- void set_text(const char *buf);
- void set_text(const QString buf);
- void set_textf(const char *fmt, ...);
+ void display_text(const char *buf);
+ void display_text(const QString buf);
+ void display_textf(const char *fmt, ...);
void update_cursor(void);
void write_dir(const char *buf);
bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons);
void setEnabled(bool enable) { m_notifier->setEnabled(enable); };
QStringList get_list(char *cmd);
bool get_job_defaults(struct job_defaults &);
+ void terminate();
QStringList job_list;
QStringList client_list;
*/
void MainWin::closeEvent(QCloseEvent *event)
{
- /* ***FIXME*** close any open sockets */
writeSettings();
m_console->writeSettings();
+ m_console->terminate();
event->accept();
}
QString cmdStr = lineEdit->text(); /* Get the text */
lineEdit->clear(); /* clear the lineEdit box */
if (m_console->is_connected()) {
- m_console->set_text(cmdStr + "\n");
+ m_console->display_text(cmdStr + "\n");
m_console->write_dir(cmdStr.toUtf8().data()); /* send to dir */
} else {
set_status("Director not connected. Click on connect button.");
void MainWin::set_status_ready()
{
- set_status("Ready");
+ set_status(" Ready");
// set_scroll_bar_to_end();
}
runDialog::runDialog(Console *console)
{
QDateTime dt;
+ job_defaults job_defs;
+
m_console = console;
setupUi(this);
jobCombo->addItems(console->job_list);
poolCombo->addItems(console->pool_list);
storageCombo->addItems(console->storage_list);
dateTimeEdit->setDateTime(dt.currentDateTime());
+ job_defs.job_name = jobCombo->currentText();
+ if (console->get_job_defaults(job_defs)) {
+ filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
+ levelCombo->setCurrentIndex(levelCombo->findText(job_defs.level, Qt::MatchExactly));
+ clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
+ poolCombo->setCurrentIndex(poolCombo->findText(job_defs.pool_name, Qt::MatchExactly));
+ storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
+ }
this->show();
}
prioritySpin->value());
// m_console->write(cmd);
- m_console->set_text(cmd);
+ m_console->display_text(cmd);
delete this;
}