Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        internal static CredentialsResponse GetCredentials(
            string serverUrl,
            string unityToken)
        {
            Uri endpoint = PlasticWebApiUris.GetFullUri(
                new Uri(serverUrl),
                WebApiEndpoints.Authentication.Credentials,
                unityToken);

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(endpoint);
                request.Method      = "GET";
                request.ContentType = "application/json";

                return(GetResponse <CredentialsResponse>(request));
            }
            catch (Exception ex)
            {
                return(new CredentialsResponse
                {
                    Error = BuildLoggedErrorFields(ex, endpoint)
                });
            }
        }
Ejemplo n.º 3
0
        internal static NewVersion GetLastVersion(
            string serverUrl,
            Edition plasticEdition)
        {
            Uri endpoint = PlasticWebApiUris.GetFullUri(
                new Uri(serverUrl), string.Format(
                    WebApiEndpoints.LastVersion.NewVersion,
                    "9.0.0.0",
                    WebApiEndpoints.LastVersion.GetEditionString(plasticEdition),
                    WebApiEndpoints.LastVersion.GetPlatformString()));

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(endpoint);
                request.Method      = "GET";
                request.ContentType = "application/json";

                return(GetResponse <NewVersion>(request));
            }
            catch (Exception ex)
            {
                mLog.ErrorFormat(
                    "Unable to retrieve new versions from '{0}': {1}",
                    endpoint.ToString(), ex.Message);

                mLog.DebugFormat(
                    "StackTrace:{0}{1}",
                    Environment.NewLine, ex.StackTrace);

                return(null);
            }
        }
Ejemplo n.º 4
0
        void OnEnable()
        {
            if (mException != null)
            {
                return;
            }

            GuiMessage.Initialize(new UnityPlasticGuiMessage(this));

            ConfigureLogging();

            RegisterExceptionHandlers();
            RegisterApplicationFocusHandlers(this);

            InitLocalization();

            ThreadWaiter.Initialize(new UnityThreadWaiterBuilder());
            ServicePointConfigurator.ConfigureServicePoint();
            CertificateUi.RegisterHandler(new ChannelCertificateUiImpl());
            CredentialsUIRegistrar.RegisterCredentialsUI(
                new CredentialsUiImpl(this));
            ClientEncryptionServiceProvider.SetEncryptionPasswordProvider(
                new MissingEncryptionPasswordPromptHandler(this));
            DisableFsWatcherIfNeeded();
            EditionManager.Get().DisableCapability(
                EnumEditionCapabilities.Extensions);

            mPlasticAPI = new PlasticAPI();
            ClientHandlers.Register();

            PlasticGuiConfig.SetConfigFile(PLASTIC_GUI_CONFIG_FILE);

            mPingEventLoop      = new PingEventLoop();
            mEventSenderRestApi = new SimpleEventSenderRestApi(
                PlasticWebApiUris.GetBaseUri());
            mEventSenderScheduler = EventTracking.Configure(
                mEventSenderRestApi,
                ApplicationIdentifier.UnityPackage,
                IdentifyEventPlatform.Get());

            if (mEventSenderScheduler != null)
            {
                mPingEventLoop.Start();
            }

            InitializePlastic();
        }
Ejemplo n.º 5
0
        void OnEnable()
        {
            wantsMouseMove = true;

            if (mException != null)
            {
                return;
            }

            GuiMessage.Initialize(new UnityPlasticGuiMessage(this));

            PlasticApp.Initialize();

            RegisterApplicationFocusHandlers(this);

            CredentialsUIRegistrar.RegisterCredentialsUI(
                new CredentialsUiImpl(this));
            ClientEncryptionServiceProvider.SetEncryptionPasswordProvider(
                new MissingEncryptionPasswordPromptHandler(this));

            mPlasticAPI = new PlasticAPI();

            mPingEventLoop      = new PingEventLoop();
            mEventSenderRestApi = new SimpleEventSenderRestApi(
                PlasticWebApiUris.GetBaseUri());
            mEventSenderScheduler = EventTracking.Configure(
                mEventSenderRestApi,
                ApplicationIdentifier.UnityPackage,
                IdentifyEventPlatform.Get());

            if (mEventSenderScheduler != null)
            {
                mPingEventLoop.Start();
            }

            InitializePlastic();

            EditorApplication.update += AutoCommitOperation.AutoCommit;
        }
Ejemplo n.º 6
0
        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);
            });
        }