]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/restore/brestore.cpp
bat: Use BVFS on bRestore view
[bacula/bacula] / bacula / src / qt-console / restore / brestore.cpp
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
5
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 three of the GNU Affero General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
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.
17
18    You should have received a copy of the GNU Affero 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
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
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.
27 */
28  
29 /*
30  *   Version $Id$
31  *
32  *  bRestore Class  (Eric's brestore)
33  *
34  *   Kern Sibbald, January MMVII
35  *
36  */ 
37
38 #include "bat.h"
39 #include "restore.h"
40
41 bRestore::bRestore()
42 {
43    m_name = tr("bRestore");
44    m_client = "";
45    setupUi(this);
46    pgInitialize();
47    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
48    thisitem->setIcon(0, QIcon(QString::fromUtf8(":images/browse.png")));
49    dockPage();
50    m_populated = false;
51 }
52
53 void bRestore::setClient()
54 {
55    Pmsg0(000, "Repopulating client table\n");
56    // Select the same client, don't touch
57    if (m_client == ClientList->currentText()) {
58       return;
59    }
60    m_client = ClientList->currentText();
61    FileList->clearContents();
62    FileRevisions->clearContents();
63    JobList->clear();
64    JobList->setEnabled(true);
65    LocationEntry->clear();
66
67    if (ClientList->currentIndex() < 1) {
68       return;
69    }
70
71    JobList->addItem("Job list for " + m_client);
72
73    QString jobQuery =
74       "SELECT Job.Jobid AS JobId, Job.StartTime AS StartTime,"
75       " Job.Level AS Level,"
76       " Job.Name AS Name"
77       " FROM Job JOIN Client USING (ClientId)"
78       " WHERE"
79       " Job.JobStatus IN ('T','W') AND Job.Type='B' AND"
80       " Client.Name='" + m_client + "' ORDER BY StartTime DESC" ;
81
82    QString job;
83    QStringList results;
84    if (m_console->sql_cmd(jobQuery, results)) {
85       QString field;
86       QStringList fieldlist;
87
88       /* Iterate through the record returned from the query */
89       foreach (QString resultline, results) {
90          fieldlist = resultline.split("\t");
91          job = fieldlist[1] + " " + fieldlist[3] + "(" + fieldlist[2] + ")";
92          JobList->addItem(job, QVariant(fieldlist[0]));
93       }
94    }
95 }
96
97
98 void bRestore::setJob()
99 {
100    if (JobList->currentIndex() < 1) {
101       return ;
102    }
103    QStringList results;
104    QVariant tmp = JobList->itemData(JobList->currentIndex(), Qt::UserRole);
105    m_jobids = tmp.toString(); 
106    QString cmd = ".bvfs_update jobid=" + m_jobids;
107    m_console->dir_cmd(cmd, results);
108    displayFiles("/");
109    Pmsg0(000, "update done\n");
110 }
111
112 void bRestore::displayFiles(uint64_t pathid)
113 {
114
115 }
116
117 void bRestore::displayFiles(QString path)
118 {
119    QString q = ".bvfs_lsdir jobid=" + m_jobids + " path=" + path;
120    QStringList results;
121    if (m_console->dir_cmd(q, results)) {
122       QString field;
123       QStringList fieldlist;
124
125       foreach (QString resultline, results) {
126          fieldlist = resultline.split("\t");
127       }
128    }
129 }
130
131 void bRestore::PgSeltreeWidgetClicked()
132 {
133    if(!m_populated) {
134       setupPage();
135    }
136    if (!isOnceDocked()) {
137       dockPage();
138    }
139 }
140
141 void bRestore::setupPage()
142 {
143    Pmsg0(000, "Setup page\n");
144    ClientList->addItem("Client list");
145    ClientList->addItems(m_console->client_list);
146    connect(ClientList, SIGNAL(currentIndexChanged(int)), this, SLOT(setClient()));
147    connect(JobList, SIGNAL(currentIndexChanged(int)), this, SLOT(setJob()));
148    m_populated = true;
149 }
150
151 bRestore::~bRestore()
152 {
153 }