From 9d2232ffd3bca2a23c842bb4d776b6f806304bca Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 6 Mar 2007 13:52:48 +0000 Subject: [PATCH] More bat implementation git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4322 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/migrate.c | 4 +- bacula/src/dird/ua_tree.c | 12 +- bacula/src/qt-console/restore/restore.cpp | 95 ++++++++-- bacula/src/qt-console/restore/restore.h | 4 + bacula/src/qt-console/restore/restore.ui | 216 ++++++++++++++++++++-- 5 files changed, 294 insertions(+), 37 deletions(-) diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index 0165f7153d..f6b369d5a4 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -783,8 +783,10 @@ static int get_job_to_migrate(JCR *jcr) Jmsg(jcr, M_INFO, 0, _("No JobIds found to migrate.\n")); goto ok_out; } - Jmsg(jcr, M_INFO, 0, _("The following %u JobId%s will be migrated: %s\n"), + + Jmsg(jcr, M_INFO, 0, _("The following %u JobId%s were chosen to be migrated: %s\n"), ids.count, ids.count==0?"":"s", ids.list); + Dmsg2(dbglevel, "Before loop count=%d ids=%s\n", ids.count, ids.list); for (int i=1; i < (int)ids.count; i++) { JobId = 0; diff --git a/bacula/src/dird/ua_tree.c b/bacula/src/dird/ua_tree.c index e9706c6e0f..3a2d160a70 100644 --- a/bacula/src/dird/ua_tree.c +++ b/bacula/src/dird/ua_tree.c @@ -123,7 +123,7 @@ bool user_select_files_from_tree(TREE_CTX *tree) } parse_args_only(ua->cmd, &ua->args, &ua->argc, ua->argk, ua->argv, MAX_CMD_ARGS); if (ua->argc == 0) { - bsendmsg(tree->ua, _("Illegal command. Enter \"done\" to exit.\n")); + bsendmsg(tree->ua, _("Invalid command. Enter \"done\" to exit.\n")); continue; } @@ -137,7 +137,7 @@ bool user_select_files_from_tree(TREE_CTX *tree) break; } if (!found) { - bsendmsg(tree->ua, _("Illegal command. Enter \"done\" to exit.\n")); + bsendmsg(tree->ua, _("Invalid command. Enter \"done\" to exit.\n")); continue; } if (!stat) { @@ -678,7 +678,7 @@ static int cdcmd(UAContext *ua, TREE_CTX *tree) if (ua->argc != 2) { - bsendmsg(ua, _("Too many arguments. Try using double quotes.\n")); + bsendmsg(ua, _("Too few or too many arguments. Try using double quotes.\n")); return 1; } node = tree_cwd(ua->argk[1], tree->root, tree->node); @@ -698,7 +698,11 @@ static int cdcmd(UAContext *ua, TREE_CTX *tree) tree->node = node; } tree_getpath(tree->node, cwd, sizeof(cwd)); - bsendmsg(ua, _("cwd is: %s\n"), cwd); + if (ua->api) { + bsendmsg(ua, "%s", cwd); + } else { + bsendmsg(ua, _("cwd is: %s\n"), cwd); + } return 1; } diff --git a/bacula/src/qt-console/restore/restore.cpp b/bacula/src/qt-console/restore/restore.cpp index 13145ed164..0a7c416788 100644 --- a/bacula/src/qt-console/restore/restore.cpp +++ b/bacula/src/qt-console/restore/restore.cpp @@ -40,14 +40,24 @@ restoreDialog::restoreDialog(Console *console) { + QStringList titles; m_console = console; m_console->setEnabled(false); setupUi(this); connect(fileWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(fileDoubleClicked(QTreeWidgetItem *, int))); + connect(upButton, SIGNAL(pressed()), this, SLOT(upButtonPushed())); + connect(markButton, SIGNAL(pressed()), this, SLOT(markButtonPushed())); + connect(unmarkButton, SIGNAL(pressed()), this, SLOT(unmarkButtonPushed())); setFont(m_console->get_font()); m_console->displayToPrompt(); + + + titles << "Mark" << "File" << "Mode" << "User" << "Group" << "Size" << "Date"; + fileWidget->setHeaderLabels(titles); + + get_cwd(); fillDirectory(); this->show(); } @@ -57,23 +67,13 @@ restoreDialog::restoreDialog(Console *console) */ void restoreDialog::fillDirectory() { - 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); - QStringList titles; - - titles << "Mark" << "File" << "Mode" << "User" << "Group" << "Size" << "Date"; - fileWidget->setHeaderLabels(titles); - - 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(); + fileWidget->clear(); m_console->write_dir("dir"); QList items; QStringList item; @@ -157,8 +157,6 @@ void restoreDialog::reject() void restoreDialog::fileDoubleClicked(QTreeWidgetItem *item, int 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()); @@ -168,12 +166,81 @@ void restoreDialog::fileDoubleClicked(QTreeWidgetItem *item, int column) item->setText(0, "*"); } m_console->write(cmd); -// printf("cmd=%s", cmd); m_console->displayToPrompt(); return; + } + /* + * Double clicking other than column 0 means to decend into + * the directory -- or nothing if it is not a directory. + */ + if (item->text(1).endsWith("/")) { + cwd(item->text(1).toUtf8().data()); + fillDirectory(); + } +} + +void restoreDialog::upButtonPushed() +{ + cwd(".."); + fillDirectory(); +} + +void restoreDialog::markButtonPushed() +{ + QList items = fileWidget->selectedItems(); + QTreeWidgetItem *item; + char cmd[1000]; + foreach (item, items) { + Dmsg1(000, "item=%s\n", item->text(1).toUtf8().data()); + if (item->text(0) == " ") { + bsnprintf(cmd, sizeof(cmd), "mark \"%s\"", item->text(1).toUtf8().data()); + item->setText(0, "*"); + m_console->write(cmd); + Dmsg1(000, "cmd=%s\n", cmd); + m_console->displayToPrompt(); + } + } +} + +void restoreDialog::unmarkButtonPushed() +{ + QList items = fileWidget->selectedItems(); + QTreeWidgetItem *item; + char cmd[1000]; + foreach (item, items) { + if (item->text(0) == "*") { + bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"", item->text(1).toUtf8().data()); + item->setText(0, " "); + m_console->write(cmd); + Dmsg1(000, "cmd=%s\n", cmd); + m_console->displayToPrompt(); + } } } +/* + * Change current working directory + */ +bool restoreDialog::cwd(const char *dir) +{ + int stat; + char cd_cmd[MAXSTRING]; + + 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); + 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->discardToPrompt(); + lineEdit->clear(); + lineEdit->insert(m_cwd); + return true; /* ***FIXME*** return real status */ +} + /* * Return cwd when in tree restore mode */ diff --git a/bacula/src/qt-console/restore/restore.h b/bacula/src/qt-console/restore/restore.h index 0a15ff9f6c..499a316d03 100644 --- a/bacula/src/qt-console/restore/restore.h +++ b/bacula/src/qt-console/restore/restore.h @@ -75,11 +75,15 @@ public: restoreDialog(Console *parent); void fillDirectory(); char *get_cwd(); + bool cwd(const char *); private slots: void accept(); void reject(); void fileDoubleClicked(QTreeWidgetItem *item, int column); + void upButtonPushed(); + void unmarkButtonPushed(); + void markButtonPushed(); private: Console *m_console; diff --git a/bacula/src/qt-console/restore/restore.ui b/bacula/src/qt-console/restore/restore.ui index f2254c45f2..a746e40c0b 100644 --- a/bacula/src/qt-console/restore/restore.ui +++ b/bacula/src/qt-console/restore/restore.ui @@ -5,8 +5,8 @@ 0 0 - 1196 - 649 + 1285 + 759 @@ -19,12 +19,28 @@ 6 + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + Qt::Horizontal - + 0 @@ -45,10 +61,13 @@ Qt::Horizontal + + QSizePolicy::Preferred + - 40 - 20 + 50 + 30 @@ -65,10 +84,13 @@ Qt::Horizontal + + QSizePolicy::Preferred + - 40 - 20 + 50 + 30 @@ -79,7 +101,7 @@ - 7 + 5 7 1 1 @@ -87,7 +109,7 @@ - 100 + 60 0 @@ -99,7 +121,13 @@ - 0 + 1 + 0 + + + + + 50 0 @@ -118,7 +146,7 @@ - + 0 @@ -139,6 +167,111 @@ Qt::Horizontal + + QSizePolicy::Fixed + + + + 16 + 20 + + + + + + + + + 5 + 0 + 0 + 0 + + + + Up + + + ../images/up.png + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 16 + 20 + + + + + + + + + 5 + 0 + 0 + 0 + + + + Mark + + + ../images/mark.png + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 16 + 20 + + + + + + + + + 5 + 0 + 0 + 0 + + + + Unmark + + + ../images/unmark.png + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + 61 @@ -161,8 +294,8 @@ - 91 - 20 + 261 + 30 @@ -259,6 +392,9 @@ Current Dir: + + lineEdit + @@ -309,17 +445,61 @@ + + + 0 + 0 + 0 + 0 + + Status: - + + + + 5 + 0 + 0 + 0 + + + + + + + + + ../images/up.png + + + Up + + + + + ../images/mark.png + + + Mark + + + + + ../images/unmark.png + + + Unmark + + @@ -330,8 +510,8 @@ accept() - 248 - 254 + 955 + 719 157 @@ -346,8 +526,8 @@ reject() - 316 - 260 + 1023 + 719 286 -- 2.39.5