Exemple #1
0
        public Tasker.Conclusion ExportGames(Tasker tasker, Object syncObject = null)
        {
            // get specialized view
            transferForm = tasker.GetSpecificViews <TaskerTransferForm>().First();

            // set up progress bar
            tasker.SetTitle(Resources.ExportGames);
            tasker.SetState(Tasker.State.Starting);
            tasker.SetStatusImage(Resources.sign_up);

            // safeguard
            if (Games == null || Games.Count == 0)
            {
                return(Tasker.Conclusion.Error);
            }

            // add sub-tasks
            tasker.AddTask(ShowExportDialog, 0);
            tasker.AddTask(BuildMenu, 0);
            tasker.AddTask(BuildFiles, 1);
            tasker.AddTask(CheckLocalStorageRequirements, 1);
            tasker.AddTask(CalculateLocalDiff, 1);
            tasker.AddTask(SyncLocalGames, 12);

            return(Tasker.Conclusion.Success);
        }
Exemple #2
0
        public static Conclusion WaitForShellCycle(Tasker tasker, Object syncObject = null, int maxWaitTime = -1, string title = null, string message = null)
        {
            var hostForm = tasker.GetSpecificViews <Form>().FirstOrDefault();

            if (hostForm == default(Form))
            {
                hostForm = tasker.HostForm;
            }
            if (hostForm.InvokeRequired)
            {
                return((Conclusion)hostForm.Invoke(new Func <Tasker, object, int, string, string, Conclusion>(WaitForShellCycle), new object[] { tasker, syncObject, maxWaitTime, title, message }));
            }

            tasker.SetStatus(Resources.WaitingForDevice);
            tasker.PushState(State.Waiting);
            var result = WaitingShellCycleForm.WaitForDevice(hostForm, maxWaitTime == -1 ? MembootWaitDelay : maxWaitTime);

            tasker.PopState();
            if (result == DialogResult.OK)
            {
                return(Conclusion.Success);
            }
            else if (result == DialogResult.No)
            {
                MessageForm.Show(hostForm, title == null ? Resources.WaitingForDevice : title, message == null ? Resources.WaitingForDeviceTakingALongTime : message, Resources.sign_clock);
            }

            return(Conclusion.Abort);
        }
Exemple #3
0
        public static Conclusion WaitForShellCycle(Tasker tasker, Object syncObject = null)
        {
            var hostForm = tasker.GetSpecificViews <Form>().FirstOrDefault();

            if (hostForm == default(Form))
            {
                hostForm = tasker.HostForm;
            }
            if (hostForm.InvokeRequired)
            {
                return((Conclusion)hostForm.Invoke(new Func <Tasker, object, Conclusion>(WaitForShellCycle), new object[] { tasker, syncObject }));
            }

            tasker.SetStatus(Resources.WaitingForDevice);
            tasker.PushState(State.Waiting);
            var result = WaitingShellCycleForm.WaitForDevice(hostForm, MembootWaitDelay);

            tasker.PopState();
            if (result == DialogResult.OK)
            {
                return(Conclusion.Success);
            }

            return(Conclusion.Abort);
        }
        public Conclusion WaitForFelOrMembootableShell(Tasker tasker, Object syncObject = null)
        {
            var hostForm = tasker.GetSpecificViews<Form>().FirstOrDefault();
            if (hostForm == default(Form))
                hostForm = tasker.HostForm;
            if (hostForm.InvokeRequired)
            {
                return (Conclusion)hostForm.Invoke(new Func<Tasker, Object, Conclusion>(WaitForFelOrMembootableShell), new object[] { tasker, syncObject });
            }

            tasker.SetStatus(Resources.WaitingForDevice);
            if (hakchi.Shell.IsOnline && hakchi.Shell.Execute("[ -f /proc/atags ]") == 0)
                return Conclusion.Success;

            if (!WaitingFelForm.WaitForDevice(Shared.ClassicUSB.vid, Shared.ClassicUSB.pid, hostForm))
                return Conclusion.Abort;

            fel.Fes1Bin = Resources.fes1;
            if (ConfigIni.Instance.MembootUboot == Fel.UbootType.SD)
            {
                fel.UBootBin = Resources.ubootSD;
            }
            else
            {
                fel.UBootBin = Resources.uboot;
            }
            if (!fel.Open(Shared.ClassicUSB.vid, Shared.ClassicUSB.pid))
                throw new FelException("Can't open device");
            tasker.SetStatus(Resources.UploadingFes1);
            fel.InitDram(true);
            return Conclusion.Success;
        }
Exemple #5
0
        public Conclusion GetStockKernel(Tasker tasker, Object syncObject = null)
        {
            var hostForm = tasker.GetSpecificViews <Form>().FirstOrDefault();

            if (hostForm == default(Form))
            {
                hostForm = tasker.HostForm;
            }
            if (hostForm.InvokeRequired)
            {
                return((Conclusion)hostForm.Invoke(new Func <Tasker, Object, Conclusion>(GetStockKernel), new object[] { tasker, syncObject }));
            }

            tasker.SetStatus(Resources.DumpingKernel);
            stockKernel = new MemoryStream();

            if ((!ignoreBackupKernel) && hakchi.Shell.Execute("hakchi getBackup2", null, stockKernel) == 0)
            {
                return(Conclusion.Success);
            }
            else
            {
                using (OpenFileDialog ofd = new OpenFileDialog())
                {
                    ofd.Filter           = $"{Resources.KernelDump}|*.img";
                    ofd.InitialDirectory = Shared.PathCombine(Program.BaseDirectoryExternal, "dump");
                    if (ofd.ShowDialog(hostForm) == DialogResult.OK)
                    {
                        if (File.OpenRead(ofd.FileName).Length <= Fel.kernel_max_size)
                        {
                            byte[] kernelBytes = File.ReadAllBytes(ofd.FileName);

                            var md5            = System.Security.Cryptography.MD5.Create();
                            var hash           = BitConverter.ToString(md5.ComputeHash(kernelBytes)).Replace("-", "").ToLower();
                            var matchedKernels = from k in correctKernels where k.Value.Contains(hash) select k.Key;
                            if (matchedKernels.Count() > 0)
                            {
                                stockKernel = new MemoryStream(kernelBytes);
                                return(Conclusion.Success);
                            }
                        }
                        MessageForm.Show(hostForm, Resources.Error, Resources.DumpOriginalKernelInvalid, Resources.sign_error);
                    }
                    else
                    {
                        return(Conclusion.Abort);
                    }
                }
            }
            return(Conclusion.Error);
        }
Exemple #6
0
        public Tasker.Conclusion UploadGames(Tasker tasker, Object syncObject = null)
        {
            // get specialized view
            transferForm = tasker.GetSpecificViews <TaskerTransferForm>().First();

            // set up progress bar
            tasker.SetTitle(Resources.UploadGames);
            tasker.SetState(Tasker.State.Starting);
            tasker.SetStatusImage(Resources.sign_up);

            // safeguards
            if (!hakchi.Shell.IsOnline || Games == null || Games.Count == 0)
            {
                return(Tasker.Conclusion.Error);
            }

            // set up upload path
            if (ConfigIni.Instance.UploadToTmp)
            {
                uploadPath = remoteTempDirectory;
            }
            else
            {
                uploadPath = hakchi.GetRemoteGameSyncPath(ConfigIni.Instance.ConsoleType);
            }

            // add sub-tasks
            tasker.AddTask(BuildMenu, 0);
            tasker.AddTask(BuildFiles, 1);
            tasker.AddTask(CheckRemoteStorageRequirements, 1);
            tasker.AddTask(PrepareRemoteTransfer, 1);
            tasker.AddTask(CalculateRemoteDiff, 1);
            if (ConfigIni.Instance.ForceSSHTransfers || hakchi.Shell is clovershell.ClovershellConnection)
            {
                tasker.AddTask(SyncRemoteGamesShell, 28);
            }
            else if (hakchi.Shell is INetworkShell)
            {
                tasker.AddTask(SyncRemoteGamesFTP, 28);
            }
            tasker.AddTask(RemoteCleanup, 1);
            tasker.AddTask(LinkGames, 1);
            tasker.AddTask(ShellTasks.SyncConfig, 1);

            return(Tasker.Conclusion.Success);
        }
Exemple #7
0
        private Conclusion WaitForFelOrMembootableShell(Tasker tasker, Object syncObject = null, bool sdRequired = false)
        {
            var hostForm = tasker.GetSpecificViews <Form>().FirstOrDefault();

            if (hostForm == default(Form))
            {
                hostForm = tasker.HostForm;
            }
            if (hostForm.InvokeRequired)
            {
                return((Conclusion)hostForm.Invoke(new Func <Tasker, Object, bool, Conclusion>(WaitForFelOrMembootableShell), new object[] { tasker, syncObject, sdRequired }));
            }

            tasker.SetStatus(Resources.WaitingForDevice);
            if (hakchi.Shell.IsOnline && hakchi.Shell.Execute("[ -f /proc/atags ]") == 0)
            {
                if (sdRequired)
                {
                    if (hakchi.Shell.Execute("hakchi mmcUsed") == 0)
                    {
                        return(Conclusion.Success);
                    }
                }
                else
                {
                    return(Conclusion.Success);
                }
            }

            if (!WaitingFelForm.WaitForDevice(hostForm))
            {
                return(Conclusion.Abort);
            }

            fel.Fes1Bin  = Resources.fes1;
            fel.UBootBin = hakchi.Hmod.GetUboot(UbootType.SD).ToArray();
            if (!fel.Open())
            {
                throw new FelException("Can't open device");
            }
            tasker.SetStatus(Resources.UploadingFes1);
            fel.InitDram(true);
            return(Conclusion.Success);
        }