コード例 #1
0
 private void RecreateKitInstance()
 {
     if (kit == null)
     {
         if (!String.IsNullOrEmpty(Settings.Instance.Kit))
         {
             kit = KitUtils.ListImportedKits(Api)().Find(k => k.Name.Equals(Settings.Instance.Kit));
         }
     }
 }
コード例 #2
0
        private void InitiateUpdate(
            Action <float> reportProgress,
            Action <string> downloadComplete,
            Action <System.Exception> downloadError,
            Action verificationError,
            Func <bool> isCancelled
            )
        {
            Update.PeriodicPinger.Enqueue(new Analytics.Events.UpdateTakenEvent(KitUtils.AnalyticsStateString()));

            fabricInstaller.DownloadAndInstallPackage(
                new FabricInstaller.ReportInstallProgress(reportProgress),
                new FabricInstaller.DownloadComplete(downloadComplete),
                new FabricInstaller.DownloadError(downloadError),
                new FabricInstaller.VerificationError(verificationError),
                new FabricInstaller.IsCancelled(isCancelled)
                );
        }
コード例 #3
0
        private Action <KitsObject, ImportedKit, bool> SelectKit()
        {
            return(delegate(KitsObject availableKit, ImportedKit importedKit, bool checkForConflicts) {
                if (Update.PeriodicUpdateManager.IsPluginUpdateRequired(availableKit.Name))
                {
                    EditorUtility.DisplayDialog(
                        "A plugin update is required",
                        availableKit.Name + " requires a newer version of the Fabric Plugin, please update by clicking 'View Update'.",
                        "OK"
                        );
                    return;
                }

                Settings.Instance.Kit = availableKit.Name;

                if (importedKit != null && KitUtils.IsUpToDate(availableKit, importedKit))
                {
                    // Delegate to the kit's controller.
                    this.kit = importedKit;
                    Settings.Instance.FlowSequence = 0;
                    return;
                }

                // We need to download the latest version of the kit, because it's either not imported or needs updating.

                this.kit = null;
                Settings.Instance.FlowSequence = (int)UpdateFlow.Kit;

                FabricInstaller.Config config = new FabricInstaller.Config(
                    availableKit.PackageUrl,
                    availableKit.PackageName,
                    availableKit.ReleaseNotesUrl
                    );

                if (!checkForConflicts || !HasConflictingDependencies(Settings.Instance.Kit))
                {
                    ShowUpdatePage(() => { return config; }, UpdateFlow.Kit)();
                    return;
                }

                Settings.Instance.Conflict = Settings.Instance.Kit;
                ShowConflictPage();
            });
        }
コード例 #4
0
 public PluginController()
 {
     login        = new LoginPage(Login());
     orgs         = new OrganizationsPage(SelectOrganization(), FetchOrganizationsAsync);
     validation   = new ValidationPage(BackToKitSelection, SetSelectedKitConfigured);
     kitSelection = new KitSelectionPage(
         ListAvailableOnboardableKits,
         KitUtils.ListImportedKits(Api),
         SelectKit(),
         ActivationCheck,
         BackToOrganizations(),
         Update.PeriodicUpdateManager.IsPluginUpdateAvailable,
         ShowUpdatePage(() => { return(LatestPluginConfig); }, UpdateFlow.Plugin)
         );
     updatePage = new UpdatePage(InitiateUpdate, BackToKitSelection,
                                 delegate() {
         return(String.IsNullOrEmpty(Settings.Instance.Kit) ? "Fabric Plugin" : Settings.Instance.Kit);
     },
                                 delegate() {
         return(fabricInstaller.FetchReleaseNotes());
     }
                                 );
     conflictPage = new ConflictResolutionPage(
         (string conflictWith) => {
         Settings.Instance.Conflict = conflictWith;
         BackToKitSelection();
     },
         SelectKit(),
         ListAvailableOnboardableKits(),
         ConflictAgent,
         GetConflictingDependenciesFor
         );
     manualInitialization = new ManualInitializationPage(BackToKitSelection, (Settings.InitializationType type) => {
         Settings.Instance.Initialization = type;
     }, () => {
         Application.OpenURL("https://docs.fabric.io/unity/index.html");
     }, () => {
         return(Settings.Instance.Initialization);
     });
 }
コード例 #5
0
 public PluginController()
 {
     login        = new LoginPage(Login());
     orgs         = new OrganizationsPage(SelectOrganization(), FetchOrganizationsAsync);
     validation   = new ValidationPage(QueryForActivation(), ResetActivationStatus());
     kitSelection = new KitSelectionPage(
         ListAvailableKits,
         KitUtils.ListImportedKits(Api),
         DisplayedKitStatusAndVersion,
         SelectKit(),
         BackToOrganizations(),
         Update.PeriodicUpdateManager.IsPluginUpdateAvailable,
         ShowUpdatePage(() => { return(LatestPluginConfig); }, UpdateFlow.Plugin)
         );
     updatePage = new UpdatePage(InitiateUpdate, BackToKitSelection,
                                 delegate() {
         return(String.IsNullOrEmpty(Settings.Instance.Kit) ? "Fabric Plugin" : Settings.Instance.Kit);
     },
                                 delegate() {
         return(fabricInstaller.FetchReleaseNotes());
     }
                                 );
 }
コード例 #6
0
        public Page PageFromState()
        {
            UpdateInstalledKitStatus();

            if (NoAuthToken())
            {
                return(login);
            }

            if (NoOrganizationSelected())
            {
                return(orgs);
            }

            if (ManualInitializationFlow())
            {
                return(manualInitialization);
            }

            RecreateKitInstance();

            if (PluginUpdateInProgress() && Update.PeriodicUpdateManager.IsPluginUpdateAvailable() && NoKitSelected())
            {
                return(updatePage);
            }

            if (ConflictResolutionInProgress() || ConflictResolutionInProgressPostUpdate())
            {
                if (HasConflictingDependencies(ConflictAgent()))
                {
                    return(conflictPage);
                }

                OnAllConflictsResolved();
            }

            if (KitUpdateInProgress())
            {
                if (KitUtils.IsKitInstalled(Settings.Instance.Kit))
                {
                    return(OnKitUpdateCompleted());
                }

                if (kit != null && Update.PeriodicUpdateManager.IsKitUpdateAvailable(kit.Name, kit.Instance.Version()) || kit == null)
                {
                    return(updatePage);
                }
                else
                {
                    CleanKitUpgrade(kit.Name);

                    // Trigger the kit flow.
                    Settings.Instance.FlowSequence = 0;
                }
            }

            if (NoKitSelected())
            {
                if (Settings.Instance.FlowSequence == (int)UpdateFlow.Plugin || LegacyUpdateFlow())
                {
                    CleanPluginUpgrade();
                }

                Settings.Instance.FlowSequence = 0;
                return(kitSelection);
            }

            // At this point, the kit is selected. If it does not exist in the installed kits list,
            // add it.

            AddKitToKitsList(kit.Name);
            return(DelegateToKitController() ?? kitSelection);
        }
コード例 #7
0
        public Page PageFromState()
        {
            if (NoAuthToken())
            {
                return(login);
            }

            if (NoOrganizationSelected())
            {
                return(orgs);
            }

            if (KitIsActivated())
            {
                MarkKitAsInstalled();
            }

            RecreateKitInstance();

            if (PluginUpdateInProgress() && Update.PeriodicUpdateManager.IsPluginUpdateAvailable() && NoKitSelected())
            {
                return(updatePage);
            }

            if (KitUpdateInProgress())
            {
                if (KitUtils.IsKitInstalled(Settings.Instance.Kit))
                {
                    if (!Update.PeriodicUpdateManager.IsKitUpdateAvailable(kit.Name, kit.Instance.Version()))
                    {
                        // At this point, the upgrade is done for the given kit. Since this kit was previously
                        // installed, we do not need to go through the flow.

                        CleanKitUpgrade(kit.Name);
                        BackToKitSelection();
                        return(kitSelection);
                    }

                    // Waiting for the import to finish.
                    return(updatePage);
                }

                if (kit != null && Update.PeriodicUpdateManager.IsKitUpdateAvailable(kit.Name, kit.Instance.Version()) || kit == null)
                {
                    return(updatePage);
                }
                else
                {
                    CleanKitUpgrade(kit.Name);

                    // Trigger the kit flow.
                    Settings.Instance.FlowSequence = 0;
                }
            }

            if (NoKitSelected())
            {
                if (Settings.Instance.FlowSequence == (int)UpdateFlow.Plugin || LegacyUpdateFlow())
                {
                    CleanPluginUpgrade();
                }

                Settings.Instance.FlowSequence = 0;
                return(kitSelection);
            }

            Page page = null;
            KitControllerStatus status = kit.Instance.PageFromState(out page);

            switch (status)
            {
            case KitControllerStatus.NextPage:
                return(page);

            case KitControllerStatus.LastPage:
                return(validation);

            case KitControllerStatus.CurrentPage:
                Settings.Instance.Kit = "";
                break;
            }

            return(kitSelection);
        }