void ExchangeTokensAndJoinOrganization(string unityAccessToken) { int ini = Environment.TickCount; TokenExchangeResponse response = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(10); waiter.Execute( /*threadOperationDelegate*/ delegate { mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ResponseInit; response = PlasticScmRestApiClient.TokenExchange(unityAccessToken); }, /*afterOperationDelegate*/ delegate { mLog.DebugFormat( "TokenExchange time {0} ms", Environment.TickCount - ini); if (waiter.Exception != null) { mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorTokenException; ExceptionsHandler.LogException( "TokenExchangeSetting", waiter.Exception); return; } if (response == null) { mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorResponseNull; Debug.Log("response null"); return; } if (response.Error != null) { mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorResponseError; mLog.ErrorFormat( "Unable to exchange token: {0} [code {1}]", response.Error.Message, response.Error.ErrorCode); return; } if (string.IsNullOrEmpty(response.AccessToken)) { mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ErrorTokenEmpty; mLog.InfoFormat( "Access token is empty for user: {0}", response.User); return; } mPlasticWindow.GetWelcomeView().autoLoginState = AutoLogin.State.ResponseEnd; sAccessToken = response.AccessToken; sUserName = response.User; GetOrganizationList(); }); }
internal static void FromUnityAccessToken( string unityAccessToken, RepositorySpec repSpec, string projectPath) { CredentialsResponse response = PlasticScmRestApiClient.GetCredentials( PlasticWebApiUris.GetBaseUri(), unityAccessToken); if (response.Error != null) { UnityEngine.Debug.LogErrorFormat( "Error getting credentials to download Cloud Project: {0} ({1})", response.Error.Message, response.Error.ErrorCode); return; } ClientConfigData configData = BuildClientConfigData( repSpec, projectPath, response); ClientConfig.Get().Save(configData); }
internal static void FromUnityAccessToken( string unityAccessToken, RepositorySpec repSpec, string projectPath) { CredentialsResponse response = PlasticScmRestApiClient.GetCredentials(unityAccessToken); if (response.Error != null) { UnityEngine.Debug.LogErrorFormat( PlasticLocalization.GetString(PlasticLocalization.Name.ErrorGettingCredentialsCloudProject), response.Error.Message, response.Error.ErrorCode); return; } ClientConfigData configData = BuildClientConfigData( repSpec, projectPath, response); ClientConfig.Get().Save(configData); }
internal void ExchangeTokens(string unityAccessToken) { int ini = Environment.TickCount; TokenExchangeResponse response = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(10); waiter.Execute( /*threadOperationDelegate*/ delegate { response = PlasticScmRestApiClient.TokenExchange(unityAccessToken); }, /*afterOperationDelegate*/ delegate { mLog.DebugFormat( "TokenExchange time {0} ms", Environment.TickCount - ini); if (waiter.Exception != null) { ExceptionsHandler.LogException( "TokenExchangeSetting", waiter.Exception); return; } if (response == null) { Debug.Log("response null"); return; } if (response.Error != null) { mLog.ErrorFormat( "Unable to exchange token: {0} [code {1}]", response.Error.Message, response.Error.ErrorCode); return; } if (string.IsNullOrEmpty(response.AccessToken)) { mLog.InfoFormat( "Access token is empty for user: {0}", response.User); return; } sAccessToken = response.AccessToken; sUserName = response.User; }); }
static void EnableUserBetaProgramIfNeeded(string unityAccessToken) { int ini = Environment.TickCount; UnityPackageBetaEnrollResponse response = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(10); waiter.Execute( /*threadOperationDelegate*/ delegate { response = PlasticScmRestApiClient.IsBetaEnabled(unityAccessToken); }, /*afterOperationDelegate*/ delegate { mLog.DebugFormat( "IsBetaEnabled time {0} ms", Environment.TickCount - ini); if (waiter.Exception != null) { ExceptionsHandler.LogException( "CalculateUserBetaProgramSetting", waiter.Exception); return; } if (response == null) { return; } if (response.Error != null) { mLog.ErrorFormat( "Unable to retrieve is beta enabled: {0} [code {1}]", response.Error.Message, response.Error.ErrorCode); return; } if (!response.IsBetaEnabled) { mLog.InfoFormat( "Beta is disabled for accessToken: {0}", unityAccessToken); return; } PlasticMenuItem.Add(); }); }
internal static void Run( Edition plasticEdition, string installerDestinationPath, ProgressControlsForViews progressControls) { ((IProgressControls)progressControls).ShowProgress("Downloading"); NewVersion plasticVersion = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(); waiter.Execute( /*threadOperationDelegate*/ delegate { plasticVersion = PlasticScmRestApiClient.GetLastVersion( PlasticWebApiUris.GetBaseUri(), plasticEdition); if (plasticVersion == null) { return; } string installerUrl = GetInstallerUrl( plasticVersion.Version, plasticEdition == Edition.Cloud); DownloadInstaller( installerUrl, installerDestinationPath, progressControls); if (!PlatformIdentifier.IsMac()) { return; } installerDestinationPath = UnZipMacOsPackage( installerDestinationPath); }, /*afterOperationDelegate*/ delegate { ((IProgressControls)progressControls).HideProgress(); if (waiter.Exception != null) { ((IProgressControls)progressControls).ShowError( waiter.Exception.Message); return; } if (plasticVersion == null) { ((IProgressControls)progressControls).ShowError( "There was an error connecting. Please check your internet."); return; } if (!File.Exists(installerDestinationPath)) { return; } RunInstaller( installerDestinationPath, progressControls); }); }
internal static void Run( Edition plasticEdition, string installerDestinationPath, ProgressControlsForViews progressControls) { ((IProgressControls)progressControls).ShowProgress( PlasticLocalization.GetString(PlasticLocalization.Name.DownloadingProgress)); NewVersionResponse plasticVersion = null; IThreadWaiter waiter = ThreadWaiter.GetWaiter(); waiter.Execute( /*threadOperationDelegate*/ delegate { plasticVersion = PlasticScmRestApiClient.GetLastVersion(plasticEdition); if (plasticVersion == null) { return; } string installerUrl = GetInstallerUrl( plasticVersion.Version, plasticEdition == Edition.Cloud); DownloadInstaller( installerUrl, installerDestinationPath, progressControls); if (!PlatformIdentifier.IsMac()) { return; } installerDestinationPath = UnZipMacOsPackage( installerDestinationPath); }, /*afterOperationDelegate*/ delegate { ((IProgressControls)progressControls).HideProgress(); if (waiter.Exception != null) { ((IProgressControls)progressControls).ShowError( waiter.Exception.Message); return; } if (plasticVersion == null) { ((IProgressControls)progressControls).ShowError( PlasticLocalization.GetString(PlasticLocalization.Name.ConnectingError)); return; } if (!File.Exists(installerDestinationPath)) { return; } RunInstaller( installerDestinationPath, progressControls); }); }