m_conn = conn;
m_in_command = 0;
m_in_select = false;
+ m_notify = false;
}
DirComm::~DirComm()
m_notifier->setEnabled(false);
delete m_notifier;
m_notifier = NULL;
+ m_notify = false;
}
if (mainWin->m_connDebug)
Pmsg2(000, "DirComm %i terminating connections %s\n", m_conn, m_console->m_dir->name());
m_notifier = new QSocketNotifier(m_sock->m_fd, QSocketNotifier::Read, 0);
QObject::connect(m_notifier, SIGNAL(activated(int)), this, SLOT(notify_read_dir(int)));
m_notifier->setEnabled(true);
+ m_notify = true;
write(".api 1");
m_api_set = true;
m_notifier->setEnabled(false);
delete m_notifier;
m_notifier = NULL;
+ m_notify = false;
}
mainWin->set_status(_("Director disconnected."));
stat = BNET_HARDEOF;
*
* When we are in a bat dialog, we want to control *all* output
* from the Directory, so we set notify to off.
- * m_console->notifiy(false);
+ * m_console->notify(false);
*/
bool DirComm::notify(bool enable)
{
mainWin->m_notify = enable;
if (m_notifier) {
prev_enabled = m_notifier->isEnabled();
- if (prev_enabled != enable) {
- m_notifier->setEnabled(enable);
- }
- if (mainWin->m_connDebug) Pmsg3(000, "conn=%i notify=%d prev=%d\n", m_conn, enable, prev_enabled);
+ m_notifier->setEnabled(enable);
+ m_notify = enable;
+ if (mainWin->m_connDebug) Pmsg3(000, "conn=%i set_notify=%d prev=%d\n", m_conn, enable, prev_enabled);
} else if (mainWin->m_connDebug) {
Pmsg2(000, "m_notifier does not exist: %i %s\n", m_conn, m_console->m_dir->name());
}
bool DirComm::is_notify_enabled() const
{
- return mainWin->m_notify;
+ return m_notify;
}
/*
}
}
populateLists(conn);
+ notify(conn, true);
}
void Console::populateLists(int conn)
mainWin->waitEnter();
DirComm *dircomm = m_dircommHash.value(conn);
int stat;
- bool prev_notify = mainWin->m_notify;
+ bool prev_notify = is_notify_enabled(conn);
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);
+ if (prev_notify) {
+ notify(conn, false);
+ }
dircomm->write(cmd);
while ((stat = dircomm->read()) > 0 && dircomm->is_in_command()) {
if (mainWin->m_displayAll) display_text(dircomm->msg());
DirComm *dircomm = m_dircommHash.value(conn);
int stat;
POOL_MEM cmd(PM_MESSAGE);
- bool prev_notify = mainWin->m_notify;
+ bool prev_notify = is_notify_enabled(conn);
if (!is_connectedGui()) {
return false;
}
discardToPrompt(conn);
mainWin->waitExit();
+ if (donotify && prev_notify) {
+ dircomm->notify(true);
+ }
return !mainWin->isClosing(); /* return false if closing */
}
bool Console::get_job_defaults(struct job_defaults &job_defs)
{
int conn;
+ getDirComm(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);
+ return get_job_defaults(conn, job_defs, true);
}
/*
QString scmd;
int stat;
char *def;
- bool prev_notify = mainWin->m_notify;
+ bool prev_notify = is_notify_enabled(conn);
bool rtn = false;
+ DirComm *dircomm = m_dircommHash.value(conn);
if (donotify) {
- conn = notifyOff();
+ dircomm->notify(false);
}
beginNewCommand(conn);
- DirComm *dircomm = m_dircommHash.value(conn);
bool prevWaitState = mainWin->getWaitState();
if (!prevWaitState)
mainWin->waitEnter();
bool Console::notify(int conn, bool enable)
{
DirComm *dircomm = m_dircommHash.value(conn);
- return dircomm->notify(enable);
+ if (dircomm) {
+ return dircomm->notify(enable);
+ } else {
+ return false;
+ }
}
/* knowing a connection, return notify state */
bool Console::is_notify_enabled(int conn) const
{
DirComm *dircomm = m_dircommHash.value(conn);
- return dircomm->is_notify_enabled();
+ if (dircomm) {
+ return dircomm->is_notify_enabled();
+ } else {
+ return false;
+ }
}
void Console::setDirectorTreeItem(QTreeWidgetItem *item)
*/
bool Console::findDirComm(int &conn)
{
- int i = 1;
QHash<int, DirComm*>::const_iterator iter = m_dircommHash.constBegin();
while (iter != m_dircommHash.constEnd()) {
DirComm *dircomm = iter.value();
}
if (mainWin->m_connDebug) {
Pmsg4(000, "currentDirComm=%d at_prompt=%d at_main=%d && notify=%d\n",
- i, dircomm->m_at_prompt, dircomm->m_at_main_prompt, dircomm->is_notify_enabled());
- i++;
+ dircomm->m_conn, dircomm->m_at_prompt, dircomm->m_at_main_prompt, dircomm->is_notify_enabled());
}
++iter;
}