From: Kern Sibbald Date: Mon, 5 Mar 2007 09:46:43 +0000 (+0000) Subject: Get new api working + mark/unmark restore files X-Git-Tag: Release-7.0.0~6790 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1ee06c7b2ff420133f3f8641f14c5d3fbaa692d8;p=bacula%2Fbacula Get new api working + mark/unmark restore files git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4310 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/Makefile b/bacula/src/qt-console/Makefile index 4d2e501917..9e2396bf24 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: Tue Feb 27 17:51:23 2007 +# Generated by qmake (2.01a) (Qt 4.2.1) on: Mon Mar 5 09:37:46 2007 # Project: bat.pro # Template: app # Command: /usr/bin/qmake -unix -o Makefile bat.pro @@ -51,6 +51,7 @@ SOURCES = main.cpp \ qstd.cpp \ console/authenticate.cpp \ console/console.cpp \ + restore/prerestore.cpp \ restore/restore.cpp \ restore/brestore.cpp \ label/label.cpp \ @@ -66,6 +67,7 @@ OBJECTS = obj/main.o \ obj/qstd.o \ obj/authenticate.o \ obj/console.o \ + obj/prerestore.o \ obj/restore.o \ obj/brestore.o \ obj/label.o \ @@ -166,7 +168,7 @@ qmake: FORCE dist: @$(CHK_DIR_EXISTS) obj/bat1.0.0 || $(MKDIR) obj/bat1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/bat1.0.0/ && $(COPY_FILE) --parents mainwin.h bat.h bat_conf.h qstd.h console/console.h restore/restore.h label/label.h run/run.h obj/bat1.0.0/ && $(COPY_FILE) --parents main.qrc obj/bat1.0.0/ && $(COPY_FILE) --parents main.cpp bat_conf.cpp mainwin.cpp qstd.cpp console/authenticate.cpp console/console.cpp restore/restore.cpp restore/brestore.cpp label/label.cpp run/run.cpp obj/bat1.0.0/ && $(COPY_FILE) --parents main.ui label/label.ui console/console.ui restore/restore.ui restore/prerestore.ui restore/brestore.ui run/run.ui obj/bat1.0.0/ && (cd `dirname obj/bat1.0.0` && $(TAR) bat1.0.0.tar bat1.0.0 && $(COMPRESS) bat1.0.0.tar) && $(MOVE) `dirname obj/bat1.0.0`/bat1.0.0.tar.gz . && $(DEL_FILE) -r obj/bat1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/bat1.0.0/ && $(COPY_FILE) --parents mainwin.h bat.h bat_conf.h qstd.h console/console.h restore/restore.h label/label.h run/run.h obj/bat1.0.0/ && $(COPY_FILE) --parents main.qrc obj/bat1.0.0/ && $(COPY_FILE) --parents main.cpp bat_conf.cpp mainwin.cpp qstd.cpp console/authenticate.cpp console/console.cpp restore/prerestore.cpp restore/restore.cpp restore/brestore.cpp label/label.cpp run/run.cpp obj/bat1.0.0/ && $(COPY_FILE) --parents main.ui label/label.ui console/console.ui restore/restore.ui restore/prerestore.ui restore/brestore.ui run/run.ui obj/bat1.0.0/ && (cd `dirname obj/bat1.0.0` && $(TAR) bat1.0.0.tar bat1.0.0 && $(COMPRESS) bat1.0.0.tar) && $(MOVE) `dirname obj/bat1.0.0`/bat1.0.0.tar.gz . && $(DEL_FILE) -r obj/bat1.0.0 yaccclean: @@ -350,6 +352,21 @@ obj/console.o: console/console.cpp bat.h \ ui_console.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/console.o console/console.cpp +obj/prerestore.o: restore/prerestore.cpp bat.h \ + mainwin.h \ + ui_main.h \ + label/label.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/prerestore.o restore/prerestore.cpp + obj/restore.o: restore/restore.cpp bat.h \ mainwin.h \ ui_main.h \ diff --git a/bacula/src/qt-console/bat.h b/bacula/src/qt-console/bat.h index 1138677199..173119f30f 100644 --- a/bacula/src/qt-console/bat.h +++ b/bacula/src/qt-console/bat.h @@ -4,7 +4,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2007-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. @@ -46,6 +46,7 @@ using namespace qstd; extern MainWin *mainWin; extern QApplication *app; +extern bool commDebug; int bvsnprintf(char *str, int32_t size, const char *format, va_list ap); diff --git a/bacula/src/qt-console/bat.pro b/bacula/src/qt-console/bat.pro index 53f2cb9b65..40d4eb1916 100644 --- a/bacula/src/qt-console/bat.pro +++ b/bacula/src/qt-console/bat.pro @@ -32,7 +32,7 @@ SOURCES += console/authenticate.cpp console/console.cpp # Restore HEADERS += restore/restore.h -SOURCES += restore/restore.cpp restore/brestore.cpp +SOURCES += restore/prerestore.cpp restore/restore.cpp restore/brestore.cpp # Label dialog HEADERS += label/label.h diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 60a230a57d..a46dfff47a 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -153,6 +153,9 @@ void Console::connect() m_notifier = new QSocketNotifier(m_sock->fd, QSocketNotifier::Read, 0); QObject::connect(m_notifier, SIGNAL(activated(int)), this, SLOT(read_dir(int))); + write(".api"); + discardToPrompt(); + beginNewCommand(); job_list = get_list(".jobs"); client_list = get_list(".clients"); @@ -184,7 +187,7 @@ QStringList Console::get_list(char *cmd) list << msg(); } setEnabled(true); - list.sort(); +// list.sort(); return list; } @@ -386,12 +389,9 @@ char *Console::msg() void Console::write_dir(const char *msg) { if (m_sock) { - m_at_prompt = false; mainWin->set_status(_("Processing command ...")); QApplication::setOverrideCursor(Qt::WaitCursor); - m_sock->msglen = strlen(msg); - pm_strcpy(&m_sock->msg, msg); - m_sock->send(); + write(msg); } else { mainWin->set_status(" Director not connected. Click on connect button."); mainWin->actionConnect->setIcon(QIcon(QString::fromUtf8("images/disconnected.png"))); @@ -409,6 +409,8 @@ int Console::write(const char *msg) { m_sock->msglen = strlen(msg); pm_strcpy(&m_sock->msg, msg); + m_at_prompt = false; + if (commDebug) Pmsg1(000, "send: %s\n", msg); return m_sock->send(); } @@ -417,7 +419,6 @@ int Console::write(const char *msg) */ void Console::beginNewCommand() { -// displayToPrompt(); write(".\n"); while (read() > 0) { } @@ -432,31 +433,95 @@ void Console::beginNewCommand() void Console::displayToPrompt() { - while (read() > 0) { + int stat; + if (commDebug) Pmsg0(000, "DisplaytoPrompt\n"); + m_notifier->setEnabled(false); + while ((stat = read()) > 0) { display_text(msg()); } + if (commDebug) Pmsg1(000, "endDisplaytoPrompt=%d\n", stat); + m_notifier->setEnabled(true); +} +void Console::discardToPrompt() +{ + int stat; + if (commDebug) Pmsg0(000, "discardToPrompt\n"); + m_notifier->setEnabled(false); + while ((stat = read()) > 0) { + } + if (commDebug) Pmsg1(000, "endDisplayToPrompt=%d\n", stat); + m_notifier->setEnabled(true); } + /* - * Blocking read from director */ + * Blocking read from director + */ int Console::read() { - int stat; - if (m_sock) { + int stat = BNET_HARDEOF; + while (m_sock) { for (;;) { stat = bnet_wait_data_intr(m_sock, 1); if (stat > 0) { break; } app->processEvents(); - if (stat < 0) { - return BNET_ERROR; + } + stat = m_sock->recv(); + if (stat >= 0) { + if (m_at_prompt) { + display_text("\n"); + m_at_prompt = false; + } + if (commDebug) Pmsg1(000, "got: %s", m_sock->msg); + + } + switch (m_sock->msglen) { + case BNET_CMD_BEGIN: + m_at_prompt = false; + continue; + case BNET_PROMPT: + case BNET_CMD_OK: + if (commDebug) Pmsg0(000, "CMD OK/PROMPT\n"); + m_at_prompt = true; + mainWin->set_status(_("At prompt waiting for input ...")); + update_cursor(); + QApplication::restoreOverrideCursor(); + break; + case BNET_CMD_FAILED: + if (commDebug) Pmsg0(000, "CMD FAIL\n"); + m_at_prompt = true; + mainWin->set_status(_("Command failed. At prompt waiting for input ...")); + update_cursor(); + QApplication::restoreOverrideCursor(); + break; + case BNET_EOD: + if (commDebug) Pmsg0(000, "EOD\n"); + mainWin->set_status_ready(); + update_cursor(); + QApplication::restoreOverrideCursor(); + if (!m_api_set) { + break; } + continue; } - return m_sock->recv(); + if (is_bnet_stop(m_sock)) { /* error or term request */ + m_sock->close(); + m_sock = NULL; + mainWin->actionConnect->setIcon(QIcon(QString::fromUtf8("images/disconnected.png"))); + QBrush redBrush(Qt::red); + m_consoleItem->setForeground(0, redBrush); + m_notifier->setEnabled(false); + delete m_notifier; + m_notifier = NULL; + mainWin->set_status(_("Director disconnected.")); + QApplication::restoreOverrideCursor(); + } + break; } - return BNET_HARDEOF; + return stat; } /* Called by signal when the Director has output for us */ @@ -465,40 +530,9 @@ void Console::read_dir(int fd) int stat; (void)fd; - if (!m_sock) { - return; - } + if (commDebug) Pmsg0(000, "read_dir\n"); stat = read(); if (stat >= 0) { - if (m_at_prompt) { - display_text("\n"); - m_at_prompt = false; - } display_text(msg()); - return; } - if (is_bnet_stop(m_sock)) { /* error or term request */ - m_sock->close(); - m_sock = NULL; - mainWin->actionConnect->setIcon(QIcon(QString::fromUtf8("images/disconnected.png"))); - QBrush redBrush(Qt::red); - m_consoleItem->setForeground(0, redBrush); - m_notifier->setEnabled(false); - delete m_notifier; - m_notifier = NULL; - mainWin->set_status(_("Director disconnected.")); - QApplication::restoreOverrideCursor(); - return; - } - /* Must be a signal -- either do something or ignore it */ - if (m_sock->msglen == BNET_PROMPT) { - m_at_prompt = true; - mainWin->set_status(_("At prompt waiting for input ...")); - update_cursor(); - } - if (m_sock->msglen == BNET_EOD) { - mainWin->set_status_ready(); - update_cursor(); - } - return; } diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index 2c66a2b68a..f9f1c88eb6 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -87,6 +87,7 @@ public: void terminate(); void beginNewCommand(); void displayToPrompt(); + void discardToPrompt(); QStringList job_list; QStringList client_list; @@ -114,6 +115,7 @@ private: QSocketNotifier *m_notifier; QTextCursor *m_cursor; QTreeWidgetItem *m_consoleItem; + bool m_api_set; }; #endif /* _CONSOLE_H_ */ diff --git a/bacula/src/qt-console/main.cpp b/bacula/src/qt-console/main.cpp index a2260c97fd..2777c43fa4 100644 --- a/bacula/src/qt-console/main.cpp +++ b/bacula/src/qt-console/main.cpp @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2007 Free Software Foundation Europe e.V. + Copyright (C) 2007-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. @@ -30,7 +30,7 @@ * * Main program for bat (qt-console) * - * Kern Sibbald, January MMVI + * Kern Sibbald, January MMVII * */ @@ -51,6 +51,7 @@ static char *configfile = NULL; MainWin *mainWin; QApplication *app; +bool commDebug = false; int main(int argc, char *argv[]) diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 6ddd36d201..767ae66cfc 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -31,7 +31,7 @@ * * Main Window control for bat (qt-console) * - * Kern Sibbald, January MMVI + * Kern Sibbald, January MMVII * */ @@ -45,7 +45,7 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) m_console = new Console(stackedWidget); stackedWidget->setCurrentIndex(0); - lineEdit->setFocus(); + resetFocus(); createConnections(); @@ -56,6 +56,11 @@ MainWin::MainWin(QWidget *parent) : QMainWindow(parent) m_console->connect(); } +void MainWin::resetFocus() +{ + lineEdit->setFocus(); +} + void MainWin::createConnections() { diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index f1936f7ef8..9ec3240801 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2007 Free Software Foundation Europe e.V. + Copyright (C) 2007-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. @@ -31,7 +31,7 @@ * * qt-console main window class definition. * - * Written by Kern Sibbald, January MMVI + * Written by Kern Sibbald, January MMVII */ #ifndef _MAINWIN_H_ @@ -56,6 +56,7 @@ public: void set_status(const char *buf); void writeSettings(); void readSettings(); + void resetFocus(); public slots: void input_line(); diff --git a/bacula/src/qt-console/restore/prerestore.cpp b/bacula/src/qt-console/restore/prerestore.cpp new file mode 100644 index 0000000000..2aefaeb98f --- /dev/null +++ b/bacula/src/qt-console/restore/prerestore.cpp @@ -0,0 +1,98 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2007-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. +*/ + +/* + * Version $Id: restore.cpp 4307 2007-03-04 10:24:39Z kerns $ + * + * preRestore -> dialog put up to determine the restore type + * + * Kern Sibbald, February MMVII + * + */ + +#include "bat.h" +#include "restore.h" + + +prerestoreDialog::prerestoreDialog(Console *console) +{ + m_console = console; /* keep compiler quiet */ + setupUi(this); + jobCombo->addItems(console->job_list); + filesetCombo->addItems(console->fileset_list); + clientCombo->addItems(console->client_list); + poolCombo->addItems(console->pool_list); + storageCombo->addItems(console->storage_list); + job_name_change(0); + connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int))); + + this->show(); +} + +void prerestoreDialog::accept() +{ + QString cmd; + + this->hide(); + + cmd = QString( + "restore select current fileset=\"%1\" client=\"%2\" pool=\"%3\" " + "storage=\"%4\"\n") + .arg(filesetCombo->currentText()) + .arg(clientCombo->currentText()) + .arg(poolCombo->currentText()) + .arg(storageCombo->currentText()); + + m_console->write(cmd); + m_console->display_text(cmd); + new restoreDialog(m_console); + delete this; +} + + +void prerestoreDialog::reject() +{ + mainWin->set_status("Canceled"); + this->hide(); + delete this; +} + + +void prerestoreDialog::job_name_change(int index) +{ + job_defaults job_defs; + + (void)index; + job_defs.job_name = jobCombo->currentText(); + if (m_console->get_job_defaults(job_defs)) { + filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, 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)); + } +} diff --git a/bacula/src/qt-console/restore/restore.cpp b/bacula/src/qt-console/restore/restore.cpp index f6ba6a8186..13145ed164 100644 --- a/bacula/src/qt-console/restore/restore.cpp +++ b/bacula/src/qt-console/restore/restore.cpp @@ -31,124 +31,57 @@ * * Restore Class * - * Kern Sibbald, February MMVI + * Kern Sibbald, February MMVII * */ #include "bat.h" #include "restore.h" - -prerestoreDialog::prerestoreDialog(Console *console) -{ - m_console = console; /* keep compiler quiet */ - setupUi(this); - jobCombo->addItems(console->job_list); - filesetCombo->addItems(console->fileset_list); - clientCombo->addItems(console->client_list); - poolCombo->addItems(console->pool_list); - storageCombo->addItems(console->storage_list); - job_name_change(0); - connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int))); - - this->show(); -} - -void prerestoreDialog::accept() -{ - QString cmd; - - this->hide(); - - cmd = QString( - "restore select current fileset=\"%1\" client=\"%2\" pool=\"%3\" " - "storage=\"%4\"\n") - .arg(filesetCombo->currentText()) - .arg(clientCombo->currentText()) - .arg(poolCombo->currentText()) - .arg(storageCombo->currentText()); - - m_console->write(cmd); - m_console->display_text(cmd); - new restoreDialog(m_console); - delete this; -} - - -void prerestoreDialog::reject() -{ - mainWin->set_status("Canceled"); - this->hide(); - delete this; -} - - -void prerestoreDialog::job_name_change(int index) -{ - job_defaults job_defs; - - (void)index; - job_defs.job_name = jobCombo->currentText(); - if (m_console->get_job_defaults(job_defs)) { - filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, 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)); - } -} - restoreDialog::restoreDialog(Console *console) { m_console = console; + + m_console->setEnabled(false); setupUi(this); connect(fileWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(fileDoubleClicked(QTreeWidgetItem *, int))); setFont(m_console->get_font()); - fillDirectory("/home/kern/bacula/k"); + m_console->displayToPrompt(); + fillDirectory(); this->show(); } /* - * Fill the CList box with files at path + * Fill the fileWidget box with the contents of the current directory */ -void restoreDialog::fillDirectory(const char *dir) +void restoreDialog::fillDirectory() { - char pathbuf[MAXSTRING]; + char cd_cmd[MAXSTRING]; char modes[20], user[20], group[20], size[20], date[30]; char marked[10]; int pnl, fnl; POOLMEM *file = get_pool_memory(PM_FNAME); POOLMEM *path = get_pool_memory(PM_FNAME); - - m_console->setEnabled(false); - m_fname = dir; - - - m_console->displayToPrompt(); - bsnprintf(pathbuf, sizeof(pathbuf), "cd %s", dir); - Dmsg1(100, "%s\n", pathbuf); - QStringList titles; + titles << "Mark" << "File" << "Mode" << "User" << "Group" << "Size" << "Date"; fileWidget->setHeaderLabels(titles); - m_console->write(pathbuf); - m_console->display_text(pathbuf); - m_console->displayToPrompt(); - - m_console-> write_dir("dir"); - m_console->display_text("dir"); + char *dir = get_cwd(); + bsnprintf(cd_cmd, sizeof(cd_cmd), "cd \"%s\"\n", dir); + Dmsg2(100, "dir=%s cmd=%s\n", dir, cd_cmd); + m_console->write_dir(cd_cmd); + m_console->discardToPrompt(); + m_console->write_dir("dir"); QList items; QStringList item; while (m_console->read() > 0) { char *p = m_console->msg(); char *l; strip_trailing_junk(p); - if (*p == '$') { - break; - } - if (!*p) { + if (*p == '$' || !*p) { continue; } l = p; @@ -182,7 +115,7 @@ void restoreDialog::fillDirectory(const char *dir) bstrncpy(date, l, sizeof(date)); skip_spaces(&p); if (*p == '*') { - bstrncpy(marked, "x", sizeof(marked)); + bstrncpy(marked, "*", sizeof(marked)); p++; } else { bstrncpy(marked, " ", sizeof(marked)); @@ -197,7 +130,6 @@ void restoreDialog::fillDirectory(const char *dir) fileWidget->clear(); fileWidget->insertTopLevelItems(0, items); - m_console->setEnabled(true); free_pool_memory(file); free_pool_memory(path); } @@ -207,6 +139,8 @@ void restoreDialog::accept() this->hide(); m_console->write("done"); delete this; + m_console->setEnabled(true); + mainWin->resetFocus(); } @@ -216,9 +150,44 @@ void restoreDialog::reject() m_console->write("quit"); mainWin->set_status("Canceled"); delete this; + m_console->setEnabled(true); + mainWin->resetFocus(); } void restoreDialog::fileDoubleClicked(QTreeWidgetItem *item, int column) { - printf("Text=%s column=%d\n", item->text(1).toUtf8().data(), column); + char cmd[1000]; +// printf("cwd=%s Text=%s column=%d\n", m_cwd.toUtf8().data(), +// item->text(1).toUtf8().data(), column); + if (column == 0) { /* mark/unmark */ + if (item->text(0) == "*") { + bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"\n", item->text(1).toUtf8().data()); + item->setText(0, " "); + } else { + bsnprintf(cmd, sizeof(cmd), "mark \"%s\"\n", item->text(1).toUtf8().data()); + item->setText(0, "*"); + } + m_console->write(cmd); +// printf("cmd=%s", cmd); + m_console->displayToPrompt(); + return; + } +} + +/* + * Return cwd when in tree restore mode + */ +char *restoreDialog::get_cwd() +{ + int stat; + m_console->write_dir(".pwd"); + Dmsg0(100, "send: .pwd\n"); + if ((stat = m_console->read()) > 0) { + m_cwd = m_console->msg(); + Dmsg2(100, "cwd=%s msg=%s\n", m_cwd.toUtf8().data(), m_console->msg()); + } else { + Dmsg1(000, "stat=%d\n", stat); + } + m_console->displayToPrompt(); + return m_cwd.toUtf8().data(); } diff --git a/bacula/src/qt-console/restore/restore.h b/bacula/src/qt-console/restore/restore.h index 2ed83a771c..0a15ff9f6c 100644 --- a/bacula/src/qt-console/restore/restore.h +++ b/bacula/src/qt-console/restore/restore.h @@ -52,7 +52,7 @@ class prerestoreDialog : public QDialog, public Ui::prerestoreForm public: prerestoreDialog(Console *parent); -public slots: +private slots: void accept(); void reject(); void job_name_change(int index); @@ -73,7 +73,8 @@ class restoreDialog : public QDialog, public Ui::restoreForm public: restoreDialog(Console *parent); - void fillDirectory(const char *path); + void fillDirectory(); + char *get_cwd(); private slots: void accept(); @@ -82,8 +83,7 @@ private slots: private: Console *m_console; - QString m_fname; - + QString m_cwd; }; @@ -100,6 +100,4 @@ private: }; - - #endif /* _RESTORE_H_ */ diff --git a/bacula/src/qt-console/restore/restore.ui b/bacula/src/qt-console/restore/restore.ui index 56c99e0218..f2254c45f2 100644 --- a/bacula/src/qt-console/restore/restore.ui +++ b/bacula/src/qt-console/restore/restore.ui @@ -5,7 +5,7 @@ 0 0 - 688 + 1196 649 @@ -79,15 +79,15 @@ - 5 + 7 7 1 - 0 + 1 - 0 + 100 0