2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation plus additions
11 that are listed in the file LICENSE.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of John Walker.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
34 * Kern Sibbald, February MMVI
42 prerestoreDialog::prerestoreDialog(Console *console)
44 m_console = console; /* keep compiler quiet */
46 jobCombo->addItems(console->job_list);
47 filesetCombo->addItems(console->fileset_list);
48 clientCombo->addItems(console->client_list);
49 poolCombo->addItems(console->pool_list);
50 storageCombo->addItems(console->storage_list);
52 connect(jobCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(job_name_change(int)));
57 void prerestoreDialog::accept()
64 "restore select current fileset=\"%1\" client=\"%2\" pool=\"%3\" "
66 .arg(filesetCombo->currentText())
67 .arg(clientCombo->currentText())
68 .arg(poolCombo->currentText())
69 .arg(storageCombo->currentText());
71 m_console->write(cmd);
72 m_console->display_text(cmd);
73 new restoreDialog(m_console);
78 void prerestoreDialog::reject()
80 mainWin->set_status("Canceled");
86 void prerestoreDialog::job_name_change(int index)
88 job_defaults job_defs;
91 job_defs.job_name = jobCombo->currentText();
92 if (m_console->get_job_defaults(job_defs)) {
93 filesetCombo->setCurrentIndex(filesetCombo->findText(job_defs.fileset_name, Qt::MatchExactly));
94 clientCombo->setCurrentIndex(clientCombo->findText(job_defs.client_name, Qt::MatchExactly));
95 poolCombo->setCurrentIndex(poolCombo->findText(job_defs.pool_name, Qt::MatchExactly));
96 storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
100 restoreDialog::restoreDialog(Console *console)
104 fillDirectory("/home/kern/bacula/k");
109 * Fill the CList box with files at path
111 void restoreDialog::fillDirectory(const char *dir)
113 char pathbuf[MAXSTRING];
114 char modes[20], user[20], group[20], size[20], date[30];
118 POOLMEM *file = get_pool_memory(PM_FNAME);
119 POOLMEM *path = get_pool_memory(PM_FNAME);
121 m_console->setEnabled(false);
125 m_console->displayToPrompt();
126 bsnprintf(pathbuf, sizeof(pathbuf), "cd %s", dir);
127 Dmsg1(100, "%s\n", pathbuf);
130 titles << "Mark" << "File" << "Mode" << "User" << "Group" << "Size" << "Date";
131 fileWidget->setHeaderLabels(titles);
133 m_console->write(pathbuf);
134 m_console->display_text(pathbuf);
135 m_console->displayToPrompt();
137 m_console-> write_dir("dir");
138 m_console->display_text("dir");
140 QList<QTreeWidgetItem *> items;
142 while (m_console->read() > 0) {
143 char *p = m_console->msg();
145 strip_trailing_junk(p);
149 // Dmsg1(000, "Got: %s\n", p);
154 skip_nonspaces(&p); /* permissions */
156 bstrncpy(modes, l, sizeof(modes));
158 skip_nonspaces(&p); /* link count */
162 skip_nonspaces(&p); /* user */
165 bstrncpy(user, l, sizeof(user));
167 skip_nonspaces(&p); /* group */
169 bstrncpy(group, l, sizeof(group));
172 skip_nonspaces(&p); /* size */
174 bstrncpy(size, l, sizeof(size));
177 skip_nonspaces(&p); /* date/time */
181 bstrncpy(date, l, sizeof(date));
184 bstrncpy(marked, "x", sizeof(marked));
187 bstrncpy(marked, " ", sizeof(marked));
189 split_path_and_filename(p, &path, &pnl,
192 // printf("modes=%s user=%s group=%s size=%s date=%s path=%s file=%s\n",
193 // modes, user, group, size, date, path, file);
196 item << "" << file << modes << user << group << size << date;
197 items.append(new QTreeWidgetItem((QTreeWidget *)0, item));
201 fileWidget->insertTopLevelItems(0, items);
203 m_console->setEnabled(true);