Пример #1
0
        protected override void StartSaveTask(long dbId, byte[] template, Guid guid, CancellationToken token)
        {
            // Make HTTP request
            HttpContent content = new ByteArrayContent(template);
            Task <HttpResponseMessage> saveResponse = m_Client.PostAsync(SimTemplateServerHelper.SaveTemplateUri(dbId), content);

            // When task is complete, raise GetCaptureComplete event
            // Pass the task the cancellation token so that this action may be skipped
            saveResponse.ContinueWith((Task <HttpResponseMessage> sTT) =>
            {
                // Check for cancellation (race)
                if (!token.IsCancellationRequested)
                {
                    // HTTP requests are not cancellable
                    IntegrityCheck.IsFalse(sTT.IsCanceled);
                    if (sTT.IsCompleted)
                    {
                        HttpResponseMessage response = sTT.Result;
                        // Do some dealing with the response to check it was successful
                        OnSaveTemplateComplete(
                            new SaveTemplateEventArgs(guid, DataRequestResult.Success));
                    }
                    else if (sTT.IsFaulted)
                    {
                        // An exception was thrown during the request.
                        Log.Error("Save Template task failed: " + sTT.Exception.Message, sTT.Exception);
                        OnSaveTemplateComplete(
                            new SaveTemplateEventArgs(guid, DataRequestResult.TaskFailed));
                    }
                }
            }, token);
        }
        public string this[string property]
        {
            get
            {
                String errorMessage = String.Empty;
                switch (property)
                {
                case "ApiKey":
                    if (!m_SettingsManager.ValidateQuerySetting(
                            Setting.ApiKey,
                            m_ApiKey.QueryValue))
                    {
                        errorMessage = m_SettingsManager.ValidationHelpText(Setting.ApiKey);
                    }
                    break;

                case "RootUrl":
                    if (!m_SettingsManager.ValidateQuerySetting(
                            Setting.RootUrl,
                            m_RootUrl.QueryValue))
                    {
                        errorMessage = m_SettingsManager.ValidationHelpText(Setting.RootUrl);
                    }
                    break;

                default:
                    throw IntegrityCheck.FailUnexpectedDefault(property);
                }
                return(errorMessage);
            }
        }
Пример #3
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Activity           currentActivity = (Activity)value;
            ResourceDictionary imageLookup     = (ResourceDictionary)parameter;

            ImageSource image;

            switch (currentActivity)
            {
            case Activity.Fault:
                image = (ImageSource)imageLookup["errorStatus"];
                break;

            case Activity.Loading:
            case Activity.Transitioning:
                image = (ImageSource)imageLookup["loadingStatus"];
                break;

            case Activity.Templating:
            case Activity.Idle:
            // TODO: uninitialised image?
            case Activity.Uninitialised:
                image = null;
                break;

            default:
                throw IntegrityCheck.FailUnexpectedDefault(currentActivity);
            }
            return(image);
        }
            protected override void OnOperationComplete(SaveTemplateEventArgs e)
            {
                switch (e.Result)
                {
                case DataRequestResult.Success:
                    Outer.PromptText = "Saved successfully";
                    // Save operation complete
                    // Clear the TemplatingViewModel of any leftover information
                    Outer.TemplatingViewModel.QuitTemplating();
                    // Now transition to Idle
                    TransitionTo(typeof(Idle));
                    break;

                case DataRequestResult.Failed:
                    Outer.PromptText = "Server failed to save";
                    // Save operation failed due to connection. Wait
                    TransitionTo(typeof(Templating));
                    break;

                case DataRequestResult.TaskFailed:
                    Outer.PromptText = "Application failed to save";
                    // Save operation failed due to bug. Transition to Fault
                    TransitionTo(typeof(Error));
                    break;

                default:
                    throw IntegrityCheck.FailUnexpectedDefault(e.Result);
                }
            }
Пример #5
0
        // TODO: Swap TemplatingViewModel for a TemplatingViewModelFactory
        // TODO: Swap SettingsViewModel for a SettingsViewModelFactory
        public MainWindowViewModel(
            IDataController dataController,
            ITemplatingViewModel templatingViewModel,
            ISettingsViewModel settingsViewModel,
            ISettingsManager settingsManager,
            IWindowService windowService,
            IDispatcherHelper dispatcherHelper)
        {
            IntegrityCheck.IsNotNull(dataController);
            IntegrityCheck.IsNotNull(templatingViewModel);
            IntegrityCheck.IsNotNull(settingsViewModel);
            IntegrityCheck.IsNotNull(settingsManager);
            IntegrityCheck.IsNotNull(windowService);
            IntegrityCheck.IsNotNull(dispatcherHelper);

            // Save arguments
            m_DataController      = dataController;
            m_TemplatingViewModel = templatingViewModel;
            m_SettingsViewModel   = settingsViewModel;
            m_SettingsManager     = settingsManager;
            m_WindowService       = windowService;
            m_DispatcherHelper    = dispatcherHelper;

            // Initialise the state machine
            m_StateLock = new object();
            m_StateMgr  = new StateManager <MainWindowState>(this, typeof(Uninitialised));

            // Configure commands/event handlers
            InitialiseCommands();
            m_DataController.InitialisationComplete  += DataController_InitialisationComplete;
            m_DataController.GetCaptureComplete      += DataController_GetCaptureComplete;
            m_DataController.SaveTemplateComplete    += DataController_SaveTemplateComplete;
            m_TemplatingViewModel.UserActionRequired += TemplatingViewModel_UserActionRequired;
        }
Пример #6
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ViewModelStatus status = (ViewModelStatus)value;

            bool?dialogResult = false;

            switch (status)
            {
            case ViewModelStatus.NoChange:
                dialogResult = false;
                break;

            case ViewModelStatus.Running:
                dialogResult = null;
                break;

            case ViewModelStatus.Complete:
                dialogResult = true;
                break;

            default:
                throw IntegrityCheck.FailUnexpectedDefault(status);
            }
            return(dialogResult);
        }
Пример #7
0
        private double ParseValue(object value)
        {
            IntegrityCheck.IsNotNull(value);
            double val;
            bool   isValSuccessful = double.TryParse((string)value, out val);

            IntegrityCheck.IsTrue(isValSuccessful);
            return(val);
        }
            public override void OnEnteringState()
            {
                base.OnEnteringState();

                Outer.PromptText = m_PromptText;

                m_Identifier = StartAsyncOperation();
                IntegrityCheck.IsNotNull(m_Identifier);
            }
Пример #9
0
        // TODO: Note that there is a contract here, CaptureComplete SHALL follow, in a timely manner
        Guid IDataController.BeginGetCapture(ScannerType scannerType)
        {
            Log.DebugFormat("BeginGetCapture(scannterType={0}) called",
                            scannerType);
            IntegrityCheck.IsNotNull(scannerType);

            return(StartLogic((Guid guid, CancellationToken token) =>
                              StartCaptureTask(scannerType, guid, token)));
        }
Пример #10
0
        private CaptureInfo GetCapture(ScannerType scannerType, CancellationToken token)
        {
            Log.DebugFormat("GetCapture(scannerType={0}, token={1}) called",
                            scannerType, token);
            CaptureInfo       captureInfo = null;
            DataRequestResult result      = DataRequestResult.None;
            bool isRunning = true;
            int  attempts  = 0;

            while (isRunning)
            {
                // Check if cancellation requested
                token.ThrowIfCancellationRequested();

                // First query the database to get an image file name.
                CaptureDb captureCandidate = GetCaptureFromDatabase(scannerType);

                if (captureCandidate != null)
                {
                    // Try to find an image file using the file name.
                    byte[] imageData;
                    bool   isFound = TryGetImageFromName(captureCandidate.HumanId, out imageData);
                    if (isFound)
                    {
                        // Matching file found.
                        Log.DebugFormat("Matching file found for capture={0}", captureCandidate.HumanId);
                        isRunning   = false;
                        captureInfo = new CaptureInfo(
                            captureCandidate.Id,
                            imageData,
                            captureCandidate.GoldTemplate);
                        result = DataRequestResult.Success;
                    }
                    else
                    {
                        // Give up if the number of attemps exceeds limit.
                        attempts++;
                        if (attempts > MAX_OPEN_FILE_ATTEMPTS)
                        {
                            Log.WarnFormat("Exceeded maximum number of file searches (attempts={0})",
                                           attempts);
                            isRunning = false;
                            result    = DataRequestResult.Failed;
                        }
                    }
                }
                else
                {
                    // Queries are not returning any more candidates, give up immediately.
                    Log.Warn("No candidate filename obtained from the database");
                    result = DataRequestResult.Failed;
                    break;
                }
            }
            IntegrityCheck.AreNotEqual(DataRequestResult.None, result);
            return(captureInfo);
        }
        private void RunIntegrityCheck_OnClick(object s, RoutedEventArgs e)
        {
            var window   = new IntegrityCheckProgressWindow();
            var progress = new Progress <IntegrityCheck.IntegrityCheckProgress>();

            progress.ProgressChanged += (sender, checkProgress) => window.UpdateProgress(checkProgress);

            var gamePath = new DirectoryInfo(ViewModel.GamePath);

            if (Repository.Ffxiv.IsBaseVer(gamePath))
            {
                CustomMessageBox.Show(Loc.Localize("IntegrityCheckBase", "The game is not installed to the path you specified.\nPlease install the game before running an integrity check."), "XIVLauncher", parentWindow: Window.GetWindow(this));
                return;
            }

            Task.Run(async() => await IntegrityCheck.CompareIntegrityAsync(progress, gamePath)).ContinueWith(task =>
            {
                window.Dispatcher.Invoke(() => window.Close());

                string saveIntegrityPath = Path.Combine(Paths.RoamingPath, "integrityreport.txt");
#if DEBUG
                Log.Information("Saving integrity to " + saveIntegrityPath);
#endif
                File.WriteAllText(saveIntegrityPath, task.Result.report);

                this.Dispatcher.Invoke(() =>
                {
                    switch (task.Result.compareResult)
                    {
                    case IntegrityCheck.CompareResult.ReferenceNotFound:
                        CustomMessageBox.Show(Loc.Localize("IntegrityCheckImpossible",
                                                           "There is no reference report yet for this game version. Please try again later."),
                                              "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Asterisk, parentWindow: Window.GetWindow(this));
                        return;

                    case IntegrityCheck.CompareResult.ReferenceFetchFailure:
                        CustomMessageBox.Show(Loc.Localize("IntegrityCheckNetworkError",
                                                           "Failed to download reference files for checking integrity. Check your internet connection and try again."),
                                              "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Error, parentWindow: Window.GetWindow(this));
                        return;

                    case IntegrityCheck.CompareResult.Invalid:
                        CustomMessageBox.Show(Loc.Localize("IntegrityCheckFailed",
                                                           "Some game files seem to be modified or corrupted. \n\nIf you use TexTools mods, this is an expected result.\n\nIf you do not use mods, right click the \"Login\" button on the XIVLauncher start page and choose \"Repair game\"."),
                                              "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Exclamation, showReportLinks: true, parentWindow: Window.GetWindow(this));
                        break;

                    case IntegrityCheck.CompareResult.Valid:
                        CustomMessageBox.Show(Loc.Localize("IntegrityCheckValid", "Your game install seems to be valid."), "XIVLauncher", MessageBoxButton.OK,
                                              MessageBoxImage.Asterisk, parentWindow: Window.GetWindow(this));
                        break;
                    }
                });
            });

            window.ShowDialog();
        }
        public TemplatingViewModel(IDispatcherHelper dispatcherHelper)
        {
            IntegrityCheck.IsNotNull(dispatcherHelper);

            m_DispatcherHelper = dispatcherHelper;

            m_StateLock = new object();
            Minutae     = new TrulyObservableCollection <MinutiaRecord>();
            m_StateMgr  = new StateManager <TemplatingState>(this, typeof(Uninitialised));
        }
Пример #13
0
        public static void RegisterPhoneNumberProvider <T>(Expression <Func <T, string> > phoneExpression, Expression <Func <T, CultureInfo> > cultureExpression) where T : Entity
        {
            phoneNumberProviders[typeof(T)] = phoneExpression;
            cultureProviders[typeof(T)]     = cultureExpression;

            new Graph <ProcessEntity> .ConstructFromMany <T>(SMSMessageOperation.SendSMSMessages)
            {
                Construct = (providers, args) =>
                {
                    var numbers = Database.Query <T>().Where(p => providers.Contains(p.ToLite()))
                                  .Select(pr => new { Exp = phoneExpression.Evaluate(pr), Referred = pr.ToLite() }).AsEnumerable().NotNull().Distinct().ToList();

                    var splitNumbers = (from p in numbers.Where(p => p.Exp.Contains(','))
                                        from n in p.Exp.Split('n')
                                        select new { Exp = n.Trim(), p.Referred }).Concat(numbers.Where(p => !p.Exp.Contains(','))).Distinct().ToList();

                    numbers = splitNumbers;

                    MultipleSMSModel model = args.GetArg <MultipleSMSModel>();

                    IntegrityCheck ic = model.IntegrityCheck();

                    if (!model.Message.HasText())
                    {
                        throw new ApplicationException("The text for the SMS message has not been set");
                    }

                    SMSSendPackageEntity package = new SMSSendPackageEntity().Save();

                    var packLite = package.ToLite();

                    using (OperationLogic.AllowSave <SMSMessageEntity>())
                        numbers.Select(n => new SMSMessageEntity
                        {
                            DestinationNumber = n.Exp,
                            SendPackage       = packLite,
                            Referred          = n.Referred,

                            Message   = model.Message,
                            From      = model.From,
                            Certified = model.Certified,
                            State     = SMSMessageState.Created,
                        }).SaveList();

                    var process = ProcessLogic.Create(SMSMessageProcess.Send, package);

                    process.Execute(ProcessOperation.Execute);

                    return(process);
                }
            }

            .Register();
        }
Пример #14
0
            public override void OnEnteringState()
            {
                base.OnEnteringState();

                Outer.OnUserActionRequired(new UserActionRequiredEventArgs(SET_ANGLE_PROMPT));

                // Get the minutia that was placed in the previous step
                IntegrityCheck.AreNotEqual(0, Outer.Minutae.Count());
                m_Record = Outer.Minutae.Last();
                IntegrityCheck.IsNotNull(m_Record.Position);
            }
            public override void PositionUpdate(Point position)
            {
                IntegrityCheck.IsNotNull(position);

                lock (Outer.m_SelectedMinutiaLock)
                {
                    IntegrityCheck.IsNotNull(Outer.m_SelectedMinutia.HasValue);
                    // Set position
                    Outer.Minutae[Outer.m_SelectedMinutia.Value].Position = position;
                }
            }
Пример #16
0
        // TODO: Note that there is a contract here, InitialisedComplete SHALL follow, in a timely manner
        Guid IDataController.BeginInitialise(DataControllerConfig config)
        {
            Log.Debug("BeginInitialise(...) called.");
            IntegrityCheck.IsNotNull(config, "config");
            IntegrityCheck.IsNotNullOrEmpty(config.ApiKey, "config.ApiKey");
            IntegrityCheck.IsNotNullOrEmpty(config.UrlRoot, "config.UrlRoot");

            m_Config = config;
            m_TokenSourceLookup.Clear();

            return(StartLogic((Guid guid, CancellationToken token) =>
                              StartInitialiseTask(config, guid, token)));
        }
Пример #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GetCaptureCompleteEventArgs"/> class in
        /// the case where the request was successful.
        /// </summary>
        /// <param name="capture">The capture.</param>
        /// <param name="requestId">The request unique identifier.</param>
        public GetCaptureCompleteEventArgs(CaptureInfo capture, Guid requestId, DataRequestResult result)
        {
            IntegrityCheck.IsNotNull(requestId);
            IntegrityCheck.IsNotNull(result);
            if (result == DataRequestResult.Success)
            {
                IntegrityCheck.IsNotNull(capture);
            }

            m_Capture   = capture;
            m_RequestId = requestId;
            m_Result    = result;
        }
Пример #18
0
        public MainWindow()
        {
            IntegrityCheck.Run();

            Icon = MediaConverter.ImageSourceFromBitmap(Properties.Resources.Fire.ToBitmap());
            InitializeComponent();

            nvFrom.OnFormSubmit     += NvFrom_OnFormSubmit;
            core.RunWorkerCompleted += Core_RunWorkerCompleted;
            Loaded += MainWindow_Loaded;

            SetupLog();
        }
        private void RunIntegrityCheck_OnClick(object s, RoutedEventArgs e)
        {
            var window   = new IntegrityCheckProgressWindow();
            var progress = new Progress <IntegrityCheck.IntegrityCheckProgress>();

            progress.ProgressChanged += (sender, checkProgress) => window.UpdateProgress(checkProgress);

            Task.Run(async() => await IntegrityCheck.CompareIntegrityAsync(progress, App.Settings.GamePath)).ContinueWith(task =>
            {
                window.Dispatcher.Invoke(() => window.Close());

                switch (task.Result.compareResult)
                {
                case IntegrityCheck.CompareResult.NoServer:
                    MessageBox.Show(Loc.Localize("IntegrityCheckImpossible",
                                                 "There is no reference report yet for this game version. Please try again later."),
                                    "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                    return;

                case IntegrityCheck.CompareResult.Invalid:
                    {
                        File.WriteAllText("integrityreport.txt", task.Result.report);
                        var result = MessageBox.Show(Loc.Localize("IntegrityCheckFailed",
                                                                  "Some game files seem to be modified or corrupted. Please check the \"integrityreport.txt\" file in the XIVLauncher folder for more information.\n\nDo you want to reset the game to the last patch? This will allow you to patch it again, likely fixing the issues you are encountering."),
                                                     "XIVLauncher", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);

                        if (result == MessageBoxResult.Yes)
                        {
                            var verFile = Path.Combine(App.Settings.GamePath.FullName, "game", "ffxivgame.ver");

                            File.Delete(verFile);
                            File.WriteAllText(verFile, task.Result.remoteIntegrity.LastGameVersion);

                            Process.Start(Path.Combine(ViewModel.GamePath, "boot", "ffxivboot.exe"));
                            Environment.Exit(0);
                        }

                        break;
                    }

                case IntegrityCheck.CompareResult.Valid:
                    MessageBox.Show(Loc.Localize("IntegrityCheckValid", "Your game install seems to be valid."), "XIVLauncher", MessageBoxButton.OK,
                                    MessageBoxImage.Asterisk);
                    break;
                }
            });

            window.ShowDialog();
        }
Пример #20
0
        private void ViewModel_ActivityChanged(object sender, ActivityChangedEventArgs e)
        {
            // Set the Status Image
            ImageSource statusImageSource;

            switch (e.NewActivity)
            {
            case Activity.Fault:
                statusImageSource = (ImageSource)mainWindow.Resources["errorStatus"];
                break;

            case Activity.Loading:
            case Activity.Transitioning:
                statusImageSource = (ImageSource)mainWindow.Resources["loadingStatus"];
                break;

            case Activity.Templating:
            case Activity.Idle:
            // TODO: uninitialised image?
            case Activity.Uninitialised:
                statusImageSource = null;
                break;

            default:
                throw IntegrityCheck.FailUnexpectedDefault(e.NewActivity);
            }

            // Load File icon
            ImageSource loadFileIcon;

            if (e.NewActivity == Activity.Loading)
            {
                loadFileIcon = (ImageSource)mainWindow.Resources["cancelIcon"];
            }
            else
            {
                loadFileIcon = (ImageSource)mainWindow.Resources["loadIcon"];
            }

            // Update UI element on application thread
            m_ViewModel.DispatcherHelper.Invoke(new Action(() =>
            {
                statusImage.Source = statusImageSource;
                ((System.Windows.Controls.Image)loadFile.Content).Source = loadFileIcon;
            }));
        }
Пример #21
0
        public StateManager(ViewModel viewModel, Type initialStateType)
        {
            IntegrityCheck.IsNotNull(viewModel);

            m_ViewModel = viewModel;

            // Instantiate all concrete states into a list for transitioning to.
            m_States = new Dictionary <Type, T>();
            foreach (Type type in Assembly.GetAssembly(typeof(T)).GetTypes()
                     .Where(myType =>
                            myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T))))
            {
                m_States.Add(type, (T)Activator.CreateInstance(type, m_ViewModel));
            }

            // Transition to the initial state.
            TransitionTo(initialStateType);
        }
Пример #22
0
        protected override void StartCaptureTask(ScannerType scannerType, Guid guid, CancellationToken token)
        {
            Log.DebugFormat("Starting task with Guid={0}", guid);

            // Make HTTP request
            Task <string> responseText = m_Client.GetStringAsync(
                SimTemplateServerHelper.GetCaptureRequestUri(scannerType));

            // When task is complete, raise GetCaptureComplete event
            // Pass the task the cancellation token so that this action may be skipped
            responseText.ContinueWith((Task <string> gCT) =>
            {
                // Check for cancellation (race)
                if (!token.IsCancellationRequested)
                {
                    // HTTP requests are not cancellable
                    IntegrityCheck.IsFalse(gCT.IsCanceled);
                    if (gCT.IsCompleted)
                    {
                        CaptureInfo capture;
                        try
                        {
                            capture = ProcessResponse(gCT.Result);
                            OnGetCaptureComplete(
                                new GetCaptureCompleteEventArgs(capture, guid, DataRequestResult.Success));
                        }
                        catch (SimTemplateException ex)
                        {
                            Log.Error("Failed to process xml response:", ex);
                            OnGetCaptureComplete(
                                new GetCaptureCompleteEventArgs(null, guid, DataRequestResult.Failed));
                        }
                    }
                    else if (gCT.IsFaulted)
                    {
                        // An exception was thrown during the request.
                        Log.Error("GetCapture task failed: " + gCT.Exception.Message, gCT.Exception);
                        OnGetCaptureComplete(
                            new GetCaptureCompleteEventArgs(null, guid, DataRequestResult.TaskFailed));
                    }
                }
            }, token);
        }
Пример #23
0
        private T ToState(Type stateType)
        {
            IntegrityCheck.IsTrue(
                typeof(T).IsAssignableFrom(stateType),
                "Supplied type doesn't derive from {0}", typeof(T).Name);
            IntegrityCheck.IsFalse(
                stateType.IsAbstract,
                "Cannot transition to abstract state {0}", stateType.Name);

            T    state;
            bool isFound = m_States.TryGetValue(stateType, out state);

            IntegrityCheck.IsTrue(isFound, "State {0} not found in m_States", stateType.Name);
            IntegrityCheck.IsNotNull(
                state,
                "State {0} found in m_States, but value was null",
                stateType.Name);

            return(state);
        }
        private void image_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            m_Log.Debug("image_SizeChanged(...) called.");

            if (image.Source != null)
            {
                // Image has been resized.
                // Get scaling in each dimension.
                double scaleX = e.NewSize.Width / image.Source.Width;
                double scaleY = e.NewSize.Height / image.Source.Height;
                // Check that scaling factor is equal for each dimension.
                Scale = new Vector(scaleX, scaleY);
            }
            else
            {
                // Image has been removed.
                IntegrityCheck.AreEqual(0, e.NewSize.Height);
                IntegrityCheck.AreEqual(0, e.NewSize.Width);
            }
        }
Пример #25
0
        private void RunIntegrityCheck_OnClick(object s, RoutedEventArgs e)
        {
            var window   = new IntegrityCheckProgressWindow();
            var progress = new Progress <IntegrityCheck.IntegrityCheckProgress>();

            progress.ProgressChanged += (sender, checkProgress) => window.UpdateProgress(checkProgress);

            var gamePath = new DirectoryInfo(ViewModel.GamePath);

            Task.Run(async() => await IntegrityCheck.CompareIntegrityAsync(progress, gamePath)).ContinueWith(task =>
            {
                window.Dispatcher.Invoke(() => window.Close());

                switch (task.Result.compareResult)
                {
                case IntegrityCheck.CompareResult.NoServer:
                    CustomMessageBox.Show(Loc.Localize("IntegrityCheckImpossible",
                                                       "There is no reference report yet for this game version. Please try again later."),
                                          "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                    return;

                case IntegrityCheck.CompareResult.Invalid:
                    {
                        File.WriteAllText("integrityreport.txt", task.Result.report);
                        CustomMessageBox.Show(Loc.Localize("IntegrityCheckFailed",
                                                           "Some game files seem to be modified or corrupted. Please check the \"integrityreport.txt\" file in the XIVLauncher folder for more information.\n\nIf you use TexTools mods, this is an expected result.\n\nIf you do not use mods, please reinstall your game."),
                                              "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                        break;
                    }

                case IntegrityCheck.CompareResult.Valid:
                    CustomMessageBox.Show(Loc.Localize("IntegrityCheckValid", "Your game install seems to be valid."), "XIVLauncher", MessageBoxButton.OK,
                                          MessageBoxImage.Asterisk);
                    break;
                }
            });

            window.ShowDialog();
        }
Пример #26
0
        void IDataController.AbortRequest(Guid guid)
        {
            Log.DebugFormat("AbortRequest(guid={0}) called.", guid);
            IntegrityCheck.IsNotNull(guid);

            // Attempt to lookup the token.
            CancellationTokenSource tokenSource;
            bool isSuccessful = m_TokenSourceLookup.TryGetValue(guid, out tokenSource);

            if (isSuccessful)
            {
                // Request cancellation.
                IntegrityCheck.IsNotNull(tokenSource);
                tokenSource.Cancel();
                m_TokenSourceLookup.Remove(guid);
            }
            else
            {
                // TODO: What to do if Guid doesn't correspond to a current request?
                Log.WarnFormat("Cancellation of request (guid={0}) failed, token no longer exists.",
                               guid);
            }
        }
Пример #27
0
            protected override void OnOperationComplete(GetCaptureCompleteEventArgs e)
            {
                // We have recieved a response from our request.
                // Indicate we are no longer loading.

                switch (e.Result)
                {
                case DataRequestResult.Success:
                    IntegrityCheck.IsNotNull(e.Capture);

                    Outer.PromptText = "Capture loaded";
                    Outer.m_TemplatingViewModel.BeginTemplating(e.Capture);
                    TransitionTo(typeof(Templating));
                    break;

                case DataRequestResult.Failed:
                    // No capture was obtained.
                    Outer.PromptText = "No capture matching the criteria obtained.";
                    Log.DebugFormat(
                        "Capture request returned Failed response.",
                        Outer.FilteredScannerType);
                    TransitionTo(typeof(Idle));
                    break;

                case DataRequestResult.TaskFailed:
                    // No capture was obtained.
                    Outer.PromptText = "App failed to carry out capture request.";
                    Log.ErrorFormat(
                        "Capture request returned TaskFailed response.",
                        Outer.FilteredScannerType);
                    TransitionTo(typeof(Idle));
                    break;

                default:
                    throw IntegrityCheck.FailUnexpectedDefault(e.Result);
                }
            }
Пример #28
0
 private void UpdateIntegrityCheck()
 {
     IntegrityCheck.Update();
 }
 public override void DataController_InitialisationComplete(InitialisationCompleteEventArgs e)
 {
     throw IntegrityCheck.Fail(
               "Not expected to have DataController.InitialisationComplete event when in error.");
 }
        internal static string GetTroubleshootingJson()
        {
            var gamePath = App.Settings.GamePath;

            var integrity = TroubleshootingPayload.IndexIntegrityResult.Success;

            try
            {
                if (!gamePath.Exists || !gamePath.GetDirectories().Any(x => x.Name == "game"))
                {
                    integrity = TroubleshootingPayload.IndexIntegrityResult.NoGame;
                }
                else
                {
                    var result = IntegrityCheck.CompareIntegrityAsync(null, gamePath, true).Result;

                    integrity = result.compareResult switch
                    {
                        IntegrityCheck.CompareResult.ReferenceFetchFailure => TroubleshootingPayload.IndexIntegrityResult.ReferenceFetchFailure,
                        IntegrityCheck.CompareResult.ReferenceNotFound => TroubleshootingPayload.IndexIntegrityResult.ReferenceNotFound,
                        IntegrityCheck.CompareResult.Invalid => TroubleshootingPayload.IndexIntegrityResult.Failed,
                        _ => integrity
                    };
                }
            }
            catch (Exception)
            {
                integrity = TroubleshootingPayload.IndexIntegrityResult.Exception;
            }

            var ffxivVer    = Repository.Ffxiv.GetVer(gamePath);
            var ffxivVerBck = Repository.Ffxiv.GetVer(gamePath, true);
            var ex1Ver      = Repository.Ex1.GetVer(gamePath);
            var ex1VerBck   = Repository.Ex1.GetVer(gamePath, true);
            var ex2Ver      = Repository.Ex2.GetVer(gamePath);
            var ex2VerBck   = Repository.Ex2.GetVer(gamePath, true);
            var ex3Ver      = Repository.Ex3.GetVer(gamePath);
            var ex3VerBck   = Repository.Ex3.GetVer(gamePath, true);
            var ex4Ver      = Repository.Ex4.GetVer(gamePath);
            var ex4VerBck   = Repository.Ex4.GetVer(gamePath, true);

            var payload = new TroubleshootingPayload
            {
                When                  = DateTime.Now,
                IsDx11                = App.Settings.IsDx11,
                IsAutoLogin           = App.Settings.AutologinEnabled,
                IsUidCache            = App.Settings.UniqueIdCacheEnabled,
                DalamudEnabled        = App.Settings.InGameAddonEnabled,
                DalamudLoadMethod     = App.Settings.InGameAddonLoadMethod.GetValueOrDefault(),
                DalamudInjectionDelay = App.Settings.DalamudInjectionDelayMs,
                EncryptArguments      = App.Settings.EncryptArguments.GetValueOrDefault(true),
                LauncherVersion       = AppUtil.GetAssemblyVersion(),
                LauncherHash          = AppUtil.GetGitHash(),
                Official              = AppUtil.GetBuildOrigin() == "goatcorp/FFXIVQuickLauncher",
                DpiAwareness          = App.Settings.DpiAwareness.GetValueOrDefault(),
                Platform              = Util.GetPlatform(),

                ObservedGameVersion = ffxivVer,
                ObservedEx1Version  = ex1Ver,
                ObservedEx2Version  = ex2Ver,
                ObservedEx3Version  = ex3Ver,
                ObservedEx4Version  = ex4Ver,

                BckMatch = ffxivVer == ffxivVerBck && ex1Ver == ex1VerBck && ex2Ver == ex2VerBck &&
                           ex3Ver == ex3VerBck && ex4Ver == ex4VerBck,

                IndexIntegrity = integrity
            };

            return(JsonConvert.SerializeObject(payload));
        }