Ejemplo n.º 1
0
        public void SetUp()
        {
            toTest = new SModel.Ivsu
            {
                Selected = true,
                Type     = "APPS",
                Name     = "5U5T-14G381-AP",
                Version  = "3.4.19101",
                Notes    = null,
                Url      = "https://ivsubinaries.azureedge.net/swparts/5U5T-14G381-AP_1555085337000.TAR.GZ",
                Md5      = "98c289f37416a07ba274585350acaa4c",
                FileName = "5U5T-14G381-AP_1555085337000.TAR.GZ",
                Source   = null
            };

            IvsuList = new System.Collections.ObjectModel.ObservableCollection <SModel.Ivsu>()
            {
                new SModel.Ivsu
                {
                    Selected = false,
                    Type     = "GRACENOTES",
                    Name     = "4U5T-14G423-CA",
                    Version  = "1.1.1.1332",
                    Notes    = "",
                    Url      = "https://ivsubinaries.azureedge.net/swparts/4U5T-14G423-CA_123766.tar.gz",
                    Md5      = "95d8331ef437041ec4edd2163c1f2619",
                    FileName = "4U5T-14G423-CA_123766.tar.gz",
                    Source   = null
                },
                toTest,
                new SModel.Ivsu
                {
                    Selected = false,
                    Type     = "VOICE",
                    Name     = "5U5T-14G391-CL",
                    Version  = null,
                    Notes    = null,
                    Url      = "https://ivsubinaries.azureedge.net/swparts/5U5T-14G391-CL_1580862907000.TAR.GZ",
                    Md5      = "672fc1d83f6a28fb1ec5ca713d23f050",
                    FileName = "5U5T-14G391-CL_1580862907000.TAR.GZ",
                    Source   = null
                },
            };
            merica = new SModel.SRegion()
            {
                Code = "NA", Name = "United States, Canada & Mexico"
            };
            nosavedrive = new USBHelper.Drive()
            {
                Name = "Download Only (NO USB)"
            };
        }
Ejemplo n.º 2
0
        public static StringBuilder CreateAutoInstallFile(string selectedRelease, string selectedRegion)
        {
            StringBuilder autoinstalllst =
                new(
                    $@"; CyanLabs Syn3Updater {Assembly.GetEntryAssembly()?.GetName().Version} {AppMan.App.LauncherPrefs.ReleaseTypeInstalled} - Autoinstall {(AppMan.App.ModeForced ? "FORCED " : "")}Mode - {selectedRelease} {selectedRegion}{Environment.NewLine}{Environment.NewLine}");
            //naviextras not handled here
            List <SModel.Ivsu> ivsuList = AppMan.App.Ivsus.Where(item => item.Source != "naviextras").ToList();

            if (ivsuList.Any(i => i.Type == "MAP"))
            {
                autoinstalllst.Append($@"[SYNCGen3.0_3.0.1_PRODUCT]{Environment.NewLine}");
                SModel.Ivsu mapLicense = ivsuList.Find(i => i.Type == "MAP_LICENSE");
                if (mapLicense != null)
                {
                    autoinstalllst.Append($@"Item1 = {mapLicense.Type} - {mapLicense.FileName}\rOpen1 = SyncMyRide\{mapLicense.FileName}\r").Replace(@"\r", Environment.NewLine);
                    ivsuList.Remove(mapLicense);
                }

                List <uint> vals = ivsuList.ConvertAll(ivsu => (uint)ivsu.FileSize);
                //splits the ivsus into 3 evenly distibuted buckets
                effPartition buckets = new(vals, 3);
                for (ushort i = 0; i < buckets.SubsetCount; i++)
                {
                    for (int j = 0; j < buckets[i].NumbIDs.Count; j++)
                    {
                        int subIndex = (int)buckets[i].numbIDs[j];
                        //indexes for "Items" start at 1
                        int partIndex = j + 1;
                        //indexes returned by the partition code start at 1
                        SModel.Ivsu item = ivsuList[subIndex - 1];
                        if (i == 0 && mapLicense != null) //since we added the MAP_LICENCE package above
                        {
                            partIndex++;
                        }
                        autoinstalllst.Append($@"Item{partIndex} = {item.Type} - {item.FileName}\rOpen{partIndex} = SyncMyRide\{item.FileName}\r")
                        .Replace(@"\r", Environment.NewLine);
                    }

                    if (i == 0)
                    {
                        autoinstalllst.Append("Options = AutoInstall").Append(Environment.NewLine).Append(Environment.NewLine);
                    }
                    if (i == 0 && ivsuList.Count > 1)
                    {
                        autoinstalllst.Append($@"[SYNCGen3.0_3.0.1]{Environment.NewLine}");
                    }
                    if (i == 1 && ivsuList.Count > 1)
                    {
                        autoinstalllst.Append("Options = AutoInstall, Include, Transaction").Append(Environment.NewLine).Append(Environment.NewLine);
                    }
                    if (i == 1 && ivsuList.Count > 2)
                    {
                        autoinstalllst.Append($@"[SYNCGen3.0_ALL]{Environment.NewLine}");
                    }
                    if (i == 2 && ivsuList.Count > 2)
                    {
                        autoinstalllst.Append("Options = Delay, Include, Transaction").Append(Environment.NewLine);
                    }
                }
            }
            else
            {
                autoinstalllst.Append($@"[SYNCGen3.0_ALL_PRODUCT]{Environment.NewLine}");
                for (int i = 0; i < ivsuList.Count; i++)
                {
                    SModel.Ivsu item = ivsuList[i];
                    autoinstalllst.Append($@"Item{i + 1} = {item.Type} - {item.FileName}\rOpen{i + 1} = SyncMyRide\{item.FileName}\r").Replace(@"\r", Environment.NewLine);
                }

                autoinstalllst.Append("Options = AutoInstall").Append(Environment.NewLine);
            }

            return(autoinstalllst);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Extracts the tar.gz file in to multiple packages (naviextras)
        /// </summary>
        /// <param name="item">The SModel.Ivsu of the item to extract</param>
        /// <param name="ct"></param>
        /// <returns>outputResult with Message and Result properties</returns>
        public async Task <OutputResult> ExtractMultiPackage(SModel.Ivsu item, CancellationToken ct)
        {
            OutputResult outputResult = new() { Message = "" };

            if (item.Source != "naviextras")
            {
                outputResult.Result = true;
                return(outputResult);
            }

            string path        = AppMan.App.DownloadPath + item.FileName;
            string destination = Path.ChangeExtension(path, null);
            Stream inStream    = File.OpenRead(path);
            Stream gzipStream  = new GZipInputStream(inStream);

            TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream, Encoding.ASCII);

            tarArchive.ExtractContents(destination);
            tarArchive.Close();

            gzipStream.Close();
            inStream.Close();

            foreach (string tarfile in Directory.GetFiles(destination, "*.tar.gz*", SearchOption.AllDirectories))
            {
                string name     = Path.GetFileNameWithoutExtension(tarfile).Replace(".tar", "");
                string filename = Path.GetFileName(tarfile);
                string newpath  = AppMan.App.DownloadPath + filename;
                if (File.Exists(newpath))
                {
                    File.Delete(newpath);
                }
                File.Move(tarfile, newpath);
                string type = "";

                if (name.Contains("14G424"))
                {
                    type = "MAP_LICENSE";
                }
                else if (name.Contains("14G421"))
                {
                    type = "MAP";
                }
                FileInfo fi   = new(newpath);
                long     size = fi.Length;
                AppMan.App.ExtraIvsus.Add(new SModel.Ivsu
                {
                    Type     = type,
                    Name     = name,
                    Version  = "",
                    Notes    = "",
                    Url      = "",
                    Md5      = await GenerateMd5(newpath, ct),
                    Selected = true,
                    FileName = filename,
                    FileSize = size
                });
            }

            outputResult.Message = "Added MultiPackage files to Queue";
            outputResult.Result  = true;
            return(outputResult);
        }