/*
- Bacula® - The Network Backup Solution
+ Bacula(R) - The Network Backup Solution
- Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2016 Kern Sibbald
- The main author of Bacula is Kern Sibbald, with contributions from many
- others, a complete list can be found in the file AUTHORS.
+ The original author of Bacula is Kern Sibbald, with contributions
+ from many others, a complete list can be found in the file AUTHORS.
You may use this file and others of this release according to the
license defined in the LICENSE file, which includes the Affero General
Public License, v3.0 ("AGPLv3") and some additional permissions and
terms pursuant to its AGPLv3 Section 7.
- Bacula® is a registered trademark of Kern Sibbald.
+ This notice must be preserved when any source code is
+ conveyed and/or propagated.
+
+ Bacula(R) is a registered trademark of Kern Sibbald.
*/
/*
* Console Class
*
* Written by Kern Sibbald, January MMVII
*
- */
+ */
#include "bat.h"
#include "console.h"
m_warningPrevent = false;
m_dircommCounter = 0;
- /*
+ /*
* Create a connection to the Director and put it in a hash table
*/
m_dircommHash.insert(m_dircommCounter, new DirComm(this, m_dircommCounter));
beginNewCommand(0);
}
mainWin->set_status(_("Connected"));
-
+
startTimer(); /* start message timer */
}
dir_cmd(conn, ".jobs", job_list);
dir_cmd(conn, ".jobs type=R", restore_list);
dir_cmd(conn, ".clients", client_list);
- dir_cmd(conn, ".filesets", fileset_list);
+ dir_cmd(conn, ".filesets", fileset_list);
dir_cmd(conn, ".msgs", messages_list);
dir_cmd(conn, ".pools", pool_list);
dir_cmd(conn, ".storage", storage_list);
/*
* Send a command to the Director, and return the
- * results in a QStringList.
+ * results in a QStringList.
*/
bool Console::dir_cmd(int conn, const char *cmd, QStringList &results)
{
/*
* Send an sql query to the Director, and return the
- * results in a QStringList.
+ * results in a QStringList.
*/
bool Console::sql_cmd(int &conn, const char *query, QStringList &results, bool donotify)
{
dircomm->notify(false);
}
mainWin->waitEnter();
-
+
pm_strcpy(cmd, ".sql query=\"");
pm_strcat(cmd, query);
pm_strcat(cmd, "\"");
return !mainWin->isClosing(); /* return false if closing */
}
-/*
+/*
* Overloads for
* Sending a command to the Director
*/
return get_job_defaults(conn, job_defs, true);
}
-/*
+/*
* Send a job name to the director, and read all the resulting
- * defaults.
+ * defaults.
*/
bool Console::get_job_defaults(int &conn, struct job_defaults &job_defs, bool donotify)
{
}
beginNewCommand(conn);
bool prevWaitState = mainWin->getWaitState();
- if (!prevWaitState)
+ if (!prevWaitState) {
mainWin->waitEnter();
- if (mainWin->m_connDebug)
+ }
+ if (mainWin->m_connDebug) {
Pmsg2(000, "job_defaults conn %i %s\n", conn, m_dir->name());
+ }
scmd = QString(".defaults job=\"%1\"").arg(job_defs.job_name);
dircomm->write(scmd);
while ((stat = dircomm->read()) > 0) {
* Read and restore user settings associated with this console
*/
void Console::readSettings()
-{
+{
QFont font = get_font();
QSettings settings(m_dir->name(), "bat");
void Console::display_text(const QString buf)
{
+ if (mainWin->isClosing()) return;
if (buf.size() != 0) {
m_cursor->insertText(buf);
update_cursor();
void Console::display_text(const char *buf)
{
+ if (mainWin->isClosing()) return;
if (*buf != 0) {
m_cursor->insertText(buf);
update_cursor();
void Console::display_html(const QString buf)
{
+ if (mainWin->isClosing()) return;
if (buf.size() != 0) {
m_cursor->insertHtml(buf);
update_cursor();
{
DirComm *dircomm = m_dircommHash.value(conn);
+ if (dircomm->m_at_main_prompt) {
+ return;
+ }
for (int i=0; i < 3; i++) {
dircomm->write(".");
while (dircomm->read() > 0) {
break;
}
}
- display_text("\n");
+ //display_text("\n");
}
void Console::displayToPrompt(int conn)
-{
+{
DirComm *dircomm = m_dircommHash.value(conn);
int stat = 0;
}
QString Console::returnFromPrompt(int conn)
-{
+{
DirComm *dircomm = m_dircommHash.value(conn);
QString text("");
/*
* When the notifier is enabled, read_dir() will automatically be
- * called by the Qt event loop when ever there is any output
+ * called by the Qt event loop when ever there is any output
* from the Director, and read_dir() will then display it on
* the console.
*
/* dual purpose function to turn notify off and return a connection */
int Console::notifyOff()
-{
+{
int conn = 0;
if (getDirComm(conn)) {
notify(conn, false);
/* knowing a connection, turn notify off or on */
bool Console::notify(int conn, bool enable)
-{
+{
DirComm *dircomm = m_dircommHash.value(conn);
if (dircomm) {
return dircomm->notify(enable);
m_directorTreeItem = item;
}
-void Console::setDirRes(DIRRES *dir)
-{
+void Console::setDirRes(DIRRES *dir)
+{
m_dir = dir;
}
return false;
}
-/* For adding feature to have the gui's messages button change when
+/* For adding feature to have the gui's messages button change when
* messages are pending */
bool Console::messagesPending(bool pend)
{
/*
* Try to find a free (unused but established) connection
* KES: Note, I think there is a problem here because for
- * some reason, the notifier is often turned off on file
+ * some reason, the notifier is often turned off on file
* descriptors that seem to me to be available. That means
* that we do not use a free descriptor and thus we will create
* a new connection that is maybe not necessary. Someone needs
* to look into whether or not notify() is correctly turned on
* when we are back at the command prompt and idle.
- *
+ *
*/
bool Console::findDirComm(int &conn)
{
return true;
}
if (mainWin->m_connDebug) {
- Pmsg4(000, "currentDirComm=%d at_prompt=%d at_main=%d && notify=%d\n",
+ Pmsg4(000, "currentDirComm=%d at_prompt=%d at_main=%d && notify=%d\n",
dircomm->m_conn, dircomm->m_at_prompt, dircomm->m_at_main_prompt, dircomm->is_notify_enabled());
}
++iter;