This commit is contained in:
DavidXanatos 2022-01-30 09:41:19 +01:00
parent 3dda65c852
commit b753b0039b
3 changed files with 11 additions and 8 deletions

View File

@ -258,7 +258,7 @@ void CSbieAPI::GetUserPaths()
} }
} }
SB_STATUS CSbieAPI::Connect(bool withQueue) SB_STATUS CSbieAPI::Connect(bool takeOver, bool withQueue)
{ {
if (IsConnected()) if (IsConnected())
return SB_OK; return SB_OK;
@ -298,9 +298,12 @@ SB_STATUS CSbieAPI::Connect(bool withQueue)
return SB_ERR(SB_Incompatible, QVariantList() << CurVersion << CompatVersions.join(", ")); return SB_ERR(SB_Incompatible, QVariantList() << CurVersion << CompatVersions.join(", "));
} }
SB_STATUS Status = TakeOver(); SB_STATUS Status = SB_OK;
if (takeOver) {
Status = TakeOver();
if (!Status) // only the session leader manages the interactive queue if (!Status) // only the session leader manages the interactive queue
withQueue = false; withQueue = false;
}
m_bWithQueue = withQueue; m_bWithQueue = withQueue;
m_bTerminate = false; m_bTerminate = false;

View File

@ -40,7 +40,7 @@ public:
static bool IsSbieCtrlRunning(); static bool IsSbieCtrlRunning();
static bool TerminateSbieCtrl(); static bool TerminateSbieCtrl();
virtual SB_STATUS Connect(bool withQueue = true); virtual SB_STATUS Connect(bool takeOver, bool withQueue);
virtual SB_STATUS Disconnect(); virtual SB_STATUS Disconnect();
virtual bool IsConnected() const; virtual bool IsConnected() const;

View File

@ -246,7 +246,7 @@ CSandMan::CSandMan(QWidget *parent)
m_pTraySeparator = m_pTrayMenu->addSeparator(); m_pTraySeparator = m_pTrayMenu->addSeparator();
m_pTrayMenu->addAction(m_pEmptyAll); m_pTrayMenu->addAction(m_pEmptyAll);
m_pDisableForce2 = m_pTrayMenu->addAction(tr("Disable Forced Programs"), this, SLOT(OnDisableForce2())); m_pDisableForce2 = m_pTrayMenu->addAction(tr("Pause Forced Programs Rules"), this, SLOT(OnDisableForce2()));
m_pDisableForce2->setCheckable(true); m_pDisableForce2->setCheckable(true);
m_pTrayMenu->addSeparator(); m_pTrayMenu->addSeparator();
@ -387,7 +387,7 @@ void CSandMan::CreateMenus()
m_pMenuFile->addSeparator(); m_pMenuFile->addSeparator();
m_pEmptyAll = m_pMenuFile->addAction(CSandMan::GetIcon("EmptyAll"), tr("Terminate All Processes"), this, SLOT(OnEmptyAll())); m_pEmptyAll = m_pMenuFile->addAction(CSandMan::GetIcon("EmptyAll"), tr("Terminate All Processes"), this, SLOT(OnEmptyAll()));
m_pWndFinder = m_pMenuFile->addAction(CSandMan::GetIcon("finder"), tr("Window Finder"), this, SLOT(OnWndFinder())); m_pWndFinder = m_pMenuFile->addAction(CSandMan::GetIcon("finder"), tr("Window Finder"), this, SLOT(OnWndFinder()));
m_pDisableForce = m_pMenuFile->addAction(tr("Disable Forced Programs"), this, SLOT(OnDisableForce())); m_pDisableForce = m_pMenuFile->addAction(tr("Pause Forced Programs Rules"), this, SLOT(OnDisableForce()));
m_pDisableForce->setCheckable(true); m_pDisableForce->setCheckable(true);
m_pMenuFile->addSeparator(); m_pMenuFile->addSeparator();
m_pMaintenance = m_pMenuFile->addMenu(CSandMan::GetIcon("Maintenance"), tr("&Maintenance")); m_pMaintenance = m_pMenuFile->addMenu(CSandMan::GetIcon("Maintenance"), tr("&Maintenance"));
@ -1487,7 +1487,7 @@ SB_STATUS CSandMan::ConnectSbie()
SB_STATUS CSandMan::ConnectSbieImpl() SB_STATUS CSandMan::ConnectSbieImpl()
{ {
SB_STATUS Status = theAPI->Connect(theConf->GetBool("Options/UseInteractiveQueue", true)); SB_STATUS Status = theAPI->Connect(g_PendingMessage.isEmpty(), theConf->GetBool("Options/UseInteractiveQueue", true));
if (Status.GetStatus() == 0xC0000038L /*STATUS_DEVICE_ALREADY_ATTACHED*/) { if (Status.GetStatus() == 0xC0000038L /*STATUS_DEVICE_ALREADY_ATTACHED*/) {
OnLogMessage(tr("CAUTION: Another agent (probably SbieCtrl.exe) is already managing this Sandboxie session, please close it first and reconnect to take over.")); OnLogMessage(tr("CAUTION: Another agent (probably SbieCtrl.exe) is already managing this Sandboxie session, please close it first and reconnect to take over."));