public FileItem(FileItem fileItem) { LocalFileName = fileItem.LocalFileName; ZipFileName = fileItem.ZipFileName; InstallType = fileItem.InstallType; DestinationFilename = fileItem.DestinationFilename; SystemFile = fileItem.SystemFile; UpdateOption = fileItem.UpdateOption; Param1 = fileItem.Param1; Modified = fileItem.Modified; //Param2 = fileItem.Param2; }
public void Install(PackageClass packageClass, FileItem file) { List<string> skinList = GetInstalledSkins(file.Param1.Split(ParamNamesConst.SEPARATORS)); foreach (string list in skinList) { FileItem fileItem = new FileItem(file); string destination = fileItem.ExpandedDestinationFilename.Replace("[DEFAULT]", list); FileItem item = packageClass.UniqueFileList.GetByLocalFileName(fileItem); if (item == null) return; item.InstallType = "CopyFile"; if (File.Exists(destination)) { switch (fileItem.UpdateOption) { case UpdateOptionEnum.NeverOverwrite: continue; case UpdateOptionEnum.AlwaysOverwrite: break; case UpdateOptionEnum.OverwriteIfOlder: if (File.GetLastWriteTime(destination) > packageClass.ZipProvider.FileDate(item)) continue; break; } } if (!Directory.Exists(Path.GetDirectoryName(destination))) Directory.CreateDirectory(Path.GetDirectoryName(destination)); UnInstallItem unInstallItem = packageClass.UnInstallInfo.BackUpFile(destination, item.InstallType); packageClass.ZipProvider.Extract(item, destination); FileInfo info = new FileInfo(destination); unInstallItem.FileDate = info.CreationTimeUtc; unInstallItem.FileSize = info.Length; packageClass.UnInstallInfo.Items.Add(unInstallItem); } }
public FileItem GetByLocalFileName(FileItem item) { return GetByLocalFileName(item.LocalFileName); }
/// <summary> /// Determine if exists the name of the local file. /// </summary> /// <param name="item">The item.</param> /// <returns></returns> public bool ExistLocalFileName(FileItem item) { return ExistLocalFileName(item.LocalFileName); }
/// <summary> /// Adds the specified file item. /// </summary> /// <param name="item">The file item.</param> public void Add(FileItem item) { Items.Add(item); }
public InstallEventArgs(string description) { Group = new GroupItem(); Item = new FileItem(); Description = description; }
public InstallEventArgs(GroupItem groupItem, FileItem fileItem) { Group = groupItem; Item = fileItem; Description = string.Empty; }
private static FileItem GetCommonItem(GroupItem groupItem) { var resp = new FileItem(); if (groupItem.Files.Items.Count > 0) { resp.DestinationFilename = string.IsNullOrEmpty(groupItem.Files.Items[0].DestinationFilename) ? "" : Path.GetDirectoryName(groupItem.Files.Items[0].DestinationFilename); resp.UpdateOption = groupItem.Files.Items[0].UpdateOption; resp.InstallType = groupItem.Files.Items[0].InstallType; resp.Param1 = groupItem.Files.Items[0].Param1; foreach (FileItem item in groupItem.Files.Items) { if (string.IsNullOrEmpty(item.DestinationFilename) || resp.DestinationFilename != Path.GetDirectoryName(item.DestinationFilename)) resp.DestinationFilename = ""; if (resp.UpdateOption != item.UpdateOption) resp.UpdateOption = UpdateOptionEnum.OverwriteIfOlder; if (resp.InstallType != item.InstallType) resp.InstallType = "CopyFile"; if (resp.Param1 != item.Param1) resp.Param1 = string.Empty; } } return resp; }
public void CreateSkinDependency(FileItem referenceFile) { MpeCore.Classes.VersionProvider.SkinVersion skinVersion = new MpeCore.Classes.VersionProvider.SkinVersion(); DependencyItem dep; CheckSkinDependency(out dep); if (dep != null) { Dependencies.Items.Remove(dep); } dep = CreateStrictDependency(skinVersion); Version versionSkin = null; string fileName = referenceFile.LocalFileName; if (!Path.IsPathRooted(fileName)) { fileName = Path.Combine(Path.GetDirectoryName(ProjectSettings.ProjectFilename), fileName); fileName = Path.GetFullPath(fileName); } if (File.Exists(fileName)) { XmlDocument doc = new XmlDocument(); doc.Load(fileName); XmlNode node = doc.SelectSingleNode("/controls/skin/version"); if (node != null && node.InnerText != null) { versionSkin = new Version(node.InnerText); dep.MinVersion = new VersionInfo(versionSkin); dep.MaxVersion = new VersionInfo(versionSkin); } } Dependencies.Add(dep); }
public string GetZipEntry(FileItem fileItem) { return string.Format("Installer{{GenericSkinFile}}\\{{{0}}}-{1}", Guid.NewGuid(), Path.GetFileName(fileItem.LocalFileName)); }
public ValidationResponse Validate(FileItem fileItem) { var response = new ValidationResponse(); if (!File.Exists(fileItem.LocalFileName)) { response.Valid = false; response.Message = "Source file not found !"; } if (string.IsNullOrEmpty(fileItem.DestinationFilename)) { response.Valid = false; response.Message = "No install location specified !"; } if (!fileItem.DestinationFilename.StartsWith("%Skin%\\[DEFAULT]")) { response.Valid = false; response.Message = "Template not start with %Skin%\\[DEFAULT] in destination path specified !" + fileItem.DestinationFilename; } return response; }
/// <summary> /// Transform templated path in a real path based on PathProviders /// </summary> /// <param name="fileItem">The file item.</param> /// <returns></returns> public string GetInstallPath(FileItem fileItem) { string localFile = fileItem.DestinationFilename; foreach (var pathProvider in MpeCore.MpeInstaller.PathProviders) { localFile = pathProvider.Value.Expand(localFile); } //if (!localFile.Contains("%")) // localFile = string.Empty; return localFile; }
public FileItem GetByLocalFileName(FileItem item) { return(GetByLocalFileName(item.LocalFileName)); }
/// <summary> /// Determine if exists the name of the local file. /// </summary> /// <param name="item">The item.</param> /// <returns></returns> public bool ExistLocalFileName(FileItem item) { return(ExistLocalFileName(item.LocalFileName)); }
private void btn_done_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txt_skinpath.Text)) { MessageBox.Show("No skin folder specified !"); return; } Package.GeneralInfo.Name = txt_name.Text; Package.GeneralInfo.Author = txt_author.Text; Package.GeneralInfo.Version = new VersionInfo() { Major = txt_version1.Text, Minor = txt_version2.Text, Build = txt_version3.Text, Revision = txt_version4.Text }; string fontName = Path.GetFileName(txt_skinpath.Text); #region Skin GroupItem skinGroup = new GroupItem("Skin files"); FolderGroup skinfoldergroup = new FolderGroup() { DestinationFilename = "%Skin%\\" + fontName, Folder = txt_skinpath.Text, InstallType = "CopyFile", UpdateOption = UpdateOptionEnum.OverwriteIfOlder, Param1 = "", Recursive = true, Group = skinGroup.Name }; Package.Groups.Add(skinGroup); Package.ProjectSettings.Add(skinfoldergroup); ProjectSettings.UpdateFiles(Package, skinfoldergroup); #endregion #region fonts if (!string.IsNullOrEmpty(txt_font1.Text + txt_font2.Text + txt_font3.Text)) { GroupItem fontGroup = new GroupItem("Font files"); if (!string.IsNullOrEmpty(txt_font1.Text) && File.Exists(txt_font1.Text)) { FileItem fileitem = new FileItem { DestinationFilename = "%Skin%\\" + fontName + "\\Fonts\\" + Path.GetFileName(txt_font1.Text), InstallType = "CopyFont", LocalFileName = Path.GetFullPath(txt_font1.Text) }; fontGroup.Files.Add(fileitem); } if (!string.IsNullOrEmpty(txt_font2.Text) && File.Exists(txt_font2.Text)) { FileItem fileitem = new FileItem { DestinationFilename = "%Skin%\\" + fontName + "\\Fonts\\" + Path.GetFileName(txt_font2.Text), InstallType = "CopyFont", LocalFileName = Path.GetFullPath(txt_font2.Text) }; fontGroup.Files.Add(fileitem); } if (!string.IsNullOrEmpty(txt_font3.Text) && File.Exists(txt_font3.Text)) { FileItem fileitem = new FileItem { DestinationFilename = "%Skin%\\" + fontName + "\\Fonts\\" + Path.GetFileName(txt_font3.Text), InstallType = "CopyFont", LocalFileName = Path.GetFullPath(txt_font3.Text) }; fontGroup.Files.Add(fileitem); } Package.Groups.Add(fontGroup); } #endregion #region dlls %Plugins% if (!string.IsNullOrEmpty(txt_plugin_procces.Text + txt_plugin_window.Text + txt_plugin_exe.Text)) { GroupItem dllGroup = new GroupItem("Plugin files"); if (!string.IsNullOrEmpty(txt_plugin_procces.Text) && File.Exists(txt_plugin_procces.Text)) { FileItem fileitem = new FileItem { DestinationFilename = "%Plugins%\\process\\" + Path.GetFileName(txt_plugin_procces.Text), InstallType = "CopyFile", LocalFileName = Path.GetFullPath(txt_plugin_procces.Text) }; dllGroup.Files.Add(fileitem); } if (!string.IsNullOrEmpty(txt_plugin_window.Text) && File.Exists(txt_plugin_window.Text)) { FileItem fileitem = new FileItem { DestinationFilename = "%Plugins%\\Windows\\" + Path.GetFileName(txt_plugin_window.Text), InstallType = "CopyFile", LocalFileName = Path.GetFullPath(txt_plugin_window.Text) }; dllGroup.Files.Add(fileitem); } if (!string.IsNullOrEmpty(txt_plugin_exe.Text) && File.Exists(txt_plugin_exe.Text)) { FileItem fileitem = new FileItem { DestinationFilename = "%Base%\\" + Path.GetFileName(txt_plugin_exe.Text), InstallType = "CopyFile", LocalFileName = Path.GetFullPath(txt_plugin_exe.Text) }; dllGroup.Files.Add(fileitem); } Package.Groups.Add(dllGroup); } #endregion #region install sections Package.Sections.Add("Welcome Screen").WizardButtonsEnum = WizardButtonsEnum.NextCancel; Package.Sections.Add("Install Section").WizardButtonsEnum = WizardButtonsEnum.Next; var item = new ActionItem("InstallFiles") { Params = new SectionParamCollection( MpeInstaller.ActionProviders["InstallFiles"].GetDefaultParams()) }; Package.Sections.Items[1].Actions.Add(item); Package.Sections.Add("Setup Complete").WizardButtonsEnum = WizardButtonsEnum.Finish; #endregion #region config if (radioButton1.Checked && File.Exists(txt_plugin_procces.Text)) Package.GeneralInfo.Params[ParamNamesConst.CONFIG].Value = "%Plugins%\\process\\" + Path.GetFileName(txt_plugin_procces.Text); if (radioButton1.Checked && File.Exists(txt_plugin_window.Text)) Package.GeneralInfo.Params[ParamNamesConst.CONFIG].Value = "%Plugins%\\Windows\\" + Path.GetFileName(txt_plugin_window.Text); if (radioButton1.Checked && File.Exists(txt_plugin_exe.Text)) Package.GeneralInfo.Params[ParamNamesConst.CONFIG].Value = "%Base%\\" + Path.GetFileName(txt_plugin_exe.Text); if (File.Exists(txt_ico.Text)) { string icofile = Path.GetFullPath(txt_ico.Text); Package.GeneralInfo.Params[ParamNamesConst.ICON].Value = icofile; Package.Sections.Items[0].Params[ParamNamesConst.SECTION_ICON].Value = icofile; Package.Sections.Items[1].Params[ParamNamesConst.SECTION_ICON].Value = icofile; Package.Sections.Items[2].Params[ParamNamesConst.SECTION_ICON].Value = icofile; } Package.GeneralInfo.Location = txt_mpe_folder.Text + "\\" + Package.GeneralInfo.Name + ".mpe1"; #endregion Close(); }
/// <summary> /// Checks wether package includes a skin. /// </summary> /// <returns>Returns true if package conatins a skin</returns> public bool ProvidesSkin(out FileItem referenceFile) { IsSkin = false; referenceFile = null; System.Globalization.CultureInfo invariantCulture = System.Globalization.CultureInfo.InvariantCulture; foreach (FileItem file in UniqueFileList.Items) { if (file.DestinationFilename.StartsWith("%" + MediaPortal.Configuration.Config.Dir.Skin + "%", true, invariantCulture) && file.DestinationFilename.EndsWith("references.xml", true, invariantCulture)) { referenceFile = file; IsSkin = true; return true; } } return false; }
/// <summary> /// Transform real path in a templated path based on PathProviders /// </summary> /// <param name="fileItem">The file item.</param> /// <returns></returns> public string GetTemplatePath(FileItem fileItem) { string localFile = fileItem.LocalFileName; //foreach (var pathProvider in MpeCore.MpeInstaller.PathProviders) //{ // localFile = pathProvider.Value.Colapse(localFile); //} //if (!localFile.Contains("%")) // localFile = "%Base%\\" + Path.GetFileName(localFile); return "%Skin%\\[DEFAULT]\\" + Path.GetFileName(localFile); ; }
public UnInstallItem BackUpFile(FileItem item) { return BackUpFile(item.ExpandedDestinationFilename, item.InstallType); }
private static void AddFile(TreeNode node, FileItem file) { GroupItem group = node.Tag as GroupItem; TreeNode newnode = new TreeNode(); newnode.Text = file.ToString(); newnode.Tag = file; newnode.ImageKey = File.Exists(Path.GetFullPath(file.LocalFileName)) ? ImageKeyFile : ImageKeyError; newnode.SelectedImageKey = File.Exists(Path.GetFullPath(file.LocalFileName)) ? ImageKeyFile : ImageKeyError; newnode.ToolTipText = Path.GetFullPath(file.LocalFileName); node.Nodes.Add(newnode); }