Пример #1
0
 /// Uninitializes the drive, cancelling any initialization that might be in progress.
 public async Task <bool> UninitializeAsync()
 {
     try
     {
         m_Uninitializing = true;
         m_Initialized    = false;
         m_HasSpaceQuota  = false;
         try
         {
             if (m_InitTask != null)
             {
                 m_InitTask.Cancel();
                 await m_InitTask.Task;
             }
         }
         catch (OperationCanceledException) { }
         m_InitTask    = null;
         m_Initialized = false;
         OnReadyChanged?.Invoke();
     }
     finally
     {
         m_Uninitializing = false;
     }
     return(true);
 }
Пример #2
0
        /// Initializes the Google Drive access.
        public async void InitializeDriveLinkAsync()
        {
            async Task InitializeAsync(CancellationToken token)
            {
                await m_GoogleUserSettings.InitializeAsync(token);

                m_DriveService = new DriveService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = m_GoogleIdentity.UserCredential,
                    ApplicationName       = App.kGoogleServicesAppName,
                });

                m_DeviceFolderId = await GetDeviceFolderAsync(token);

                m_Initialized = true;
                await RefreshFreeSpaceAsync(token);
            }

            if (!m_GoogleIdentity.LoggedIn)
            {
                return;
            }

            while (m_Uninitializing)
            {
                await new WaitForUpdate();
            }

            if (m_InitTask != null)
            {
                if (!await UninitializeAsync())
                {
                    return;
                }
            }

            m_InitTask      = new TaskAndCts();
            m_InitTask.Task = InitializeAsync(m_InitTask.Token);

            try
            {
                await m_InitTask.Task;
            }
            catch (OperationCanceledException)
            {
            }
            finally
            {
                m_InitTask = null;
            }

            if (Ready)
            {
                OnReadyChanged?.Invoke();
            }
        }
 private async Task CancelAuthorizationAsync()
 {
     if (m_Authorization != null)
     {
         m_Authorization.Cancel();
         try {
             await m_Authorization.Task;
         } catch (OperationCanceledException) {
         } finally {
             m_Authorization = null;
         }
     }
 }
        /// Authorizes the user. Must not be called when already authorizing.
        public async Task AuthorizeAsync()
        {
            await CancelAuthorizationAsync();

            // If we're currently revoking, just wait for it to finish.
            if (m_Revocation != null)
            {
                await m_Revocation;
            }
            try {
                m_Authorization      = new TaskAndCts <UserCredential>();
                m_Authorization.Task = m_AppFlow.AuthorizeAsync("user", m_Authorization.Token);
                m_UserCredential     = await m_Authorization.Task;
            } catch (OperationCanceledException) {
                // Do nothing with this exception as we only get it when the user cancels.
            } finally {
                m_Authorization = null;
            }
        }
Пример #5
0
        override public void SetPopupCommandParameters(int commandParam, int commandParam2)
        {
            if (commandParam2 != (int)SketchSetType.Drive)
            {
                return;
            }
            m_SketchIndex = commandParam;
            var sketchSet = SketchCatalog.m_Instance.GetSet(SketchSetType.Drive) as GoogleDriveSketchSet;

            m_SceneFileInfo =
                sketchSet.GetSketchSceneFileInfo(commandParam) as GoogleDriveSketchSet.GoogleDriveFileInfo;

            if (m_SceneFileInfo.Available)
            {
                return;
            }
            m_ProgressBar.material.SetFloat("_Ratio", 0);

            m_DownloadTask      = new TaskAndCts();
            m_DownloadTask.Task = m_SceneFileInfo.DownloadAsync(m_DownloadTask.Token);
        }