m_textEdit = textEdit; /* our console screen */
if (!m_dir) {
- mainWin->set_status(" No Director found.");
+ mainWin->set_status("No Director found.");
return;
}
if (m_sock) {
- mainWin->set_status(" Already connected.");
+ mainWin->set_status("Already connected.");
return;
}
memset(&jcr, 0, sizeof(jcr));
- mainWin->set_statusf(_(" Connecting to Director %s:%d"), m_dir->address, m_dir->DIRport);
+ mainWin->set_statusf(_("Connecting to Director %s:%d"), 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 */
/* Give GUI a chance */
app->processEvents();
- mainWin->set_status(_(" Initializing ..."));
+ mainWin->set_status(_("Initializing ..."));
/* Set up input notifier */
m_notifier = new QSocketNotifier(m_sock->fd, QSocketNotifier::Read, 0);
QObject::connect(m_notifier, SIGNAL(activated(int)), this, SLOT(read_dir(int)));
+ beginNewCommand();
job_list = get_list(".jobs");
client_list = get_list(".clients");
fileset_list = get_list(".filesets");
type_list = get_list(".types");
level_list = get_list(".levels");
- mainWin->set_status(_(" Connected"));
+ mainWin->set_status(_("Connected"));
return;
}
*/
bool Console::get_job_defaults(struct job_defaults &job_defs)
{
+ QString scmd;
char cmd[1000];
int stat;
char *def;
setEnabled(false);
- bsnprintf(cmd, sizeof(cmd), ".defaults job=\"%s\"", job_defs.job_name.toUtf8().data());
- write(cmd);
+ beginNewCommand();
+ scmd = QString(".defaults job=\"%1\"").arg(job_defs.job_name);
+ write(scmd);
while ((stat = read()) > 0) {
def = strchr(msg(), '=');
if (!def) {
{
if (m_sock) {
m_at_prompt = false;
- mainWin->set_status(_(" Processing command ..."));
+ mainWin->set_status(_("Processing command ..."));
QApplication::setOverrideCursor(Qt::WaitCursor);
m_sock->msglen = strlen(msg);
pm_strcpy(&m_sock->msg, msg);
- bnet_send(m_sock);
+ m_sock->send();
} else {
mainWin->set_status(" Director not connected. Click on connect button.");
mainWin->actionConnect->setIcon(QIcon(QString::fromUtf8("images/disconnected.png")));
}
}
+int Console::write(const QString msg)
+{
+ return write(msg.toUtf8().data());
+}
+
int Console::write(const char *msg)
{
m_sock->msglen = strlen(msg);
pm_strcpy(&m_sock->msg, msg);
- return bnet_send(m_sock);
+ return m_sock->send();
+}
+
+/*
+ * Get to main command prompt
+ */
+void Console::beginNewCommand()
+{
+// displayToPrompt();
+ write(".\n");
+ while (read() > 0) {
+ }
+ write(".\n");
+ while (read() > 0) {
+ }
+ write(".\n");
+ while (read() > 0) {
+ }
+ display_text("\n");
+}
+
+void Console::displayToPrompt()
+{
+ while (read() > 0) {
+ display_text(msg());
+ }
+
}
/*
return BNET_ERROR;
}
}
- return bnet_recv(m_sock);
+ return m_sock->recv();
}
return BNET_HARDEOF;
}
if (!m_sock) {
return;
}
- stat = bnet_recv(m_sock);
+ stat = read();
if (stat >= 0) {
if (m_at_prompt) {
display_text("\n");
m_at_prompt = false;
}
- display_text(m_sock->msg);
+ display_text(msg());
return;
}
if (is_bnet_stop(m_sock)) { /* error or term request */
m_notifier->setEnabled(false);
delete m_notifier;
m_notifier = NULL;
- mainWin->set_status(_(" Director disconnected."));
+ 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 ..."));
+ mainWin->set_status(_("At prompt waiting for input ..."));
update_cursor();
}
if (m_sock->msglen == BNET_EOD) {
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 store_name[MAX_NAME_LENGTH];
- char where[MAX_NAME_LENGTH];
- char level[MAX_NAME_LENGTH];
- char type[MAX_NAME_LENGTH];
- char fileset_name[MAX_NAME_LENGTH];
- char catalog_name[MAX_NAME_LENGTH];
-#endif
bool enabled;
};
QStringList get_list(char *cmd);
bool get_job_defaults(struct job_defaults &);
void terminate();
+ void beginNewCommand();
+ void displayToPrompt();
QStringList job_list;
QStringList client_list;
void read_dir(int fd);
int read(void);
int write(const char *msg);
+ int write(QString msg);
void status_dir(void);
void set_font(void);
#include "bat.h"
#include "restore.h"
-restoreDialog::restoreDialog(Console *parent)
-{
- (void)parent; /* keep compiler quiet */
- setupUi(this);
- this->show();
-}
prerestoreDialog::prerestoreDialog(Console *console)
{
.arg(poolCombo->currentText())
.arg(storageCombo->currentText());
-// m_console->write(cmd);
+ m_console->write(cmd);
m_console->display_text(cmd);
delete this;
+ new restoreDialog(m_console);
}
storageCombo->setCurrentIndex(storageCombo->findText(job_defs.store_name, Qt::MatchExactly));
}
}
+
+restoreDialog::restoreDialog(Console *console)
+{
+ m_console = console;
+ setupUi(this);
+ fillDirectory("/");
+ this->show();
+}
+
+/*
+ * Fill the CList box with files at path
+ */
+void restoreDialog::fillDirectory(const char *path)
+{
+ char pathbuf[MAXSTRING];
+ char modes[20], user[20], group[20], size[20], date[30];
+ char file[1000];
+ char marked[10];
+ int row = 0;
+
+ m_console->setEnabled(false);
+ m_fname = path;
+
+
+ m_console->displayToPrompt();
+ bsnprintf(pathbuf, sizeof(pathbuf), "cd %s", path);
+ Dmsg1(100, "%s\n", pathbuf);
+
+ m_console->write(pathbuf);
+ m_console->display_text(pathbuf);
+ m_console->displayToPrompt();
+
+ m_console-> write_dir("dir");
+ m_console->display_text("dir");
+ while (m_console->read() > 0) {
+ char *p = m_console->msg();
+ char *l;
+ strip_trailing_junk(p);
+ if (*p == '$') {
+ break;
+ }
+ Dmsg1(200, "Got: %s\n", p);
+ if (!*p) {
+ continue;
+ }
+ l = p;
+ skip_nonspaces(&p); /* permissions */
+ *p++ = 0;
+ bstrncpy(modes, l, sizeof(modes));
+ skip_spaces(&p);
+ skip_nonspaces(&p); /* link count */
+ *p++ = 0;
+ skip_spaces(&p);
+ l = p;
+ skip_nonspaces(&p); /* user */
+ *p++ = 0;
+ skip_spaces(&p);
+ bstrncpy(user, l, sizeof(user));
+ l = p;
+ skip_nonspaces(&p); /* group */
+ *p++ = 0;
+ bstrncpy(group, l, sizeof(group));
+ skip_spaces(&p);
+ l = p;
+ skip_nonspaces(&p); /* size */
+ *p++ = 0;
+ bstrncpy(size, l, sizeof(size));
+ skip_spaces(&p);
+ l = p;
+ skip_nonspaces(&p); /* date/time */
+ skip_spaces(&p);
+ skip_nonspaces(&p);
+ *p++ = 0;
+ bstrncpy(date, l, sizeof(date));
+ skip_spaces(&p);
+ if (*p == '*') {
+ bstrncpy(marked, "x", sizeof(marked));
+ p++;
+ } else {
+ bstrncpy(marked, " ", sizeof(marked));
+ }
+// split_path_and_filename(p, &restore->path, &restore->pnl,
+// &restore->file, &restore->fnl);
+
+// Dmsg1(000, "restore->fname=%s\n", restore->fname);
+// bstrncpy(file, restore->file, sizeof(file));
+ printf("modes=%s user=%s group=%s size=%s date=%s file=%s\n",
+ modes, user, group, size, date, file);
+
+// append to list
+
+ row++;
+ }
+
+ m_console->setEnabled(true);
+}
public:
restoreDialog(Console *parent);
+ void fillDirectory(const char *path);
public slots:
-
private:
+ Console *m_console;
+ QString m_fname;
};
m_console = console;
setupUi(this);
+ m_console->beginNewCommand();
jobCombo->addItems(console->job_list);
filesetCombo->addItems(console->fileset_list);
levelCombo->addItems(console->level_list);
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));
- while (typeCombo->count() > 0) {
- typeCombo->removeItem(0);
- }
+ typeCombo->clear();
typeCombo->addItem(job_defs.type);
}
}