You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Code/Editor/Plugins/PerforcePlugin/PerforceSourceControl.cpp

90 lines
2.0 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "CryFile.h"
#include "PerforceSourceControl.h"
#include "PasswordDlg.h"
#include <QSettings>
#include <QDir>
#include <QFile>
#include <QProcess>
#include <QApplication>
#include <QTimer>
#include <Util/PathUtil.h>
#include <AzCore/base.h>
namespace
{
CryCriticalSection g_cPerforceValues;
}
////////////////////////////////////////////////////////////
ULONG STDMETHODCALLTYPE CPerforceSourceControl::Release()
{
if ((--m_ref) == 0)
{
g_cPerforceValues.Lock();
delete this;
g_cPerforceValues.Unlock();
return 0;
}
else
{
return m_ref;
}
}
void CPerforceSourceControl::Init()
{
UpdateSourceControlState();
}
void CPerforceSourceControl::ShowSettings()
{
if (PerforceConnection::OpenPasswordDlg())
{
UpdateSourceControlState();
}
}
void CPerforceSourceControl::SetSourceControlState(SourceControlState state)
{
CryAutoLock<CryCriticalSection> lock(g_cPerforceValues);
switch (state)
{
case SourceControlState::Disabled:
m_connectionState = ConnectivityState::Disconnected;
break;
case SourceControlState::Active:
m_connectionState = ConnectivityState::Connected;
break;
case SourceControlState::ConfigurationInvalid:
m_connectionState = ConnectivityState::BadConfiguration;
break;
default:
break;
}
}
void CPerforceSourceControl::UpdateSourceControlState()
{
using namespace AzToolsFramework;
SourceControlState state = SourceControlState::Disabled;
SourceControlConnectionRequestBus::BroadcastResult(state,
&SourceControlConnectionRequestBus::Events::GetSourceControlState);
SetSourceControlState(state);
}