PerforceSourceControl.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include "CryFile.h"
  9. #include "PerforceSourceControl.h"
  10. #include "PasswordDlg.h"
  11. #include <QSettings>
  12. #include <QDir>
  13. #include <QFile>
  14. #include <QProcess>
  15. #include <QApplication>
  16. #include <QTimer>
  17. #include <Util/PathUtil.h>
  18. #include <AzCore/base.h>
  19. namespace
  20. {
  21. CryCriticalSection g_cPerforceValues;
  22. }
  23. ////////////////////////////////////////////////////////////
  24. ULONG STDMETHODCALLTYPE CPerforceSourceControl::Release()
  25. {
  26. if ((--m_ref) == 0)
  27. {
  28. g_cPerforceValues.Lock();
  29. delete this;
  30. g_cPerforceValues.Unlock();
  31. return 0;
  32. }
  33. else
  34. {
  35. return m_ref;
  36. }
  37. }
  38. void CPerforceSourceControl::Init()
  39. {
  40. UpdateSourceControlState();
  41. }
  42. void CPerforceSourceControl::ShowSettings()
  43. {
  44. if (PerforceConnection::OpenPasswordDlg())
  45. {
  46. UpdateSourceControlState();
  47. }
  48. }
  49. void CPerforceSourceControl::SetSourceControlState(SourceControlState state)
  50. {
  51. CryAutoLock<CryCriticalSection> lock(g_cPerforceValues);
  52. switch (state)
  53. {
  54. case SourceControlState::Disabled:
  55. m_connectionState = ConnectivityState::Disconnected;
  56. break;
  57. case SourceControlState::Active:
  58. m_connectionState = ConnectivityState::Connected;
  59. break;
  60. case SourceControlState::ConfigurationInvalid:
  61. m_connectionState = ConnectivityState::BadConfiguration;
  62. break;
  63. default:
  64. break;
  65. }
  66. }
  67. void CPerforceSourceControl::UpdateSourceControlState()
  68. {
  69. using namespace AzToolsFramework;
  70. SourceControlState state = SourceControlState::Disabled;
  71. SourceControlConnectionRequestBus::BroadcastResult(state,
  72. &SourceControlConnectionRequestBus::Events::GetSourceControlState);
  73. SetSourceControlState(state);
  74. }