コード例 #1
0
        void ScanConnectedDevices()
        {
            ConnectedDeviceInfo [] DeviceMap = null;

            Program.ProgressDialog.OnBeginBackgroundWork = delegate
            {
                DeviceMap = DeploymentHelper.Get().EnumerateConnectedDevices();
            };

            if ((Program.ProgressDialog.ShowDialog() == DialogResult.OK) && (DeviceMap != null))
            {
                ConnectedDevicesList.BeginUpdate();
                ConnectedDevicesList.Items.Clear();

                foreach (var DeviceInfo in DeviceMap)
                {
                    string DisplayName = DeviceInfo.DeviceName;
                    string UDID        = DeviceInfo.UDID;
                    string DeviceType  = DeviceInfo.DeviceType;

                    ListViewItem NewItem = ConnectedDevicesList.Items.Add(DisplayName);
                    NewItem.SubItems.Add(UDID);
                    NewItem.SubItems.Add(DeviceType);
                }

                ConnectedDevicesList.EndUpdate();
            }
            else
            {
                Program.Error("Enumerating devices failed");
            }
        }
コード例 #2
0
        private void UninstallIPAButton_Click_1(object sender, EventArgs e)
        {
            string BundleID = PickIPAAndFetchBundleIdentifier();

            if (BundleID != null)
            {
                Program.ProgressDialog.OnBeginBackgroundWork = delegate
                {
                    DeploymentHelper.Get().UninstallIPAOnDevice(BundleID);
                };
                Program.ProgressDialog.ShowDialog();
            }
        }
コード例 #3
0
        private void BackupDocumentsButton_Click(object sender, EventArgs e)
        {
            string BundleID = PickIPAAndFetchBundleIdentifier();

            if (BundleID != null)
            {
                Program.ProgressDialog.OnBeginBackgroundWork = delegate
                {
                    DeploymentHelper.Get().BackupDocumentsDirectory(BundleID, Config.GetRootBackedUpDocumentsDirectory());
                };
                Program.ProgressDialog.ShowDialog();
            }
        }
コード例 #4
0
        private void InstallIPAButton_Click(object sender, EventArgs e)
        {
            string PickedFilename;

            if (ToolsHub.ShowOpenFileDialog(ToolsHub.IpaFilter, "Choose an IPA to install", "ipa", "", ref ToolsHub.ChoosingIpaDirectory, out PickedFilename))
            {
                Program.ProgressDialog.OnBeginBackgroundWork = delegate
                {
                    DeploymentHelper.InstallIPAOnConnectedDevices(PickedFilename);
                };
                Program.ProgressDialog.ShowDialog();
            }
        }
コード例 #5
0
        static void ListDevices()
        {
            var DeviceList = DeploymentHelper.Get().EnumerateConnectedDevices();

            Console.WriteLine("-------------------------------------------------------");
            Console.WriteLine("List of devices attached");

            foreach (var DeviceInfo in DeviceList)
            {
                string UDID       = DeviceInfo.UDID;
                string DeviceName = DeviceInfo.DeviceName;

                Console.WriteLine("{0} device:{1}", UDID, DeviceName);
            }
        }
コード例 #6
0
        public static void InstallIPAOnConnectedDevices(string IPAPath)
        {
            // Read the mobile provision to check for issues
            FileOperations.ReadOnlyZipFileSystem Zip = new FileOperations.ReadOnlyZipFileSystem(IPAPath);
            MobileProvision Provision = null;

            try
            {
                MobileProvisionParser.ParseFile(Zip.ReadAllBytes("embedded.mobileprovision"));
            }
            catch (System.Exception ex)
            {
                Program.Warning(String.Format("Couldn't find an embedded mobile provision ({0})", ex.Message));
                Provision = null;
            }
            Zip.Close();

            if (Provision != null)
            {
                var DeviceList = DeploymentHelper.Get().EnumerateConnectedDevices();

                foreach (var DeviceInfo in DeviceList)
                {
                    string UDID       = DeviceInfo.UDID;
                    string DeviceName = DeviceInfo.DeviceName;

                    // Check the IPA's mobile provision against the connected device to make sure this device is authorized
                    // We'll still try installing anyways, but this message is more friendly than the failure we get back from MobileDeviceInterface
                    if (UDID != String.Empty)
                    {
                        if (!Provision.ContainsUDID(UDID))
                        {
                            Program.Warning(String.Format("Embedded provision in IPA does not include the UDID {0} of device '{1}'.  The installation is likely to fail.", UDID, DeviceName));
                        }
                    }
                    else
                    {
                        Program.Warning(String.Format("Unable to query device for UDID, and therefore unable to verify IPA embedded mobile provision contains this device."));
                    }
                }
            }

            DeploymentHelper.Get().InstallIPAOnDevice(IPAPath);
        }
コード例 #7
0
        static public void ExecuteCommand(string Command, string RPCCommand)
        {
            if (ReturnCode > 0)
            {
                Warning("Error in previous command; suppressing: " + Command + " " + RPCCommand ?? "");
                return;
            }

            if (Config.bVerbose)
            {
                Log("");
                Log("----------");
                Log(String.Format("Executing command '{0}' {1}...", Command, (RPCCommand != null) ? ("'" + RPCCommand + "' ") : ""));
            }

            try
            {
                bool bHandledCommand = CookTime.ExecuteCookCommand(Command, RPCCommand);

                if (!bHandledCommand)
                {
                    bHandledCommand = CompileTime.ExecuteCompileCommand(Command, RPCCommand);
                }

                if (!bHandledCommand)
                {
                    bHandledCommand = DeploymentHelper.ExecuteDeployCommand(Command, GamePath, RPCCommand);
                }

                if (!bHandledCommand)
                {
                    bHandledCommand = true;
                    switch (Command)
                    {
                    case "configure":
                        if (Config.bForDistribution)
                        {
                            Error("configure cannot be used with -distribution");
                            Program.ReturnCode = (int)ErrorCodes.Error_Arguments;
                        }
                        else
                        {
                            RunInVisualMode(delegate { return(new ConfigureMobileGame()); });
                        }
                        break;

                    default:
                        bHandledCommand = false;
                        break;
                    }
                }

                if (!bHandledCommand)
                {
                    Error("Unknown command");
                    Program.ReturnCode = (int)ErrorCodes.Error_UnknownCommand;
                }
            }
            catch (Exception Ex)
            {
                Error("Error while executing command: " + Ex.ToString());
                if (Program.ReturnCode == 0)
                {
                    Program.ReturnCode = (int)ErrorCodes.Error_Unknown;
                }
            }

            Console.WriteLine();
        }
コード例 #8
0
        public static bool ExecuteDeployCommand(string Command, string GamePath, string RPCCommand)
        {
            switch (Command.ToLowerInvariant())
            {
            case "backup":
            {
                string ApplicationIdentifier = RPCCommand;
                if (ApplicationIdentifier == null)
                {
                    ApplicationIdentifier = Utilities.GetStringFromPList("CFBundleIdentifier");
                }

                if (Config.FilesForBackup.Count > 0)
                {
                    if (!DeploymentHelper.Get().BackupFiles(ApplicationIdentifier, Config.FilesForBackup.ToArray()))
                    {
                        Program.Error("Failed to transfer manifest file from device to PC");
                        Program.ReturnCode = (int)ErrorCodes.Error_DeviceBackupFailed;
                    }
                }
                else if (!DeploymentHelper.Get().BackupDocumentsDirectory(ApplicationIdentifier, Config.GetRootBackedUpDocumentsDirectory()))
                {
                    Program.Error("Failed to transfer documents directory from device to PC");
                    Program.ReturnCode = (int)ErrorCodes.Error_DeviceBackupFailed;
                }
            }
            break;

            case "uninstall":
            {
                string ApplicationIdentifier = RPCCommand;
                if (ApplicationIdentifier == null)
                {
                    ApplicationIdentifier = Utilities.GetStringFromPList("CFBundleIdentifier");
                }

                if (!DeploymentHelper.Get().UninstallIPAOnDevice(ApplicationIdentifier))
                {
                    Program.Error("Failed to uninstall IPA on device");
                    Program.ReturnCode = (int)ErrorCodes.Error_AppUninstallFailed;
                }
            }
            break;

            case "deploy":
            case "install":
            {
                string IPAPath = GamePath;
                string AdditionalCommandline = Program.AdditionalCommandline;

                if (!String.IsNullOrEmpty(AdditionalCommandline) && !Config.bIterate)
                {
                    // Read the mobile provision to check for issues
                    FileOperations.ReadOnlyZipFileSystem Zip = new FileOperations.ReadOnlyZipFileSystem(IPAPath);
                    try
                    {
                        // Compare the commandline embedded to prevent us from any unnecessary writing.
                        byte[] CommandlineBytes    = Zip.ReadAllBytes("ue4commandline.txt");
                        string ExistingCommandline = Encoding.UTF8.GetString(CommandlineBytes, 0, CommandlineBytes.Length);
                        if (ExistingCommandline != AdditionalCommandline)
                        {
                            // Ensure we have a temp dir to stage our temporary ipa
                            if (!Directory.Exists(Config.PCStagingRootDir))
                            {
                                Directory.CreateDirectory(Config.PCStagingRootDir);
                            }

                            string TmpFilePath = Path.Combine(Path.GetDirectoryName(Config.PCStagingRootDir), Path.GetFileNameWithoutExtension(IPAPath) + ".tmp.ipa");
                            if (File.Exists(TmpFilePath))
                            {
                                File.Delete(TmpFilePath);
                            }

                            File.Copy(IPAPath, TmpFilePath);

                            // Get the project name:
                            string ProjectFile = ExistingCommandline.Split(' ').FirstOrDefault();

                            // Write out the new commandline.
                            FileOperations.ZipFileSystem WritableZip = new FileOperations.ZipFileSystem(TmpFilePath);
                            byte[] NewCommandline = Encoding.UTF8.GetBytes(ProjectFile + " " + AdditionalCommandline);
                            WritableZip.WriteAllBytes("ue4commandline.txt", NewCommandline);

                            // We need to residn the application after the commandline file has changed.
                            CodeSignatureBuilder CodeSigner = new CodeSignatureBuilder();
                            CodeSigner.FileSystem = WritableZip;

                            CodeSigner.PrepareForSigning();
                            CodeSigner.PerformSigning();

                            WritableZip.Close();

                            // Set the deploying ipa path to our new ipa
                            IPAPath = TmpFilePath;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        Program.Warning(String.Format("Failed to override the commandline.txt file: ({0})", ex.Message));
                    }
                    Zip.Close();
                }

                if (Config.bIterate)
                {
                    string ApplicationIdentifier = RPCCommand;
                    if (String.IsNullOrEmpty(ApplicationIdentifier))
                    {
                        ApplicationIdentifier = Utilities.GetStringFromPList("CFBundleIdentifier");
                    }

                    DeploymentHelper.Get().DeviceId = Config.DeviceId;
                    if (!DeploymentHelper.Get().InstallFilesOnDevice(ApplicationIdentifier, Config.DeltaManifest))
                    {
                        Program.Error("Failed to install Files on device");
                        Program.ReturnCode = (int)ErrorCodes.Error_FilesInstallFailed;
                    }
                }
                else if (File.Exists(IPAPath))
                {
                    DeploymentHelper.Get().DeviceId = Config.DeviceId;
                    if (!DeploymentHelper.Get().InstallIPAOnDevice(IPAPath))
                    {
                        Program.Error("Failed to install IPA on device");
                        Program.ReturnCode = (int)ErrorCodes.Error_AppInstallFailed;
                    }
                }
                else
                {
                    Program.Error(String.Format("Failed to find IPA file: '{0}'", IPAPath));
                    Program.ReturnCode = (int)ErrorCodes.Error_AppNotFound;
                }
            }
            break;

            default:
                return(false);
            }

            return(true);
        }