return;
DirComm *dircomm = m_dircommHash.value(conn);
- if (mainWin->m_checkMessages && dircomm->m_at_main_prompt && hasFocus()){
+ if (mainWin->m_checkMessages && dircomm->m_at_main_prompt && hasFocus() && !mainWin->getWaitState()){
messagesPending(true);
dircomm->write(".messages");
displayToPrompt(conn);
}
/*
- * Connect to Director.
+ * Connect to Director. This does not connect to the director, dircomm does.
+ * This creates the first and possibly 2nd dircomm instance
*/
void Console::connect_dir()
{
if (dircomm->connect_dir()) {
if (mainWin->m_connDebug)
- Pmsg0(000, "DirComm 0 Seems to have Connected\n");
+ Pmsg1(000, "DirComm 0 Seems to have Connected %s\n", m_dir->name());
beginNewCommand(0);
}
+ mainWin->set_status(_("Connected"));
- int ndc;
- if (newDirComm(ndc)) {
- if (mainWin->m_connDebug)
- Pmsg1(000, "DirComm %i Seems to have Connected\n", ndc);
- dircomm = m_dircommHash.value(ndc);
- job_list.clear();
- client_list.clear();
- fileset_list.clear();
- fileset_list.clear();
- messages_list.clear();
- pool_list.clear();
- storage_list.clear();
- type_list.clear();
- level_list.clear();
- dir_cmd(ndc, ".jobs", job_list);
- dir_cmd(ndc, ".clients", client_list);
- dir_cmd(ndc, ".filesets", fileset_list);
- dir_cmd(ndc, ".msgs", messages_list);
- dir_cmd(ndc, ".pools", pool_list);
- dir_cmd(ndc, ".storage", storage_list);
- dir_cmd(ndc, ".types", type_list);
- dir_cmd(ndc, ".levels", level_list);
-
- if (mainWin->m_connDebug) {
- QString dbgmsg = QString("jobs=%1 clients=%2 filesets=%3 msgs=%4 pools=%5 storage=%6 types=%7 levels=%8\n")
- .arg(job_list.count()).arg(client_list.count()).arg(fileset_list.count()).arg(messages_list.count())
- .arg(pool_list.count()).arg(storage_list.count()).arg(type_list.count()).arg(level_list.count());
- Pmsg1(000, "%s\n", dbgmsg.toUtf8().data());
- } else
- if (mainWin->m_connDebug)
- Pmsg0(000, "DirComm 1 Seems to Failed\n");
-
- mainWin->set_status(_("Connected"));
- startTimer(); /* start message timer */
+ startTimer(); /* start message timer */
+}
+
+/*
+ * A function created to separate out the population of the lists
+ * from the Console::connect_dir function
+ */
+void Console::populateLists(bool forcenew)
+{
+ int conn;
+ if (forcenew) {
+ if (!newDirComm(conn)) {
+ Pmsg1(000, "newDirComm Seems to Failed to create a connection for populateLists %s\n", m_dir->name());
+ return;
+ }
+ } else {
+ if(!availableDirComm(conn)) {
+ Pmsg1(000, "availableDirComm Seems to Failed to find a connection for populateListsi %s\n", m_dir->name());
+ return;
+ }
+ }
+ populateLists(conn);
+}
+
+void Console::populateLists(int conn)
+{
+ job_list.clear();
+ client_list.clear();
+ fileset_list.clear();
+ fileset_list.clear();
+ messages_list.clear();
+ pool_list.clear();
+ storage_list.clear();
+ type_list.clear();
+ level_list.clear();
+ dir_cmd(conn, ".jobs", job_list);
+ dir_cmd(conn, ".clients", client_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);
+ dir_cmd(conn, ".types", type_list);
+ dir_cmd(conn, ".levels", level_list);
+
+ if (mainWin->m_connDebug) {
+ QString dbgmsg = QString("jobs=%1 clients=%2 filesets=%3 msgs=%4 pools=%5 storage=%6 types=%7 levels=%8 conn=%9 %10\n")
+ .arg(job_list.count()).arg(client_list.count()).arg(fileset_list.count()).arg(messages_list.count())
+ .arg(pool_list.count()).arg(storage_list.count()).arg(type_list.count()).arg(level_list.count())
+ .arg(conn).arg(m_dir->name());
+ Pmsg1(000, "%s", dbgmsg.toUtf8().data());
}
}
bool Console::dir_cmd(const char *cmd, QStringList &results)
{
int conn;
- if(availableDirComm(conn)) {
+ if (availableDirComm(conn)) {
dir_cmd(conn, cmd, results);
return true;
} else {
- Pmsg0(000, "dir_cmd Seems to Failed to find a connection\n");
+ Pmsg1(000, "dir_cmd Seems to Failed to find a connection %s\n", m_dir->name());
return false;
}
}
*/
bool Console::dir_cmd(int conn, const char *cmd, QStringList &results)
{
+ mainWin->waitEnter();
DirComm *dircomm = m_dircommHash.value(conn);
int stat;
- if (mainWin->m_connDebug)
- Pmsg2(000, "dir_cmd conn %i %s\n", conn, cmd);
+ if (mainWin->m_connDebug) {
+ QString dbgmsg = QString("dir_cmd conn %1 %2 %3\n").arg(conn).arg(m_dir->name()).arg(cmd);
+ Pmsg1(000, "%s", dbgmsg.toUtf8().data());
+ }
notify(conn, false);
dircomm->write(cmd);
while ((stat = dircomm->read()) > 0 && dircomm->is_in_command()) {
if (stat > 0 && mainWin->m_displayAll) display_text(dircomm->msg());
notify(conn, true);
discardToPrompt(conn);
+ mainWin->waitExit();
return true; /* ***FIXME*** return any command error */
}
+/*
+ * OverLoads for sql_cmd
+ */
+bool Console::sql_cmd(int &conn, QString &query, QStringList &results)
+{
+ return sql_cmd(conn, query.toUtf8().data(), results, false);
+}
+
bool Console::sql_cmd(QString &query, QStringList &results)
{
- return sql_cmd(query.toUtf8().data(), results);
+ int conn;
+ if (!availableDirComm(conn))
+ return false;
+ return sql_cmd(conn, query.toUtf8().data(), results, true);
}
-/*
- * Send an sql query to the Director, and return the
- * results in a QStringList.
- */
bool Console::sql_cmd(const char *query, QStringList &results)
{
int conn;
if (!availableDirComm(conn))
return false;
+ return sql_cmd(conn, query, results, true);
+}
+/*
+ * Send an sql query to the Director, and return the
+ * results in a QStringList.
+ */
+bool Console::sql_cmd(int &conn, const char *query, QStringList &results, bool donotify)
+{
DirComm *dircomm = m_dircommHash.value(conn);
int stat;
POOL_MEM cmd(PM_MESSAGE);
if (mainWin->m_connDebug)
Pmsg2(000, "sql_cmd conn %i %s\n", conn, query);
- notify(conn, false);
+ if (donotify)
+ dircomm->notify(false);
+ mainWin->waitEnter();
pm_strcpy(cmd, ".sql query=\"");
pm_strcat(cmd, query);
results << dircomm->msg();
first = false;
}
- notify(conn, true);
+ if (donotify)
+ dircomm->notify(true);
discardToPrompt(conn);
+ mainWin->waitExit();
return true; /* ***FIXME*** return any command error */
}
-/* Send a command to the Director */
+/*
+ * Overloads for
+ * Sending a command to the Director
+ */
int Console::write_dir(const char *msg)
{
int conn;
- if(availableDirComm(conn))
+ if (availableDirComm(conn))
write_dir(conn, msg);
return conn;
}
-/* Send a command to the Director */
+int Console::write_dir(const char *msg, bool dowait)
+{
+ int conn;
+ if (availableDirComm(conn))
+ write_dir(conn, msg, dowait);
+ return conn;
+}
+
void Console::write_dir(int conn, const char *msg)
+{
+ write_dir(conn, msg, true);
+}
+
+/*
+ * Send a command to the Director
+ */
+void Console::write_dir(int conn, const char *msg, bool dowait)
{
DirComm *dircomm = m_dircommHash.value(conn);
if (dircomm->m_sock) {
mainWin->set_status(_("Processing command ..."));
- QApplication::setOverrideCursor(Qt::WaitCursor);
+ if (dowait)
+ mainWin->waitEnter();
dircomm->write(msg);
+ if (dowait)
+ mainWin->waitExit();
} else {
mainWin->set_status( tr(" Director not connected. Click on connect button."));
mainWin->actionConnect->setIcon(QIcon(":images/disconnected.png"));
}
}
+/*
+ * get_job_defaults overload
+ */
+bool Console::get_job_defaults(struct job_defaults &job_defs)
+{
+ int conn;
+ return get_job_defaults(conn, job_defs, true);
+}
+
+bool Console::get_job_defaults(int &conn, struct job_defaults &job_defs)
+{
+ return get_job_defaults(conn, job_defs, false);
+}
+
/*
* Send a job name to the director, and read all the resulting
* defaults.
*/
-bool Console::get_job_defaults(struct job_defaults &job_defs)
+bool Console::get_job_defaults(int &conn, struct job_defaults &job_defs, bool donotify)
{
QString scmd;
int stat;
char *def;
- int conn = notifyOff();
+ if (donotify)
+ conn = notifyOff();
beginNewCommand(conn);
DirComm *dircomm = m_dircommHash.value(conn);
+ bool prevWaitState = mainWin->getWaitState();
+ if (!prevWaitState)
+ mainWin->waitEnter();
if (mainWin->m_connDebug)
- Pmsg1(000, "job_defaults conn %i\n", conn);
+ 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) {
}
}
- notify(conn, true);
+ if (donotify)
+ notify(conn, true);
+ if (!prevWaitState)
+ mainWin->waitExit();
return true;
bail_out:
- notify(conn, true);
+ if (donotify)
+ notify(conn, true);
+ if (!prevWaitState)
+ mainWin->waitExit();
return false;
}
/* Position cursor to end of screen */
void Console::update_cursor()
{
- QApplication::restoreOverrideCursor();
m_textEdit->moveCursor(QTextCursor::End);
m_textEdit->ensureCursorVisible();
}
for (int i=0; i < 3; i++) {
dircomm->write(".");
while (dircomm->read() > 0) {
+ Pmsg2(000, "begin new command loop %i %s\n", i, m_dir->name());
if (mainWin->m_displayAll) display_text(dircomm->msg());
}
if (dircomm->m_at_main_prompt) {
int stat = 0;
QString buf;
- if (mainWin->m_commDebug) Pmsg0(000, "DisplaytoPrompt\n");
+ if (mainWin->m_commDebug) Pmsg1(000, "DisplaytoPrompt %s\n", m_dir->name());
while (!dircomm->m_at_prompt) {
if ((stat=dircomm->read()) > 0) {
buf += dircomm->msg();
}
}
display_text(buf);
- if (mainWin->m_commDebug) Pmsg1(000, "endDisplaytoPrompt=%d\n", stat);
+ if (mainWin->m_commDebug) Pmsg2(000, "endDisplaytoPrompt=%d %s\n", stat, m_dir->name());
}
void Console::discardToPrompt(int conn)
DirComm *dircomm = m_dircommHash.value(conn);
int stat = 0;
- if (mainWin->m_commDebug) Pmsg0(000, "discardToPrompt\n");
+ if (mainWin->m_commDebug) Pmsg1(000, "discardToPrompt %s\n", m_dir->name());
if (mainWin->m_displayAll) {
displayToPrompt(conn);
} else {
while (!dircomm->m_at_prompt) {
- stat=dircomm->read();
+ stat = dircomm->read();
+ if (stat < 0) {
+ break;
+ }
}
}
- if (mainWin->m_commDebug) Pmsg1(000, "endDiscardToPrompt=%d\n", stat);
+ if (mainWin->m_commDebug) Pmsg2(000, "endDiscardToPrompt=%d %s\n", stat, m_dir->name());
}
/*
int Console::notifyOff()
{
int conn = 0;
- if(availableDirComm(conn))
+ if (availableDirComm(conn))
notify(conn, false);
return conn;
}
consoleCommand(cmd);
}
-/* Function to get a list of volumes */
-void Console::getVolumeList(QStringList &volumeList)
-{
- QString query("SELECT VolumeName AS Media FROM Media ORDER BY Media");
- if (mainWin->m_sqlDebug) {
- Pmsg1(000, "Query cmd : %s\n",query.toUtf8().data());
- }
- QStringList results;
- if (sql_cmd(query, results)) {
- QString field;
- QStringList fieldlist;
- /* Iterate through the lines of results. */
- foreach (QString resultline, results) {
- fieldlist = resultline.split("\t");
- volumeList.append(fieldlist[0]);
- } /* foreach resultline */
- } /* if results from query */
-}
-
-/* Function to get a list of volumes */
-void Console::getStatusList(QStringList &statusLongList)
-{
- QString statusQuery("SELECT JobStatusLong FROM Status");
- if (mainWin->m_sqlDebug) {
- Pmsg1(000, "Query cmd : %s\n",statusQuery.toUtf8().data());
- }
- QStringList statusResults;
- if (sql_cmd(statusQuery, statusResults)) {
- QString field;
- QStringList fieldlist;
- /* Iterate through the lines of results. */
- foreach (QString resultline, statusResults) {
- fieldlist = resultline.split("\t");
- statusLongList.append(fieldlist[0]);
- } /* foreach resultline */
- } /* if results from statusquery */
-}
-
/* For suppressing .messages
* This may be rendered not needed if the multiple connections feature gets working */
bool Console::hasFocus()
int Console::write(int conn, const QString msg)
{
DirComm *dircomm = m_dircommHash.value(conn);
- return dircomm->write(msg);
+ mainWin->waitEnter();
+ int ret = dircomm->write(msg);
+ mainWin->waitExit();
+ return ret;
}
int Console::write(int conn, const char *msg)
{
DirComm *dircomm = m_dircommHash.value(conn);
- return dircomm->write(msg);
+ mainWin->waitEnter();
+ int ret = dircomm->write(msg);
+ mainWin->waitExit();
+ return ret;
}
/* This checks to see if any is connected */
m_dircommCounter += 1;
conn = m_dircommCounter;
if (mainWin->m_connDebug)
- Pmsg1(000, "DirComm %i About to Create and Connect\n", m_dircommCounter);
+ Pmsg2(000, "DirComm %i About to Create and Connect %s\n", m_dircommCounter, m_dir->name());
DirComm *dircomm = new DirComm(this, m_dircommCounter);
m_dircommHash.insert(m_dircommCounter, dircomm);
bool success = dircomm->connect_dir();
- if (mainWin->m_connDebug)
+ if (mainWin->m_connDebug) {
if (success)
- Pmsg1(000, "DirComm %i Connected\n", conn);
+ Pmsg2(000, "DirComm %i Connected %s\n", conn, m_dir->name());
else
- Pmsg1(000, "DirComm %i NOT Connected\n", conn);
+ Pmsg2(000, "DirComm %i NOT Connected %s\n", conn, m_dir->name());
+ }
return success;
}