From a00ffdb1c7e9aa42b226baeb776d9da91a4edcd8 Mon Sep 17 00:00:00 2001 From: Dirk H Bartley Date: Sun, 22 Mar 2009 14:28:44 +0000 Subject: [PATCH] Create overloads for sql_command and get_job_defaults. In prerestore, connections were being made that did not need to be. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8580 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/qt-console/console/console.cpp | 56 ++++++++++++++++++----- bacula/src/qt-console/console/console.h | 4 ++ 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 4e4c991f21..f1291ca4fd 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -209,21 +209,36 @@ bool Console::dir_cmd(int conn, const char *cmd, QStringList &results) 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); @@ -234,7 +249,8 @@ bool Console::sql_cmd(const char *query, QStringList &results) if (mainWin->m_connDebug) Pmsg2(000, "sql_cmd conn %i %s\n", conn, query); - notify(conn, false); + if (donotify) + dircomm->notify(false); pm_strcpy(cmd, ".sql query=\""); pm_strcat(cmd, query); @@ -256,7 +272,8 @@ bool Console::sql_cmd(const char *query, QStringList &results) results << dircomm->msg(); first = false; } - notify(conn, true); + if (donotify) + dircomm->notify(true); discardToPrompt(conn); return true; /* ***FIXME*** return any command error */ } @@ -290,17 +307,32 @@ void Console::write_dir(int conn, const char *msg) } } +/* + * 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); if (mainWin->m_connDebug) @@ -365,11 +397,13 @@ bool Console::get_job_defaults(struct job_defaults &job_defs) } } - notify(conn, true); + if (donotify) + notify(conn, true); return true; bail_out: - notify(conn, true); + if (donotify) + notify(conn, true); return false; } diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index 61f751e773..5c2b35e9d2 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -88,6 +88,8 @@ public: bool dir_cmd(QString &cmd, QStringList &results); bool sql_cmd(const char *cmd, QStringList &results); bool sql_cmd(QString &cmd, QStringList &results); + bool sql_cmd(int &conn, QString &cmd, QStringList &results); + bool sql_cmd(int &conn, const char *cmd, QStringList &results, bool donotify); int write_dir(const char *buf); void write_dir(int conn, const char *buf); void getDirResName(QString &); @@ -106,12 +108,14 @@ public: void display_textf(const char *fmt, ...); void display_html(const QString buf); bool get_job_defaults(struct job_defaults &); + bool get_job_defaults(int &conn, struct job_defaults &); const QFont get_font(); void beginNewCommand(int conn); void getVolumeList(QStringList &); void getStatusList(QStringList &); private: + bool get_job_defaults(int &conn, struct job_defaults &, bool donotify); void update_cursor(void); void stopTimer(); bool is_connectedGui(); -- 2.39.5