diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7964536 --- /dev/null +++ b/.gitignore @@ -0,0 +1,189 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +x64/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Roslyn cache directories +*.ide/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +#NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding addin-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +## TODO: Comment the next line if you want to checkin your +## web deploy settings but do note that will include unencrypted +## passwords +#*.pubxml + +# NuGet Packages Directory +packages/* +## TODO: If the tool you use requires repositories.config +## uncomment the next line +#!packages/repositories.config + +# Enable "build/" folder in the NuGet Packages folder since +# NuGet packages use it for MSBuild targets. +# This line needs to be after the ignore of the build folder +# (and the packages folder if the line above has been uncommented) +!packages/build/ + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml \ No newline at end of file diff --git a/Sunfish/Sunfish.sln b/Sunfish/Sunfish.sln new file mode 100644 index 0000000..aa67b2e --- /dev/null +++ b/Sunfish/Sunfish.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sunfish", "Sunfish\Sunfish.csproj", "{5511BE4E-6AE1-479B-B5CD-5A20DC4C13F7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5511BE4E-6AE1-479B-B5CD-5A20DC4C13F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5511BE4E-6AE1-479B-B5CD-5A20DC4C13F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5511BE4E-6AE1-479B-B5CD-5A20DC4C13F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5511BE4E-6AE1-479B-B5CD-5A20DC4C13F7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Sunfish/Sunfish/DolphinWeb.ico b/Sunfish/Sunfish/DolphinWeb.ico new file mode 100644 index 0000000..8fbcd2b --- /dev/null +++ b/Sunfish/Sunfish/DolphinWeb.ico Binary files differ diff --git a/Sunfish/Sunfish/FShared.Designer.cs b/Sunfish/Sunfish/FShared.Designer.cs new file mode 100644 index 0000000..a40fc3f --- /dev/null +++ b/Sunfish/Sunfish/FShared.Designer.cs @@ -0,0 +1,221 @@ +namespace DolphinWebXplorer2 +{ + partial class FShared + { + /// + /// Variable del diseñador requerida. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Limpiar los recursos que se estén utilizando. + /// + /// true si los recursos administrados se deben eliminar; false en caso contrario, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Código generado por el Diseñador de Windows Forms + + /// + /// Método necesario para admitir el Diseñador. No se puede modificar + /// el contenido del método con el editor de código. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.tbId = new System.Windows.Forms.TextBox(); + this.tbPath = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.cbEnabled = new System.Windows.Forms.CheckBox(); + this.cbSub = new System.Windows.Forms.CheckBox(); + this.cbUpl = new System.Windows.Forms.CheckBox(); + this.btOk = new System.Windows.Forms.Button(); + this.cbDele = new System.Windows.Forms.CheckBox(); + this.cbRena = new System.Windows.Forms.CheckBox(); + this.cbExec = new System.Windows.Forms.CheckBox(); + this.btOpen = new System.Windows.Forms.Button(); + this.cbMkDir = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 15); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(50, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Identifier:"; + // + // tbId + // + this.tbId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tbId.Location = new System.Drawing.Point(68, 12); + this.tbId.Name = "tbId"; + this.tbId.Size = new System.Drawing.Size(323, 20); + this.tbId.TabIndex = 1; + this.tbId.TextChanged += new System.EventHandler(this.tbId_TextChanged); + // + // tbPath + // + this.tbPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tbPath.Location = new System.Drawing.Point(68, 39); + this.tbPath.Name = "tbPath"; + this.tbPath.Size = new System.Drawing.Size(323, 20); + this.tbPath.TabIndex = 3; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 42); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(32, 13); + this.label2.TabIndex = 2; + this.label2.Text = "Path:"; + // + // cbEnabled + // + this.cbEnabled.AutoSize = true; + this.cbEnabled.Location = new System.Drawing.Point(15, 68); + this.cbEnabled.Name = "cbEnabled"; + this.cbEnabled.Size = new System.Drawing.Size(65, 17); + this.cbEnabled.TabIndex = 4; + this.cbEnabled.Text = "Enabled"; + this.cbEnabled.UseVisualStyleBackColor = true; + // + // cbSub + // + this.cbSub.AutoSize = true; + this.cbSub.Location = new System.Drawing.Point(15, 91); + this.cbSub.Name = "cbSub"; + this.cbSub.Size = new System.Drawing.Size(149, 17); + this.cbSub.TabIndex = 5; + this.cbSub.Text = "Allow subfolder navigation"; + this.cbSub.UseVisualStyleBackColor = true; + // + // cbUpl + // + this.cbUpl.AutoSize = true; + this.cbUpl.Enabled = false; + this.cbUpl.Location = new System.Drawing.Point(15, 114); + this.cbUpl.Name = "cbUpl"; + this.cbUpl.Size = new System.Drawing.Size(91, 17); + this.cbUpl.TabIndex = 6; + this.cbUpl.Text = "Allow uploads"; + this.cbUpl.UseVisualStyleBackColor = true; + // + // btOk + // + this.btOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btOk.Location = new System.Drawing.Point(316, 140); + this.btOk.Name = "btOk"; + this.btOk.Size = new System.Drawing.Size(75, 23); + this.btOk.TabIndex = 7; + this.btOk.Text = "Ok"; + this.btOk.UseVisualStyleBackColor = true; + this.btOk.Click += new System.EventHandler(this.btOk_Click); + // + // cbDele + // + this.cbDele.AutoSize = true; + this.cbDele.Location = new System.Drawing.Point(170, 68); + this.cbDele.Name = "cbDele"; + this.cbDele.Size = new System.Drawing.Size(83, 17); + this.cbDele.TabIndex = 8; + this.cbDele.Text = "Allow delete"; + this.cbDele.UseVisualStyleBackColor = true; + // + // cbRena + // + this.cbRena.AutoSize = true; + this.cbRena.Location = new System.Drawing.Point(170, 91); + this.cbRena.Name = "cbRena"; + this.cbRena.Size = new System.Drawing.Size(89, 17); + this.cbRena.TabIndex = 9; + this.cbRena.Text = "Allow rename"; + this.cbRena.UseVisualStyleBackColor = true; + // + // cbExec + // + this.cbExec.AutoSize = true; + this.cbExec.Location = new System.Drawing.Point(170, 114); + this.cbExec.Name = "cbExec"; + this.cbExec.Size = new System.Drawing.Size(229, 17); + this.cbExec.TabIndex = 10; + this.cbExec.Text = "Allow remote execution (execute on server)"; + this.cbExec.UseVisualStyleBackColor = true; + // + // btOpen + // + this.btOpen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btOpen.Location = new System.Drawing.Point(207, 140); + this.btOpen.Name = "btOpen"; + this.btOpen.Size = new System.Drawing.Size(103, 23); + this.btOpen.TabIndex = 11; + this.btOpen.Text = "Open in browser"; + this.btOpen.UseVisualStyleBackColor = true; + this.btOpen.Click += new System.EventHandler(this.btOpen_Click); + // + // cbMkDir + // + this.cbMkDir.AutoSize = true; + this.cbMkDir.Location = new System.Drawing.Point(15, 137); + this.cbMkDir.Name = "cbMkDir"; + this.cbMkDir.Size = new System.Drawing.Size(118, 17); + this.cbMkDir.TabIndex = 12; + this.cbMkDir.Text = "Allow create folders"; + this.cbMkDir.UseVisualStyleBackColor = true; + // + // FShared + // + this.AcceptButton = this.btOk; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(403, 175); + this.Controls.Add(this.cbMkDir); + this.Controls.Add(this.btOpen); + this.Controls.Add(this.cbExec); + this.Controls.Add(this.cbRena); + this.Controls.Add(this.cbDele); + this.Controls.Add(this.btOk); + this.Controls.Add(this.cbUpl); + this.Controls.Add(this.cbSub); + this.Controls.Add(this.cbEnabled); + this.Controls.Add(this.tbPath); + this.Controls.Add(this.label2); + this.Controls.Add(this.tbId); + this.Controls.Add(this.label1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "FShared"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Shared"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox tbId; + private System.Windows.Forms.TextBox tbPath; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.CheckBox cbEnabled; + private System.Windows.Forms.CheckBox cbSub; + private System.Windows.Forms.CheckBox cbUpl; + private System.Windows.Forms.Button btOk; + private System.Windows.Forms.CheckBox cbDele; + private System.Windows.Forms.CheckBox cbRena; + private System.Windows.Forms.CheckBox cbExec; + private System.Windows.Forms.Button btOpen; + private System.Windows.Forms.CheckBox cbMkDir; + } +} \ No newline at end of file diff --git a/Sunfish/Sunfish/FShared.cs b/Sunfish/Sunfish/FShared.cs new file mode 100644 index 0000000..e2486e2 --- /dev/null +++ b/Sunfish/Sunfish/FShared.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using DolphinWebXplorer2.wx; +using System.Diagnostics; + +namespace DolphinWebXplorer2 +{ + public partial class FShared : Form + { + private bool valid; + private string formerName; + private FShared() + { + InitializeComponent(); + } + + public static bool Execute(WShared sh) + { + using (FShared f = new FShared()) + { + f.tbId.DataBindings.Add("Text", sh, "Name"); + f.tbPath.DataBindings.Add("Text", sh, "Path"); + f.cbEnabled.DataBindings.Add("Checked", sh, "Enabled"); + f.cbSub.DataBindings.Add("Checked", sh, "AllowSubfolders"); + f.cbUpl.DataBindings.Add("Checked", sh, "AllowUpload"); + f.cbDele.DataBindings.Add("Checked", sh, "AllowDeletion"); + f.cbRena.DataBindings.Add("Checked", sh, "AllowRename"); + f.cbExec.DataBindings.Add("Checked", sh, "AllowExecution"); + f.cbMkDir.DataBindings.Add("Checked", sh, "AllowNewFolder"); + f.formerName = sh.Name; + f.btOpen.Visible=WebXplorer.Contains(sh); + return f.ShowDialog() == DialogResult.OK; + } + } + + private void SaveData() + { + foreach (Control c in new Control[] { tbId, tbPath,cbEnabled,cbSub,cbUpl,cbDele,cbRena,cbExec }) + { + c.DataBindings[0].WriteValue(); + } + } + + private void tbId_TextChanged(object sender, EventArgs e) + { + if (tbId.Text.Contains(" ") || tbId.Text.Contains("|")) + { + tbId.BackColor = Color.FromArgb(255, 200, 200); + valid = false; + return; + } + tbId.BackColor = SystemColors.Window; + valid = true; + } + + private void btOk_Click(object sender, EventArgs e) + { + if (valid) + { + SaveData(); + DialogResult = DialogResult.OK; + } + } + + private void btOpen_Click(object sender, EventArgs e) + { + Process.Start("http://localhost:" + WebXplorer.Port + "/" + formerName+"/"); + } + } +} diff --git a/Sunfish/Sunfish/FShared.resx b/Sunfish/Sunfish/FShared.resx new file mode 100644 index 0000000..19dc0dd --- /dev/null +++ b/Sunfish/Sunfish/FShared.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Sunfish/Sunfish/Form1.Designer.cs b/Sunfish/Sunfish/Form1.Designer.cs new file mode 100644 index 0000000..a40868a --- /dev/null +++ b/Sunfish/Sunfish/Form1.Designer.cs @@ -0,0 +1,206 @@ +namespace DolphinWebXplorer2 +{ + partial class Form1 + { + /// + /// Variable del diseñador requerida. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Limpiar los recursos que se estén utilizando. + /// + /// true si los recursos administrados se deben eliminar; false en caso contrario, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Código generado por el Diseñador de Windows Forms + + /// + /// Método necesario para admitir el Diseñador. No se puede modificar + /// el contenido del método con el editor de código. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); + this.button1 = new System.Windows.Forms.Button(); + this.nudPort = new System.Windows.Forms.NumericUpDown(); + this.cbActive = new System.Windows.Forms.CheckBox(); + this.btAdd = new System.Windows.Forms.Button(); + this.il16 = new System.Windows.Forms.ImageList(this.components); + this.btSub = new System.Windows.Forms.Button(); + this.lbPaths = new System.Windows.Forms.ListBox(); + this.btShowIp = new System.Windows.Forms.Button(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.btGeneralOptions = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.nudPort)).BeginInit(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Location = new System.Drawing.Point(142, 334); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(92, 23); + this.button1.TabIndex = 1; + this.button1.Text = "Ok"; + this.toolTip1.SetToolTip(this.button1, "Hide"); + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // nudPort + // + this.nudPort.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.nudPort.Location = new System.Drawing.Point(179, 6); + this.nudPort.Maximum = new decimal(new int[] { + 64000, + 0, + 0, + 0}); + this.nudPort.Name = "nudPort"; + this.nudPort.Size = new System.Drawing.Size(55, 20); + this.nudPort.TabIndex = 3; + this.toolTip1.SetToolTip(this.nudPort, "Listen port"); + this.nudPort.Value = new decimal(new int[] { + 90, + 0, + 0, + 0}); + this.nudPort.ValueChanged += new System.EventHandler(this.nudPort_ValueChanged); + // + // cbActive + // + this.cbActive.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.cbActive.AutoSize = true; + this.cbActive.Location = new System.Drawing.Point(77, 8); + this.cbActive.Name = "cbActive"; + this.cbActive.Size = new System.Drawing.Size(90, 17); + this.cbActive.TabIndex = 4; + this.cbActive.Text = "Listen on port"; + this.toolTip1.SetToolTip(this.cbActive, "Enable whole server"); + this.cbActive.UseVisualStyleBackColor = true; + this.cbActive.CheckedChanged += new System.EventHandler(this.cbActive_CheckedChanged); + // + // btAdd + // + this.btAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btAdd.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btAdd.ImageIndex = 0; + this.btAdd.ImageList = this.il16; + this.btAdd.Location = new System.Drawing.Point(6, 334); + this.btAdd.Name = "btAdd"; + this.btAdd.Size = new System.Drawing.Size(23, 23); + this.btAdd.TabIndex = 5; + this.toolTip1.SetToolTip(this.btAdd, "Add new access"); + this.btAdd.UseVisualStyleBackColor = true; + this.btAdd.Click += new System.EventHandler(this.btAdd_Click); + // + // il16 + // + this.il16.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("il16.ImageStream"))); + this.il16.TransparentColor = System.Drawing.Color.White; + this.il16.Images.SetKeyName(0, "bt_plus.bmp"); + this.il16.Images.SetKeyName(1, "bt_minus.bmp"); + // + // btSub + // + this.btSub.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btSub.Enabled = false; + this.btSub.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btSub.ImageKey = "bt_minus.bmp"; + this.btSub.ImageList = this.il16; + this.btSub.Location = new System.Drawing.Point(35, 334); + this.btSub.Name = "btSub"; + this.btSub.Size = new System.Drawing.Size(23, 23); + this.btSub.TabIndex = 6; + this.toolTip1.SetToolTip(this.btSub, "Remove >selected access"); + this.btSub.UseVisualStyleBackColor = true; + this.btSub.Click += new System.EventHandler(this.btSub_Click); + // + // lbPaths + // + this.lbPaths.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbPaths.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; + this.lbPaths.FormattingEnabled = true; + this.lbPaths.IntegralHeight = false; + this.lbPaths.ItemHeight = 28; + this.lbPaths.Location = new System.Drawing.Point(0, 32); + this.lbPaths.Name = "lbPaths"; + this.lbPaths.Size = new System.Drawing.Size(240, 296); + this.lbPaths.TabIndex = 7; + this.lbPaths.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.lbPaths_DrawItem); + this.lbPaths.SelectedIndexChanged += new System.EventHandler(this.lbPaths_SelectedIndexChanged); + this.lbPaths.DoubleClick += new System.EventHandler(this.clbPaths_DoubleClick); + // + // btShowIp + // + this.btShowIp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btShowIp.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btShowIp.Image = global::DolphinWebXplorer2.Properties.Resources.messagebox_info; + this.btShowIp.Location = new System.Drawing.Point(113, 334); + this.btShowIp.Name = "btShowIp"; + this.btShowIp.Size = new System.Drawing.Size(23, 23); + this.btShowIp.TabIndex = 8; + this.toolTip1.SetToolTip(this.btShowIp, "Show network information"); + this.btShowIp.UseVisualStyleBackColor = true; + this.btShowIp.Click += new System.EventHandler(this.btShowIp_Click); + // + // btGeneralOptions + // + this.btGeneralOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btGeneralOptions.Font = new System.Drawing.Font("Lucida Console", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btGeneralOptions.Image = global::DolphinWebXplorer2.Properties.Resources.run; + this.btGeneralOptions.Location = new System.Drawing.Point(84, 334); + this.btGeneralOptions.Name = "btGeneralOptions"; + this.btGeneralOptions.Size = new System.Drawing.Size(23, 23); + this.btGeneralOptions.TabIndex = 9; + this.toolTip1.SetToolTip(this.btGeneralOptions, "General Options"); + this.btGeneralOptions.UseVisualStyleBackColor = true; + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(240, 363); + this.Controls.Add(this.btGeneralOptions); + this.Controls.Add(this.btShowIp); + this.Controls.Add(this.lbPaths); + this.Controls.Add(this.btSub); + this.Controls.Add(this.btAdd); + this.Controls.Add(this.cbActive); + this.Controls.Add(this.nudPort); + this.Controls.Add(this.button1); + this.Name = "Form1"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Sunfish"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed); + ((System.ComponentModel.ISupportInitialize)(this.nudPort)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.NumericUpDown nudPort; + private System.Windows.Forms.CheckBox cbActive; + private System.Windows.Forms.Button btAdd; + private System.Windows.Forms.Button btSub; + private System.Windows.Forms.ListBox lbPaths; + private System.Windows.Forms.Button btShowIp; + private System.Windows.Forms.ToolTip toolTip1; + private System.Windows.Forms.ImageList il16; + private System.Windows.Forms.Button btGeneralOptions; + } +} + diff --git a/Sunfish/Sunfish/Form1.cs b/Sunfish/Sunfish/Form1.cs new file mode 100644 index 0000000..632fb32 --- /dev/null +++ b/Sunfish/Sunfish/Form1.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using DolphinWebXplorer2.wx; +using DolphinWebXplorer2.Properties; +using System.IO; +using System.Net.NetworkInformation; +using System.Net.Sockets; + +namespace DolphinWebXplorer2 +{ + public partial class Form1 : Form + { + public const string conffile = "sunfish"; + public Font smallfont; + public Brush itembrushgray; + public Form1() + { + InitializeComponent(); + itembrushgray = new SolidBrush(Color.Gray); + smallfont = new Font(Font.FontFamily,7, FontStyle.Regular); + Icon = Resources.sunfishWebServer; + if (File.Exists(conffile)) + { + WebXplorer.Load(conffile); + } + PopulateData(); + Text += " "+Program.VERSION; + } + + private void PopulateData() + { + Enabled = false; + nudPort.Value = WebXplorer.Port; + cbActive.Checked=WebXplorer.Active; + lbPaths.Items.Clear(); + foreach (WShared sh in WebXplorer.Shares) + lbPaths.Items.Add(sh); + Enabled = true; + } + + private void button1_Click(object sender, EventArgs e) + { + WindowState = FormWindowState.Minimized; + } + + private void Form1_FormClosed(object sender, FormClosedEventArgs e) + { + WebXplorer.Save(conffile); + WebXplorer.Stop(); + } + + private void cbActive_CheckedChanged(object sender, EventArgs e) + { + nudPort.Enabled = !cbActive.Checked; + if (!Enabled) + return; + if (cbActive.Checked) + WebXplorer.Start(); + else + WebXplorer.Stop(); + cbActive.Checked = WebXplorer.Active; + } + + private void nudPort_ValueChanged(object sender, EventArgs e) + { + if (!Enabled) + return; + WebXplorer.Port = (int) nudPort.Value; + } + + private void btAdd_Click(object sender, EventArgs e) + { + WShared sh = new WShared("NewShared",@"C:\"); + sh.Enabled = true; + if (FShared.Execute(sh)) + { + WebXplorer.Add(sh); + lbPaths.Items.Add(sh); + } + } + + private void clbPaths_DoubleClick(object sender, EventArgs e) + { + WShared sh = (WShared)lbPaths.SelectedItem; + if (sh==null) + return; + if (FShared.Execute(sh)) + lbPaths.Update(); + } + + private void lbPaths_DrawItem(object sender, DrawItemEventArgs e) + { + e.DrawBackground(); + e.DrawFocusRectangle(); + if (e.Index < 0) + return; + WShared sh = (WShared)lbPaths.Items[e.Index]; + Graphics g=e.Graphics; + int y=e.Bounds.Top+2; + using (Brush itembrush = new SolidBrush(e.ForeColor)) + { + g.DrawImage(sh.Enabled ? Resources.foldericon : Resources.foldericond, 1, y, 24, 24); + g.DrawString(sh.Name, lbPaths.Font, itembrush, 28, y); + g.DrawString(sh.Path, smallfont, itembrushgray, 33, y + 12); + if (sh.AllowSubfolders) + g.DrawImage(Resources.osubf, 16, y + 13); + if (sh.AllowUpload) + g.DrawImage(Resources.ouplo, 3, y + 13); + } + } + + private void lbPaths_SelectedIndexChanged(object sender, EventArgs e) + { + btSub.Enabled = lbPaths.SelectedItem != null; + } + + private void btSub_Click(object sender, EventArgs e) + { + WShared sh = (WShared)lbPaths.SelectedItem; + if (sh==null) + return; + if (MessageBox.Show("Delete access " + sh.Name + "? Can not be undone!", "Delete", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + WebXplorer.Delete(sh); + lbPaths.Items.Remove(sh); + } + } + + private void btShowIp_Click(object sender, EventArgs e) + { + StringBuilder sb = new StringBuilder(WebXplorer.Active?"A":"ina"); + sb.Append("ctive.\r\n"); + foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces()) + { + if (item.NetworkInterfaceType != NetworkInterfaceType.Loopback && item.OperationalStatus == OperationalStatus.Up) + { + foreach (UnicastIPAddressInformation ip in item.GetIPProperties().UnicastAddresses) + { + if (ip.Address.AddressFamily == AddressFamily.InterNetwork) + { + sb.Append(item.Name); + sb.Append(" ("); + sb.Append(item.NetworkInterfaceType); + sb.Append("): "); + sb.Append(ip.Address.ToString()); + sb.Append(":"); + sb.Append(WebXplorer.Port); + sb.Append("\r\n"); + } + } + } + } + MessageBox.Show(sb.ToString(),"Network information",MessageBoxButtons.OK,MessageBoxIcon.Information); + } + } +} diff --git a/Sunfish/Sunfish/Form1.resx b/Sunfish/Sunfish/Form1.resx new file mode 100644 index 0000000..3a8b7aa --- /dev/null +++ b/Sunfish/Sunfish/Form1.resx @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 114, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAq + AQAAAk1TRnQBSQFMAgEBAgEAARABAAEQAQABEAEAARABAAT/AQUBAAj/AUIBTQF2BwABdgMAASgDAAFA + AwABEAMAAQEBAAEEBgABAhgAAYACAAGAAwACgAEAAYADAAGAAQABgAEAAoACAAPAAQADgAMAAf8CAAH/ + AwAC/wEAAf8DAAH/AQAB/wEAAv8CAAP//wD/AAMAAUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEB + BQABgBcAA/8BAAT/BAAE/wQABP8EAAH8AT8C/wQAAfwBPwL/BAAB/AE/Av8EAAHgAQcB4AEHBAAB4AEH + AeABBwQAAeABBwHgAQcEAAHgAQcB4AEHBAAB/AE/Av8EAAH8AT8C/wQAAfwBPwL/BAAE/wQABP8EAAT/ + BAAL + + + \ No newline at end of file diff --git a/Sunfish/Sunfish/HttpServer.cs b/Sunfish/Sunfish/HttpServer.cs new file mode 100644 index 0000000..23795ea --- /dev/null +++ b/Sunfish/Sunfish/HttpServer.cs @@ -0,0 +1,266 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Net; +using System.Web; +using System.Threading; +using DolphinWebXplorer2; + +namespace XWolf +{ + public class HttpServer + { + private int port; + private HttpListener lis = null; + private Thread loop = null; + private bool multiThread = true; + private List processors = new List(); + private List errors = new List(); + private WindowsFirewallRule fwRule; + public delegate void ErrorEventHandler(HttpServer server, Exception e); + public delegate HttpServerProcessor CreateProcessorHandler(HttpServer server); + public event ErrorEventHandler Error; + public event CreateProcessorHandler CreateProcessor; + + public HttpServer(int port) + { + this.port = port; + } + + public bool Start() + { + if (lis != null) + return false; + lis = new HttpListener(); + lis.Prefixes.Add("http://+:" + port + "/"); + try + { + lis.Start(); + } + catch (HttpListenerException e) + { + lis = null; + return false; + } + loop = new Thread(ServerLoop); + loop.Start(); + fwRule = WindowsFirewall.Allow(port); + return true; + } + + private void ServerLoop() + { + for (; ; ) + { + HttpListenerContext ctx = lis.GetContext(); + if (multiThread) + { + new Thread(new ParameterizedThreadStart(MultithreadCall)).Start(ctx); + } + else + CallNewProcessor(ctx); + } + } + + private void MultithreadCall(object octx) + { + lock (processors) + { + processors.Add(Thread.CurrentThread); + } + CallNewProcessor((HttpListenerContext)octx); + lock (processors) + { + processors.Remove(Thread.CurrentThread); + } + } + + private void CallNewProcessor(HttpListenerContext ctx) + { + HttpServerProcessor proc = CreateProcessor == null ? new HttpServerProcessor() : CreateProcessor(this); + proc.server = this; + proc.Process(ctx); + } + + public bool Stop() + { + if (lis == null) + return false; + if (loop != null) + { + try { loop.Abort(); } + catch { }; + loop = null; + } + try { lis.Stop(); } + catch { }; + try { lis.Close(); } + catch { }; + try + { + lis = null; + foreach (Thread son in processors.ToArray()) + try { son.Abort(); } + catch { }; + } + finally + { + WindowsFirewall.Remove(fwRule); + } + return true; + } + + internal void LogError(Exception e) + { + errors.Add(new LogError(e)); + if (Error != null) + Error(this, e); + } + + public bool Up { get { return lis != null; } } + public int Port { get { return port; } set { port = value; } } + public bool MultiThread { get { return multiThread; } set { multiThread = value; } } + } + + public class HttpServerProcessor + { + protected HttpListenerRequest Request; + protected HttpListenerResponse Response; + protected System.Security.Principal.IPrincipal User; + private StreamWriter swout; + private string path; + private Dictionary getArgs = new Dictionary(); + internal HttpServer server; + + internal void Process(HttpListenerContext ctx) + { + Exception error = null; + try + { + Request = ctx.Request; + Response = ctx.Response; + User = ctx.User; + System.Text.Encoding utf8EncoderNoBOM = new System.Text.UTF8Encoding(false); + swout = new StreamWriter(Response.OutputStream, utf8EncoderNoBOM); + Response.Headers[HttpResponseHeader.ContentType] = "text/html"; + Response.Headers[HttpResponseHeader.ContentEncoding] = "UTF-8"; + GetHeaders(); + Process(); + Out.Close(); + } + catch (Exception e) + { + error = e; + try + { + Out.Close(); + } + catch { }; + } + try + { + ctx.Response.Close(); + } + catch { }; + if (error!=null && server != null) + { + server.LogError(error); + } + } + + private void GetHeaders() + { + getArgs.Clear(); + path = Request.Url.LocalPath; + string qs = Request.Url.Query; + if (qs.StartsWith("?")) + { + string[] args = qs.Substring(1).Split('&'); + foreach (string arg in args) + { + int ppos = arg.IndexOf('='); + if (ppos == -1) + getArgs[arg] = "true"; + else + { + string aname = arg.Substring(0, ppos); + string aval = arg.Substring(ppos + 1); + getArgs[aname] = HttpUtility.UrlDecode(aval); + } + } + } + } + + public HttpListenerResponse GetResponse() { return Response; } + + protected void Error404() + { + Response.StatusCode = 404; + Response.StatusDescription = "Not found"; + } + + public void Write(String s) + { + if (s != null) + swout.Write(s); + } + + public void Write(object o) + { + if (o != null) + swout.Write(o); + } + + public void Write(byte[] data) + { + swout.Flush(); + OutStream.Write(data, 0, data.Length); + } + + public void Write(byte[] data, int offset, int count) + { + swout.Flush(); + OutStream.Write(data, offset, count); + } + + public string nl2br(string s) + { + return s.Replace("\r\n", "
").Replace("\n", "
").Replace("\r", "
"); + } + + public string UrlEncode(string url) + { + return HttpUtility.UrlEncode(url); + } + + public string UrlDecode(string url) + { + return HttpUtility.UrlDecode(url); + } + + virtual protected void Process() + { + Error404(); + } + + protected Stream OutStream { get { return Response.OutputStream; } } + protected StreamWriter Out { get { return swout; } } + public string Path { get { return path; } } + public Dictionary GET { get { return getArgs; } } + } + + public class LogError + { + private DateTime time = DateTime.Now; + private Exception e; + + public LogError(Exception e) + { + this.e = e; + } + + public DateTime Time { get { return time; } } + public Exception Exception { get { return e; } } + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwAuthorizedApplication.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwAuthorizedApplication.cs new file mode 100644 index 0000000..dfac91d --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwAuthorizedApplication.cs @@ -0,0 +1,77 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("B5E64FFA-C2C5-444E-A301-FB5E00018050"), TypeLibType(4160)] + [ComImport] + public interface INetFwAuthorizedApplication + { + [DispId(1)] + string Name + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(2)] + string ProcessImageFileName + { + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(3)] + NET_FW_IP_VERSION_ IpVersion + { + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(4)] + NET_FW_SCOPE_ Scope + { + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(5)] + string RemoteAddresses + { + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(6)] + bool Enabled + { + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwAuthorizedApplications.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwAuthorizedApplications.cs new file mode 100644 index 0000000..95b3e92 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwAuthorizedApplications.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("644EFD52-CCF9-486C-97A2-39F352570B30"), TypeLibType(4160)] + [ComImport] + public interface INetFwAuthorizedApplications : IEnumerable + { + [DispId(1)] + int Count + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + void Add([MarshalAs(UnmanagedType.Interface)] [In] INetFwAuthorizedApplication app); + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + void Remove([MarshalAs(UnmanagedType.BStr)] [In] string imageFileName); + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + INetFwAuthorizedApplication Item([MarshalAs(UnmanagedType.BStr)] [In] string imageFileName); + [DispId(-4), TypeLibFunc(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler")] + IEnumerator GetEnumerator(); + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwIcmpSettings.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwIcmpSettings.cs new file mode 100644 index 0000000..cbf0236 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwIcmpSettings.cs @@ -0,0 +1,111 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("A6207B2E-7CDD-426A-951E-5E1CBC5AFEAD"), TypeLibType(4160)] + [ComImport] + public interface INetFwIcmpSettings + { + [DispId(1)] + bool AllowOutboundDestinationUnreachable + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(2)] + bool AllowRedirect + { + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(3)] + bool AllowInboundEchoRequest + { + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(4)] + bool AllowOutboundTimeExceeded + { + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(5)] + bool AllowOutboundParameterProblem + { + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(6)] + bool AllowOutboundSourceQuench + { + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(7)] + bool AllowInboundRouterRequest + { + [DispId(7)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(7)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(8)] + bool AllowInboundTimestampRequest + { + [DispId(8)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(8)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(9)] + bool AllowInboundMaskRequest + { + [DispId(9)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(9)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(10)] + bool AllowOutboundPacketTooBig + { + [DispId(10)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(10)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwMgr.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwMgr.cs new file mode 100644 index 0000000..27b252a --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwMgr.cs @@ -0,0 +1,35 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("F7898AF5-CAC4-4632-A2EC-DA06E5111AF2"), TypeLibType(4160)] + [ComImport] + public interface INetFwMgr + { + [DispId(1)] + INetFwPolicy LocalPolicy + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(2)] + NET_FW_PROFILE_TYPE_ CurrentProfileType + { + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + void RestoreDefaults(); + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + void IsPortAllowed([MarshalAs(UnmanagedType.BStr)] [In] string imageFileName, [In] NET_FW_IP_VERSION_ IpVersion, [In] int portNumber, [MarshalAs(UnmanagedType.BStr)] [In] string localAddress, [In] NET_FW_IP_PROTOCOL_ ipProtocol, [MarshalAs(UnmanagedType.Struct)] out object allowed, [MarshalAs(UnmanagedType.Struct)] out object restricted); + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + void IsIcmpTypeAllowed([In] NET_FW_IP_VERSION_ IpVersion, [MarshalAs(UnmanagedType.BStr)] [In] string localAddress, [In] byte Type, [MarshalAs(UnmanagedType.Struct)] out object allowed, [MarshalAs(UnmanagedType.Struct)] out object restricted); + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwOpenPort.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwOpenPort.cs new file mode 100644 index 0000000..7a34295 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwOpenPort.cs @@ -0,0 +1,92 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("E0483BA0-47FF-4D9C-A6D6-7741D0B195F7"), TypeLibType(4160)] + [ComImport] + public interface INetFwOpenPort + { + [DispId(1)] + string Name + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(2)] + NET_FW_IP_VERSION_ IpVersion + { + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(3)] + NET_FW_IP_PROTOCOL_ Protocol + { + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(4)] + int Port + { + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(5)] + NET_FW_SCOPE_ Scope + { + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(6)] + string RemoteAddresses + { + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(7)] + bool Enabled + { + [DispId(7)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(7)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(8)] + bool BuiltIn + { + [DispId(8)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwOpenPorts.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwOpenPorts.cs new file mode 100644 index 0000000..abeaaed --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwOpenPorts.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("C0E9D7FA-E07E-430A-B19A-090CE82D92E2"), TypeLibType(4160)] + [ComImport] + public interface INetFwOpenPorts : IEnumerable + { + [DispId(1)] + int Count + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + void Add([MarshalAs(UnmanagedType.Interface)] [In] INetFwOpenPort Port); + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + void Remove([In] int portNumber, [In] NET_FW_IP_PROTOCOL_ ipProtocol); + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + INetFwOpenPort Item([In] int portNumber, [In] NET_FW_IP_PROTOCOL_ ipProtocol); + [DispId(-4), TypeLibFunc(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler")] + IEnumerator GetEnumerator(); + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwPolicy.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwPolicy.cs new file mode 100644 index 0000000..5f108b0 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwPolicy.cs @@ -0,0 +1,23 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("D46D2478-9AC9-4008-9DC7-5563CE5536CC"), TypeLibType(4160)] + [ComImport] + public interface INetFwPolicy + { + [DispId(1)] + INetFwProfile CurrentProfile + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + INetFwProfile GetProfileByType([In] NET_FW_PROFILE_TYPE_ profileType); + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwPolicy2.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwPolicy2.cs new file mode 100644 index 0000000..c08c9e0 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwPolicy2.cs @@ -0,0 +1,129 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("98325047-C671-4174-8D81-DEFCD3F03186"), TypeLibType(4160)] + [ComImport] + public interface INetFwPolicy2 + { + [DispId(1)] + int CurrentProfileTypes + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + [DispId(2)] + bool FirewallEnabled + { + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(3)] + object ExcludedInterfaces + { + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Struct)] + get; + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.Struct)] + set; + } + [DispId(4)] + bool BlockAllInboundTraffic + { + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(5)] + bool NotificationsDisabled + { + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(6)] + bool UnicastResponsesToMulticastBroadcastDisabled + { + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(7)] + INetFwRules Rules + { + [DispId(7)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(8)] + INetFwServiceRestriction ServiceRestriction + { + [DispId(8)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(12)] + NET_FW_ACTION_ DefaultInboundAction + { + [DispId(12)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(12)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(13)] + NET_FW_ACTION_ DefaultOutboundAction + { + [DispId(13)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(13)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(14)] + bool IsRuleGroupCurrentlyEnabled + { + [DispId(14)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + [DispId(15)] + NET_FW_MODIFY_STATE_ LocalPolicyModifyState + { + [DispId(15)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + [DispId(9)] + [MethodImpl(MethodImplOptions.InternalCall)] + void EnableRuleGroup([In] int profileTypesBitmask, [MarshalAs(UnmanagedType.BStr)] [In] string group, [In] bool enable); + [DispId(10)] + [MethodImpl(MethodImplOptions.InternalCall)] + bool IsRuleGroupEnabled([In] int profileTypesBitmask, [MarshalAs(UnmanagedType.BStr)] [In] string group); + [DispId(11)] + [MethodImpl(MethodImplOptions.InternalCall)] + void RestoreLocalFirewallDefaults(); + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwProduct.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwProduct.cs new file mode 100644 index 0000000..9ed2b89 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwProduct.cs @@ -0,0 +1,43 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("71881699-18F4-458B-B892-3FFCE5E07F75"), TypeLibType(4160)] + [ComImport] + public interface INetFwProduct + { + [DispId(1)] + object RuleCategories + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Struct)] + get; + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.Struct)] + set; + } + [DispId(2)] + string DisplayName + { + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(3)] + string PathToSignedProductExe + { + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwProducts.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwProducts.cs new file mode 100644 index 0000000..e39e815 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwProducts.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("39EB36E0-2097-40BD-8AF2-63A13B525362"), TypeLibType(4160)] + [ComImport] + public interface INetFwProducts : IEnumerable + { + [DispId(1)] + int Count + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.IUnknown)] + object Register([MarshalAs(UnmanagedType.Interface)] [In] INetFwProduct product); + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + INetFwProduct Item([In] int index); + [DispId(-4), TypeLibFunc(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler")] + IEnumerator GetEnumerator(); + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwProfile.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwProfile.cs new file mode 100644 index 0000000..4a4b51b --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwProfile.cs @@ -0,0 +1,98 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("174A0DDA-E9F9-449D-993B-21AB667CA456"), TypeLibType(4160)] + [ComImport] + public interface INetFwProfile + { + [DispId(1)] + NET_FW_PROFILE_TYPE_ Type + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + [DispId(2)] + bool FirewallEnabled + { + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(3)] + bool ExceptionsNotAllowed + { + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(4)] + bool NotificationsDisabled + { + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(5)] + bool UnicastResponsesToMulticastBroadcastDisabled + { + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(6)] + INetFwRemoteAdminSettings RemoteAdminSettings + { + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(7)] + INetFwIcmpSettings IcmpSettings + { + [DispId(7)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(8)] + INetFwOpenPorts GloballyOpenPorts + { + [DispId(8)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(9)] + INetFwServices Services + { + [DispId(9)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(10)] + INetFwAuthorizedApplications AuthorizedApplications + { + [DispId(10)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwRemoteAdminSettings.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwRemoteAdminSettings.cs new file mode 100644 index 0000000..351c499 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwRemoteAdminSettings.cs @@ -0,0 +1,53 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("D4BECDDF-6F73-4A83-B832-9C66874CD20E"), TypeLibType(4160)] + [ComImport] + public interface INetFwRemoteAdminSettings + { + [DispId(1)] + NET_FW_IP_VERSION_ IpVersion + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(2)] + NET_FW_SCOPE_ Scope + { + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(3)] + string RemoteAddresses + { + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(4)] + bool Enabled + { + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwRule.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwRule.cs new file mode 100644 index 0000000..aeade53 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwRule.cs @@ -0,0 +1,215 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("AF230D27-BABA-4E42-ACED-F524F22CFCE2"), TypeLibType(4160)] + [ComImport] + public interface INetFwRule + { + [DispId(1)] + string Name + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(2)] + string Description + { + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(3)] + string ApplicationName + { + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(4)] + string serviceName + { + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(5)] + int Protocol + { + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(6)] + string LocalPorts + { + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(7)] + string RemotePorts + { + [DispId(7)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(7)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(8)] + string LocalAddresses + { + [DispId(8)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(8)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(9)] + string RemoteAddresses + { + [DispId(9)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(9)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(10)] + string IcmpTypesAndCodes + { + [DispId(10)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(10)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(11)] + NET_FW_RULE_DIRECTION_ Direction + { + [DispId(11)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(11)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(12)] + object Interfaces + { + [DispId(12)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Struct)] + get; + [DispId(12)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.Struct)] + set; + } + [DispId(13)] + string InterfaceTypes + { + [DispId(13)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(13)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(14)] + bool Enabled + { + [DispId(14)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(14)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(15)] + string Grouping + { + [DispId(15)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(15)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(16)] + int Profiles + { + [DispId(16)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(16)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(17)] + bool EdgeTraversal + { + [DispId(17)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(17)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(18)] + NET_FW_ACTION_ Action + { + [DispId(18)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(18)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwRule2.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwRule2.cs new file mode 100644 index 0000000..cbd4456 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwRule2.cs @@ -0,0 +1,225 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("9C27C8DA-189B-4DDE-89F7-8B39A316782C"), TypeLibType(4160)] + [ComImport] + public interface INetFwRule2 : INetFwRule + { + [DispId(1)] + string Name + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(2)] + string Description + { + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(3)] + string ApplicationName + { + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(4)] + string serviceName + { + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(5)] + int Protocol + { + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(6)] + string LocalPorts + { + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(7)] + string RemotePorts + { + [DispId(7)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(7)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(8)] + string LocalAddresses + { + [DispId(8)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(8)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(9)] + string RemoteAddresses + { + [DispId(9)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(9)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(10)] + string IcmpTypesAndCodes + { + [DispId(10)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(10)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(11)] + NET_FW_RULE_DIRECTION_ Direction + { + [DispId(11)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(11)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(12)] + object Interfaces + { + [DispId(12)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Struct)] + get; + [DispId(12)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.Struct)] + set; + } + [DispId(13)] + string InterfaceTypes + { + [DispId(13)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(13)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(14)] + bool Enabled + { + [DispId(14)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(14)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(15)] + string Grouping + { + [DispId(15)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(15)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(16)] + int Profiles + { + [DispId(16)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(16)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(17)] + bool EdgeTraversal + { + [DispId(17)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(17)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(18)] + NET_FW_ACTION_ Action + { + [DispId(18)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(18)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(19)] + int EdgeTraversalOptions + { + [DispId(19)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(19)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwRules.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwRules.cs new file mode 100644 index 0000000..63418b2 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwRules.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("9C4C6277-5027-441E-AFAE-CA1F542DA009"), TypeLibType(4160)] + [ComImport] + public interface INetFwRules : IEnumerable + { + [DispId(1)] + int Count + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + void Add([MarshalAs(UnmanagedType.Interface)] [In] INetFwRule rule); + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + void Remove([MarshalAs(UnmanagedType.BStr)] [In] string Name); + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + INetFwRule Item([MarshalAs(UnmanagedType.BStr)] [In] string Name); + [DispId(-4), TypeLibFunc(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler")] + IEnumerator GetEnumerator(); + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwService.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwService.cs new file mode 100644 index 0000000..bd4bb3d --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwService.cs @@ -0,0 +1,83 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("79FD57C8-908E-4A36-9888-D5B3F0A444CF"), TypeLibType(4160)] + [ComImport] + public interface INetFwService + { + [DispId(1)] + string Name + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(2)] + NET_FW_SERVICE_TYPE_ Type + { + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + [DispId(3)] + bool Customized + { + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + [DispId(4)] + NET_FW_IP_VERSION_ IpVersion + { + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(4)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(5)] + NET_FW_SCOPE_ Scope + { + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(5)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(6)] + string RemoteAddresses + { + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.BStr)] + get; + [DispId(6)] + [MethodImpl(MethodImplOptions.InternalCall)] + [param: MarshalAs(UnmanagedType.BStr)] + set; + } + [DispId(7)] + bool Enabled + { + [DispId(7)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + [DispId(7)] + [MethodImpl(MethodImplOptions.InternalCall)] + set; + } + [DispId(8)] + INetFwOpenPorts GloballyOpenPorts + { + [DispId(8)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwServiceRestriction.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwServiceRestriction.cs new file mode 100644 index 0000000..cbb84b0 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwServiceRestriction.cs @@ -0,0 +1,25 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("8267BBE3-F890-491C-B7B6-2DB1EF0E5D2B"), TypeLibType(4160)] + [ComImport] + public interface INetFwServiceRestriction + { + [DispId(3)] + INetFwRules Rules + { + [DispId(3)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + void RestrictService([MarshalAs(UnmanagedType.BStr)] [In] string serviceName, [MarshalAs(UnmanagedType.BStr)] [In] string appName, [In] bool RestrictService, [In] bool serviceSidRestricted); + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + bool ServiceRestricted([MarshalAs(UnmanagedType.BStr)] [In] string serviceName, [MarshalAs(UnmanagedType.BStr)] [In] string appName); + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/INetFwServices.cs b/Sunfish/Sunfish/NetFwTypeLib/INetFwServices.cs new file mode 100644 index 0000000..689e049 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/INetFwServices.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +namespace NetFwTypeLib +{ + [Guid("79649BB4-903E-421B-94C9-79848E79F6EE"), TypeLibType(4160)] + [ComImport] + public interface INetFwServices : IEnumerable + { + [DispId(1)] + int Count + { + [DispId(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + get; + } + [DispId(2)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.Interface)] + INetFwService Item([In] NET_FW_SERVICE_TYPE_ svcType); + [DispId(-4), TypeLibFunc(1)] + [MethodImpl(MethodImplOptions.InternalCall)] + [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler")] + IEnumerator GetEnumerator(); + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/NET_FW_ACTION_.cs b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_ACTION_.cs new file mode 100644 index 0000000..107bc14 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_ACTION_.cs @@ -0,0 +1,10 @@ +using System; +namespace NetFwTypeLib +{ + public enum NET_FW_ACTION_ + { + NET_FW_ACTION_BLOCK, + NET_FW_ACTION_ALLOW, + NET_FW_ACTION_MAX + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/NET_FW_IP_PROTOCOL_.cs b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_IP_PROTOCOL_.cs new file mode 100644 index 0000000..204b1fd --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_IP_PROTOCOL_.cs @@ -0,0 +1,10 @@ +using System; +namespace NetFwTypeLib +{ + public enum NET_FW_IP_PROTOCOL_ + { + NET_FW_IP_PROTOCOL_TCP = 6, + NET_FW_IP_PROTOCOL_UDP = 17, + NET_FW_IP_PROTOCOL_ANY = 256 + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/NET_FW_IP_VERSION_.cs b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_IP_VERSION_.cs new file mode 100644 index 0000000..aa3c94d --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_IP_VERSION_.cs @@ -0,0 +1,11 @@ +using System; +namespace NetFwTypeLib +{ + public enum NET_FW_IP_VERSION_ + { + NET_FW_IP_VERSION_V4, + NET_FW_IP_VERSION_V6, + NET_FW_IP_VERSION_ANY, + NET_FW_IP_VERSION_MAX + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/NET_FW_MODIFY_STATE_.cs b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_MODIFY_STATE_.cs new file mode 100644 index 0000000..3ac6bb3 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_MODIFY_STATE_.cs @@ -0,0 +1,10 @@ +using System; +namespace NetFwTypeLib +{ + public enum NET_FW_MODIFY_STATE_ + { + NET_FW_MODIFY_STATE_OK, + NET_FW_MODIFY_STATE_GP_OVERRIDE, + NET_FW_MODIFY_STATE_INBOUND_BLOCKED + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/NET_FW_PROFILE_TYPE2_.cs b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_PROFILE_TYPE2_.cs new file mode 100644 index 0000000..5312829 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_PROFILE_TYPE2_.cs @@ -0,0 +1,11 @@ +using System; +namespace NetFwTypeLib +{ + public enum NET_FW_PROFILE_TYPE2_ + { + NET_FW_PROFILE2_DOMAIN = 1, + NET_FW_PROFILE2_PRIVATE, + NET_FW_PROFILE2_PUBLIC = 4, + NET_FW_PROFILE2_ALL = 2147483647 + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/NET_FW_PROFILE_TYPE_.cs b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_PROFILE_TYPE_.cs new file mode 100644 index 0000000..6465d12 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_PROFILE_TYPE_.cs @@ -0,0 +1,11 @@ +using System; +namespace NetFwTypeLib +{ + public enum NET_FW_PROFILE_TYPE_ + { + NET_FW_PROFILE_DOMAIN, + NET_FW_PROFILE_STANDARD, + NET_FW_PROFILE_CURRENT, + NET_FW_PROFILE_TYPE_MAX + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/NET_FW_RULE_DIRECTION_.cs b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_RULE_DIRECTION_.cs new file mode 100644 index 0000000..8c4dca1 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_RULE_DIRECTION_.cs @@ -0,0 +1,10 @@ +using System; +namespace NetFwTypeLib +{ + public enum NET_FW_RULE_DIRECTION_ + { + NET_FW_RULE_DIR_IN = 1, + NET_FW_RULE_DIR_OUT, + NET_FW_RULE_DIR_MAX + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/NET_FW_SCOPE_.cs b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_SCOPE_.cs new file mode 100644 index 0000000..89478df --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_SCOPE_.cs @@ -0,0 +1,11 @@ +using System; +namespace NetFwTypeLib +{ + public enum NET_FW_SCOPE_ + { + NET_FW_SCOPE_ALL, + NET_FW_SCOPE_LOCAL_SUBNET, + NET_FW_SCOPE_CUSTOM, + NET_FW_SCOPE_MAX + } +} diff --git a/Sunfish/Sunfish/NetFwTypeLib/NET_FW_SERVICE_TYPE_.cs b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_SERVICE_TYPE_.cs new file mode 100644 index 0000000..019ab13 --- /dev/null +++ b/Sunfish/Sunfish/NetFwTypeLib/NET_FW_SERVICE_TYPE_.cs @@ -0,0 +1,12 @@ +using System; +namespace NetFwTypeLib +{ + public enum NET_FW_SERVICE_TYPE_ + { + NET_FW_SERVICE_FILE_AND_PRINT, + NET_FW_SERVICE_UPNP, + NET_FW_SERVICE_REMOTE_DESKTOP, + NET_FW_SERVICE_NONE, + NET_FW_SERVICE_TYPE_MAX + } +} diff --git a/Sunfish/Sunfish/Program.cs b/Sunfish/Sunfish/Program.cs new file mode 100644 index 0000000..cc63df2 --- /dev/null +++ b/Sunfish/Sunfish/Program.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; +using DolphinWebXplorer2.wx; + +namespace DolphinWebXplorer2 +{ + static class Program + { + public static string VERSION = "0.7c"; + /// + /// Punto de entrada principal para la aplicación. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + try + { + Application.Run(new Form1()); + } + finally + { + WebXplorer.Stop(); + } + } + } +} diff --git a/Sunfish/Sunfish/Properties/AssemblyInfo.cs b/Sunfish/Sunfish/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2ff5702 --- /dev/null +++ b/Sunfish/Sunfish/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// La información general sobre un ensamblado se controla mediante el siguiente +// conjunto de atributos. Cambie estos atributos para modificar la información +// asociada con un ensamblado. +[assembly: AssemblyTitle("SunFishWebXplorer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("XWolf")] +[assembly: AssemblyProduct("SunFishWebXplorer")] +[assembly: AssemblyCopyright("Copyright © XWolf 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Si establece ComVisible como false, los tipos de este ensamblado no estarán visibles +// para los componentes COM. Si necesita obtener acceso a un tipo de este ensamblado desde +// COM, establezca el atributo ComVisible como true en este tipo. +[assembly: ComVisible(false)] + +// El siguiente GUID sirve como identificador de typelib si este proyecto se expone a COM +[assembly: Guid("5d6a0bda-58db-4991-a076-747ca064ebf0")] + +// La información de versión de un ensamblado consta de los cuatro valores siguientes: +// +// Versión principal +// Versión secundaria +// Número de versión de compilación +// Revisión +// +// Puede especificar todos los valores o establecer como predeterminados los números de versión de compilación y de revisión +// mediante el asterisco ('*'), como se muestra a continuación: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Sunfish/Sunfish/Properties/Resources.Designer.cs b/Sunfish/Sunfish/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9d481ac --- /dev/null +++ b/Sunfish/Sunfish/Properties/Resources.Designer.cs @@ -0,0 +1,221 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DolphinWebXplorer2.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DolphinWebXplorer2.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap foldericon { + get { + object obj = ResourceManager.GetObject("foldericon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap foldericond { + get { + object obj = ResourceManager.GetObject("foldericond", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap messagebox_info { + get { + object obj = ResourceManager.GetObject("messagebox_info", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap osubf { + get { + object obj = ResourceManager.GetObject("osubf", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap ouplo { + get { + object obj = ResourceManager.GetObject("ouplo", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap rename { + get { + object obj = ResourceManager.GetObject("rename", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap run { + get { + object obj = ResourceManager.GetObject("run", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap screen { + get { + object obj = ResourceManager.GetObject("screen", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized string similar to html{ + /// background:#BBBBBB; + ///} + /// + ///body{ + /// margin:0 auto 0 auto; + /// max-width: 900px; + /// background:white; + /// box-shadow: 0 0 5px; + /// padding:2px; + /// font-family:verdana; + /// font-size:12px; + /// padding:0; + ///} + /// + ///#head{ + /// height:68px; + /// background:#F5F6F7 url(/·logo) 20px 20px no-repeat; + /// padding:10px 10px 10px 80px; + /// font-family: verdana; + /// font-size:25px; + /// border-bottom: solid 1px #DADBDC; + /// box-shadow: 0 3px 2px -2px gray; + /// position:relative; + ///} + ///#head a{ + /// color:black; + /// text-decoration:none; + ///} + ///#head a:hover [rest of string was truncated]";. + /// + internal static string site { + get { + return ResourceManager.GetString("site", resourceCulture); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). + /// + internal static System.Drawing.Icon sunfishWebServer { + get { + object obj = ResourceManager.GetObject("sunfishWebServer", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap sws { + get { + object obj = ResourceManager.GetObject("sws", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap t_delete { + get { + object obj = ResourceManager.GetObject("t_delete", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap t_execute { + get { + object obj = ResourceManager.GetObject("t_execute", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Sunfish/Sunfish/Properties/Resources.resx b/Sunfish/Sunfish/Properties/Resources.resx new file mode 100644 index 0000000..783f4e4 --- /dev/null +++ b/Sunfish/Sunfish/Properties/Resources.resx @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\resources\site.css;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + + ..\Resources\sunfishWebServer.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\pencil.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\delete.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\osubf.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\ouplo.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\foldericon.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\foldericond.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\messagebox_info1.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\sws.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\play.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\run.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\share.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Sunfish/Sunfish/Properties/Settings.Designer.cs b/Sunfish/Sunfish/Properties/Settings.Designer.cs new file mode 100644 index 0000000..ec38d51 --- /dev/null +++ b/Sunfish/Sunfish/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DolphinWebXplorer2.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Sunfish/Sunfish/Properties/Settings.settings b/Sunfish/Sunfish/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Sunfish/Sunfish/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Sunfish/Sunfish/Resources/bt_plus.bmp b/Sunfish/Sunfish/Resources/bt_plus.bmp new file mode 100644 index 0000000..11d8570 --- /dev/null +++ b/Sunfish/Sunfish/Resources/bt_plus.bmp Binary files differ diff --git a/Sunfish/Sunfish/Resources/delete.png b/Sunfish/Sunfish/Resources/delete.png new file mode 100644 index 0000000..5d7169b --- /dev/null +++ b/Sunfish/Sunfish/Resources/delete.png Binary files differ diff --git a/Sunfish/Sunfish/Resources/foldericon.png b/Sunfish/Sunfish/Resources/foldericon.png new file mode 100644 index 0000000..16651d9 --- /dev/null +++ b/Sunfish/Sunfish/Resources/foldericon.png Binary files differ diff --git a/Sunfish/Sunfish/Resources/foldericond.png b/Sunfish/Sunfish/Resources/foldericond.png new file mode 100644 index 0000000..360b602 --- /dev/null +++ b/Sunfish/Sunfish/Resources/foldericond.png Binary files differ diff --git a/Sunfish/Sunfish/Resources/messagebox_info.png b/Sunfish/Sunfish/Resources/messagebox_info.png new file mode 100644 index 0000000..2967e4d --- /dev/null +++ b/Sunfish/Sunfish/Resources/messagebox_info.png Binary files differ diff --git a/Sunfish/Sunfish/Resources/messagebox_info1.png b/Sunfish/Sunfish/Resources/messagebox_info1.png new file mode 100644 index 0000000..7fc297e --- /dev/null +++ b/Sunfish/Sunfish/Resources/messagebox_info1.png Binary files differ diff --git a/Sunfish/Sunfish/Resources/osubf.png b/Sunfish/Sunfish/Resources/osubf.png new file mode 100644 index 0000000..6d799d2 --- /dev/null +++ b/Sunfish/Sunfish/Resources/osubf.png Binary files differ diff --git a/Sunfish/Sunfish/Resources/ouplo.png b/Sunfish/Sunfish/Resources/ouplo.png new file mode 100644 index 0000000..6c846fb --- /dev/null +++ b/Sunfish/Sunfish/Resources/ouplo.png Binary files differ diff --git a/Sunfish/Sunfish/Resources/pencil.png b/Sunfish/Sunfish/Resources/pencil.png new file mode 100644 index 0000000..6966739 --- /dev/null +++ b/Sunfish/Sunfish/Resources/pencil.png Binary files differ diff --git a/Sunfish/Sunfish/Resources/play.png b/Sunfish/Sunfish/Resources/play.png new file mode 100644 index 0000000..4e52429 --- /dev/null +++ b/Sunfish/Sunfish/Resources/play.png Binary files differ diff --git a/Sunfish/Sunfish/Resources/run.png b/Sunfish/Sunfish/Resources/run.png new file mode 100644 index 0000000..aa83249 --- /dev/null +++ b/Sunfish/Sunfish/Resources/run.png Binary files differ diff --git a/Sunfish/Sunfish/Resources/share.png b/Sunfish/Sunfish/Resources/share.png new file mode 100644 index 0000000..3dd66cc --- /dev/null +++ b/Sunfish/Sunfish/Resources/share.png Binary files differ diff --git a/Sunfish/Sunfish/Resources/site.css b/Sunfish/Sunfish/Resources/site.css new file mode 100644 index 0000000..ac1732a --- /dev/null +++ b/Sunfish/Sunfish/Resources/site.css @@ -0,0 +1,173 @@ +html{ + background:#BBBBBB; +} + +body{ + margin:0 auto 0 auto; + max-width: 900px; + background:white; + box-shadow: 0 0 5px; + padding:2px; + font-family:verdana; + font-size:12px; + padding:0; +} + +#head{ + height:68px; + background:#F5F6F7 url(/�logo) 20px 20px no-repeat; + padding:10px 10px 10px 80px; + font-family: verdana; + font-size:25px; + border-bottom: solid 1px #DADBDC; + box-shadow: 0 3px 2px -2px gray; + position:relative; +} +#head a{ + color:black; + text-decoration:none; +} +#head a:hover{ + color:#0077FF; +} +#head a:active{ + color:black; +} +#head a:visited{ + color:black; +} +#breadcrum{ + font-size:12px; + position:absolute; + bottom:0px; + padding:0 0 5px 5px; +} +#breadcrum a,#breadcrum a:visited{ + color:#333344; +} +#breadcrum a:hover{ + color:#EEEEEE; + text-shadow: 0 0 2px gray; +} + +#breadcrum a:active{ + color:#EEEEFF; +} + +#headtoolbox { + position:absolute; + top:55px; + right:20px; + width:150px; + height:24px; + text-align:right; +} + +#main{ + padding:12px; +} + +.item{ + cursor:pointer; cursor: hand; + padding:4px; + margin:5px 5px 9px 5px; + width:420px; + position: relative; + display:inline-block; + border-bottom:1px solid #EEEEEE; +} +.item:hover{ + border:1px solid #66A7E8; + background-color:#EEF4FF; + margin:4px 4px 9px 4px; + border-radius:2px; +} +.item a{ + color:black; + text-decoration:none; +} +.item:hover a{ + color:#0077FF; +} +.item a:active{ + color:white; +} +.item:hover .itool{ + //display:inherit; + opacity:1; +} +.iname{ + position:absolute; + top:2px; + left:43px; + width:380px; + text-overflow: ellipsis; + overflow:hidden; + white-space: nowrap; +} +.iinfo{ + position:absolute; + top:20px; + left:45px; + color: #555; +} +.itool{ + position:absolute; + bottom: 2px; + right: 2px; + //display:none; + opacity:0.1; +} +.itool img{ + margin-left:10px; +} +.itool img:hover{ + -webkit-filter: contrast(3); + filter: contrast(3); +} +.activity{ + background-color:#F5F6F7; + padding:10px; + border-radius:4px; + box-shadow:1px 2px 4px gray; + margin: 0 auto 0 auto; + width:70%; +} +.activity input{ + width:100%; +} +.activity input[type='submit']{ + width:initial; + float:right; + margin-top: 5px; + margin-left: 5px; +} +.activity input[type='button']{ + width:initial; + float:right; + margin-top: 5px; + margin-left: 5px; +} +.activity::after{ + content:'.'; + display:block; + height: 0; + clear: both; + visibility: hidden; +} +.activity form{ + margin:0; + padding:0; +} +.error{ + border:1px solid #E8A766; + background-color:#FFF4EE; + padding:5px; + border-radius:3px; +} +.htool { + width:24px; + height:24px; + padding:0; + margin-left:7px; +} \ No newline at end of file diff --git a/Sunfish/Sunfish/Resources/sunfishWebServer.ico b/Sunfish/Sunfish/Resources/sunfishWebServer.ico new file mode 100644 index 0000000..f79f660 --- /dev/null +++ b/Sunfish/Sunfish/Resources/sunfishWebServer.ico Binary files differ diff --git a/Sunfish/Sunfish/Resources/sws.png b/Sunfish/Sunfish/Resources/sws.png new file mode 100644 index 0000000..483c505 --- /dev/null +++ b/Sunfish/Sunfish/Resources/sws.png Binary files differ diff --git a/Sunfish/Sunfish/Sunfish.csproj b/Sunfish/Sunfish/Sunfish.csproj new file mode 100644 index 0000000..490000a --- /dev/null +++ b/Sunfish/Sunfish/Sunfish.csproj @@ -0,0 +1,178 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {5511BE4E-6AE1-479B-B5CD-5A20DC4C13F7} + WinExe + Properties + DolphinWebXplorer2 + Sunfish + v3.5 + 512 + sunfishWebServer.ico + + + + + + + 3.5 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + 3.5 + + + + + + + + + Form + + + Form1.cs + + + Form + + + FShared.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Form1.cs + + + FShared.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + + + \ No newline at end of file diff --git a/Sunfish/Sunfish/Win32.cs b/Sunfish/Sunfish/Win32.cs new file mode 100644 index 0000000..3dbc11b --- /dev/null +++ b/Sunfish/Sunfish/Win32.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; +using System.Drawing; +using System.ComponentModel; + +namespace DolphinWebXplorer2 +{ + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct SHFILEINFO + { + public IntPtr hIcon; + public IntPtr iIcon; + public uint dwAttributes; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] + public string szDisplayName; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] + public string szTypeName; + }; + + public class ShellIcon : IDisposable + { + private Bitmap icon = null; + + public ShellIcon(string path) + { + SHFILEINFO shinfo = Win32.GetIcon(path); + if (shinfo.hIcon != IntPtr.Zero) + { + using (Icon i = Icon.FromHandle(shinfo.hIcon)) + { + icon = new Bitmap(i.Width, i.Height); + using (Graphics g = Graphics.FromImage(icon)) + g.DrawIcon(i, 0, 0); + } + Win32.DestroyIcon(shinfo.hIcon); + } + } + + public void Dispose() + { + if (icon != null) + icon.Dispose(); + } + + public Bitmap Image { get { return icon; } } + } + + class Win32 + { + public const uint SHGFI_ICON = 0x000000100; // get icon + public const uint SHGFI_DISPLAYNAME = 0x000000200; // get display name + public const uint SHGFI_TYPENAME = 0x000000400; // get type name + public const uint SHGFI_ATTRIBUTES = 0x000000800; // get attributes + public const uint SHGFI_ICONLOCATION = 0x000001000; // get icon location + public const uint SHGFI_EXETYPE = 0x000002000; // return exe type + public const uint SHGFI_SYSICONINDEX = 0x000004000; // get system icon index + public const uint SHGFI_LINKOVERLAY = 0x000008000; // put a link overlay on icon + public const uint SHGFI_SELECTED = 0x000010000; // show icon in selected state + public const uint SHGFI_ATTR_SPECIFIED = 0x000020000; // get only specified attributes + public const uint SHGFI_LARGEICON = 0x000000000; // get large icon + public const uint SHGFI_SMALLICON = 0x000000001; // get small icon + public const uint SHGFI_OPENICON = 0x000000002; // get open icon + public const uint SHGFI_SHELLICONSIZE = 0x000000004; // get shell size icon + public const uint SHGFI_PIDL = 0x000000008; // pszPath is a pidl + public const uint SHGFI_USEFILEATTRIBUTES = 0x000000010; // use passed dwFileAttribute + public const uint SHGFI_ADDOVERLAYS = 0x000000020; // apply the appropriate overlays + public const uint SHGFI_OVERLAYINDEX = 0x000000040; // Get the index of the overlay + + public const uint FILE_ATTRIBUTE_DIRECTORY = 0x00000010; + public const uint FILE_ATTRIBUTE_NORMAL = 0x00000080; + + [DllImport("shell32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)] + public static extern IntPtr SHGetFileInfoW(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags); + + [DllImport("User32.dll")] + public static extern int DestroyIcon(IntPtr hIcon); + + public static SHFILEINFO GetIcon(string path) + { + SHFILEINFO shinfo = new SHFILEINFO(); + IntPtr ih = SHGetFileInfoW(path, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), Win32.SHGFI_ICON | Win32.SHGFI_LARGEICON); + return shinfo; + } + + public static string GetMimeType(string fileName) + { + string mimeType = "application/unknown"; + string ext = System.IO.Path.GetExtension(fileName).ToLower(); + Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext); + if (regKey != null && regKey.GetValue("Content Type") != null) + mimeType = regKey.GetValue("Content Type").ToString(); + return mimeType; + } + } +} diff --git a/Sunfish/Sunfish/WindowsFirewall.cs b/Sunfish/Sunfish/WindowsFirewall.cs new file mode 100644 index 0000000..41e8297 --- /dev/null +++ b/Sunfish/Sunfish/WindowsFirewall.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NetFwTypeLib; +using System.Reflection; +using System.Security.Cryptography; + +namespace DolphinWebXplorer2 +{ + public class WindowsFirewall + { + private static INetFwPolicy2 FirewallPolicy() + { + return (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2")); + } + + public static WindowsFirewallRule Allow(int port) + { + string path=Assembly.GetExecutingAssembly().Location; + INetFwRule firewallRule = CreateRule(); + firewallRule.Action = NET_FW_ACTION_.NET_FW_ACTION_ALLOW; + firewallRule.Description = "Used to allow SunFish on "+path; + firewallRule.Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN; + firewallRule.Protocol = (int)NET_FW_IP_PROTOCOL_.NET_FW_IP_PROTOCOL_TCP; + firewallRule.Enabled = true; + firewallRule.InterfaceTypes = "All"; + firewallRule.Name = "SunFish ("+port+") ["+idid(path)+"]"; + firewallRule.LocalPorts = port.ToString(); + FirewallPolicy().Rules.Add(firewallRule); + return new WindowsFirewallRule(firewallRule); + } + + public static void Remove(WindowsFirewallRule rule) + { + if (rule == null) + return; + RemovePolicy(rule.Name); + } + + private static INetFwRule CreateRule() + { + return (INetFwRule)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FWRule")); + } + + private static void RemovePolicy(string id) + { + FirewallPolicy().Rules.Remove(id); + } + + private static string idid(string id) + { + SHA1 sha1 = SHA1.Create(); + byte [] hash=sha1.ComputeHash(Encoding.UTF8.GetBytes(id)); + return Convert.ToBase64String(hash); + } + } + + public class WindowsFirewallRule + { + private INetFwRule rule; + private string name; + + internal WindowsFirewallRule(INetFwRule rule) + { + this.rule = rule; + name = rule.Name; + } + + public string Name { get { return name; } } + } +} diff --git a/Sunfish/Sunfish/app.manifest b/Sunfish/Sunfish/app.manifest new file mode 100644 index 0000000..592ce95 --- /dev/null +++ b/Sunfish/Sunfish/app.manifest @@ -0,0 +1,22 @@ + + + + + + + + + + + + diff --git a/Sunfish/Sunfish/sunfishWebServer.ico b/Sunfish/Sunfish/sunfishWebServer.ico new file mode 100644 index 0000000..f79f660 --- /dev/null +++ b/Sunfish/Sunfish/sunfishWebServer.ico Binary files differ diff --git a/Sunfish/Sunfish/uHttp.cs b/Sunfish/Sunfish/uHttp.cs new file mode 100644 index 0000000..46feb31 --- /dev/null +++ b/Sunfish/Sunfish/uHttp.cs @@ -0,0 +1,164 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Net; +using System.IO; +using System.Drawing; +using XWolf; + + +namespace Umbrella +{ + class uHttp : HttpServerProcessor + { + static byte[] logo; + + static uHttp(){ + MemoryStream ms=new MemoryStream(); + Properties.Resources.logo.Save(ms, System.Drawing.Imaging.ImageFormat.Png); + ms.Close(); + logo = ms.ToArray(); + } + + private void Header() + { + Write("Umbrella"); + Write(""); + Write(""); + Write("
Umbrella" + Program.version + "
"); +#if TRACE + Write(" TRACE "); +#endif +#if DEBUG + Write(" DEBUG "); +#endif + Write("

"); + //Listado servicios + Write(""); + foreach (uService serv in uServices.Services) + { + Write(""); + } + Write("
Servicios:
" + serv.Name + "
"); + } + + private void Foot() + { + Out.Write("
"); + } + + override protected void Process(){ + try + { + if (Path.StartsWith("/service_")) + { + doService(Path.Substring(1)); + return; + } + } + catch (Exception e) + { + doError(e); + return; + } + switch (Path.ToLower()) + { + case "/": + doHome(); + break; + case "/favicon.ico": + doFavicon(); + break; + case "/logo": + doLogo(); + break; + case "/bg": + doBack(); + break; + default: + Error404(); + break; + } + } + + private void doHome() + { + Header(); + + + + //misc + Foot(); + } + + private void doService(string srid) + { + uService srv=uServices.ByPath(srid); + if (srv == null) + throw new Exception("No existe el servicio"); + if (srv.Acciona(this)) + doGo(Path); + else + { + srv.setPath(srid); + if (srv.rsubpath == "") + { + Header(); + srv.Execute(); + Foot(); + } + else if (srv.rsubpathbin) + srv.Execute(srv.rsubpath); + else + { + Header(); + srv.Execute(srv.rsubpath); + Foot(); + } + } + } + + private void doError(Exception e) + { + Header(); + Write(""+e.GetType().FullName+": "+e.Message+"

"); + Write(nl2br(e.StackTrace)); + Write("


Indice"); + Foot(); + } + + private void doFavicon() + { + Response.Headers[HttpResponseHeader.ContentType] = "image/vnd.microsoft.icon"; + MemoryStream ms=new MemoryStream(); + Properties.Resources.ico.Save(ms); + Write(ms.ToArray()); + ms.Close(); + } + + private void doBack() + { + Response.Headers[HttpResponseHeader.ContentType] = "image/jpeg"; + Write(loadBG()); + } + + private void doLogo() + { + Response.Headers[HttpResponseHeader.ContentType] = "image/png"; + Write(logo); + } + + private void doGo(string href) + { + Write(""); + } + + private byte[] loadBG() + { + MemoryStream ms = new MemoryStream(); + Properties.Resources.ubg.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); + ms.Close(); + return ms.ToArray(); + } + } +} diff --git a/Sunfish/Sunfish/wx/WShared.cs b/Sunfish/Sunfish/wx/WShared.cs new file mode 100644 index 0000000..a4d5b7a --- /dev/null +++ b/Sunfish/Sunfish/wx/WShared.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace DolphinWebXplorer2.wx +{ + public class WShared + { + private string name; + private string path; + private bool enabled; + private bool allowSubfolders; + private bool allowUpload; + private bool allowDeletion; + private bool allowRename; + private bool allowExecution; + private bool allowNewFolder; + + public WShared() + { + } + + public WShared(string name, string path) + { + this.name = name; + Path = path; + } + + public string GetLocalPath(string path) + { + return this.path + path.Replace('/',System.IO.Path.DirectorySeparatorChar); + } + + public string GetRemotePath(string path) + { + return '/' + name +'/'+ path; + } + + public string Name { get { return name; } set { name = value; } } + public string Path + { + get { return path; } + set + { + path = value; + if (!path.EndsWith("\\")) + path += '\\'; + } + } + public bool Enabled { get { return enabled; } set { enabled = value; } } + public bool AllowSubfolders { get { return allowSubfolders; } set { allowSubfolders = value; } } + public bool AllowUpload { get { return allowUpload; } set { allowUpload = value; } } + public bool AllowDeletion { get { return allowDeletion; } set { allowDeletion = value; } } + public bool AllowRename { get { return allowRename; } set { allowRename = value; } } + public bool AllowExecution { get { return allowExecution; } set { allowExecution = value; } } + public bool AllowNewFolder { get { return allowNewFolder; } set { allowNewFolder = value; } } + } +} diff --git a/Sunfish/Sunfish/wx/WebXplorer.cs b/Sunfish/Sunfish/wx/WebXplorer.cs new file mode 100644 index 0000000..e8ea722 --- /dev/null +++ b/Sunfish/Sunfish/wx/WebXplorer.cs @@ -0,0 +1,766 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Net; +using System.Windows.Forms; +using System.Diagnostics; +using System.IO; +using XWolf; +using System.Drawing; +using System.Drawing.Imaging; +using DolphinWebXplorer2.Properties; +using System.Reflection; + +namespace DolphinWebXplorer2.wx +{ + static class WebXplorer + { + private static List shares = new List(); + private static HttpServer server; + public static byte[] res_logo; + public static byte[] res_favicon; + public static byte[] res_tdelete; + public static byte[] res_texecute; + public static byte[] res_rename; + public static byte[] res_screen; + public static byte[] res_folder; + private static int port = 90; + public static Random rnd = new Random(); + private static Dictionary acodes = new Dictionary(); + + static WebXplorer() + { + using (MemoryStream ms = new MemoryStream()) + { + Resources.sunfishWebServer.Save(ms); + ms.Position = 0; + res_favicon = ms.ToArray(); + } + res_logo = GetImageData(Resources.sws, ImageFormat.Png); + res_tdelete = GetImageData(Resources.t_delete, ImageFormat.Png); + res_texecute = GetImageData(Resources.t_execute, ImageFormat.Png); + res_rename = GetImageData(Resources.rename, ImageFormat.Png); + res_screen = GetImageData(Resources.screen, ImageFormat.Png); + res_folder = GetImageData(Resources.foldericon, ImageFormat.Png); + Win32.DestroyIcon(Win32.GetIcon(".").hIcon); + } + + private static byte[] GetImageData(Image i, ImageFormat format) + { + using (MemoryStream ms = new MemoryStream()) + { + i.Save(ms, format); + ms.Position = 0; + return ms.ToArray(); + } + } + + public static void Add(WShared sh) + { + shares.Add(sh); + } + + public static WShared Get(string index) + { + foreach (WShared w in shares) + if (w.Name.Equals(index, StringComparison.CurrentCultureIgnoreCase)) + return w; + return null; + } + + public static void Delete(string index) + { + shares.Remove(Get(index)); + } + + public static void Delete(WShared ws) + { + shares.Remove(ws); + } + + public static void Start() + { + if (server != null) + Stop(); + server = new HttpServer(port); + server.CreateProcessor += new HttpServer.CreateProcessorHandler(server_CreateProcessor); + server.Error += new HttpServer.ErrorEventHandler(server_Error); + if (!server.Start()) + server = null; + } + + static void server_Error(HttpServer server, Exception e) + { + if (!(e is ObjectDisposedException) && !(e is HttpListenerException)) + MessageBox.Show(e.Message + "\r\n" + e.StackTrace, e.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + static HttpServerProcessor server_CreateProcessor(HttpServer server) + { + return new XplorerProcessor(); + } + + public static void Stop() + { + if (server == null) + return; + server.Stop(); + server = null; + } + + public static void Save(string filename) + { + Dictionary YN = new Dictionary(); + YN[true] = "Y"; + YN[false] = "N"; + List data = new List(); + data.Add("#Sunfish WebXplorer V" + Program.VERSION + " (The new Dolphin WebXplorer) (C) XWolf 2014"); + data.Add(""); + data.Add("#Each line is: ||||||||"); + data.Add(""); + data.Add("Active: " + YN[Active]); + data.Add("Port: " + port); + foreach (WShared s in shares) + data.Add("Shared: " + s.Name + "|" + s.Path + "|" + YN[s.Enabled] + "|" + YN[s.AllowSubfolders] + "|" + YN[s.AllowUpload] + "|" + YN[s.AllowDeletion] + "|" + YN[s.AllowRename] + "|" + YN[s.AllowExecution] + "|" + YN[s.AllowNewFolder]); + File.WriteAllLines(filename, data.ToArray()); + } + + public static void Load(string filename) + { + string[] data = File.ReadAllLines(filename); + bool setactive = false; + shares.Clear(); + Stop(); + foreach (string l in data) + { + if (l.StartsWith("#")) + continue; + int dp = l.IndexOf(':'); + if (dp < 0) + continue; + string cmd = l.Substring(0, dp); + string par = l.Substring(dp + 1).Trim(); + switch (cmd.ToLower()) + { + case "active": + setactive = "Y".Equals(par); + break; + case "port": + int.TryParse(par, out port); + break; + case "shared": + { + string[] s = par.Split('|'); + string sname = s.Length > 0 ? s[0] : null; + string spath = s.Length > 1 ? s[1] : null; + if (sname != null && spath != null) + { + WShared sh = new WShared(sname, spath); + sh.Enabled = "Y".Equals(s.Length > 2 ? s[2] : null); + sh.AllowSubfolders = "Y".Equals(s.Length > 3 ? s[3] : null); + sh.AllowUpload = "Y".Equals(s.Length > 4 ? s[4] : null); + sh.AllowDeletion = "Y".Equals(s.Length > 5 ? s[5] : null); + sh.AllowRename = "Y".Equals(s.Length > 6 ? s[6] : null); + sh.AllowExecution = "Y".Equals(s.Length > 7 ? s[7] : null); + sh.AllowNewFolder = "Y".Equals(s.Length > 8 ? s[8] : null); + Add(sh); + } + } + break; + } + } + if (setactive) + Start(); + } + + public static bool Contains(WShared sh) + { + return shares.Contains(sh); + } + + public static string CreateACode(string key) + { + string result = GenACode(); + acodes[key] = result; + return result; + } + + public static bool CheckACode(string key,string acode) + { + if (acodes.ContainsKey(key)) + { + bool result = acode == acodes[key]; + acodes.Remove(key); + return result; + } + return false; + } + + private static string GenACode() + { + string allowed = "_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + StringBuilder result = new StringBuilder(16); + while (result.Length < 16) + result.Append(allowed[rnd.Next(allowed.Length)]); + return result.ToString(); + } + + public static WShared[] Shares { get { return shares.ToArray(); } } + public static bool Active { get { return server != null; } } + public static int Port { get { return port; } set { if (Active) throw new Exception("Can't change port while running"); else port = value; } } + } + + class XplorerProcessor : HttpServerProcessor + { + protected override void Process() + { + string path = Path.Substring(1); + if (path.StartsWith("·") || path == "favicon.ico") + Resource(path.Substring(1)); + else + { + string shpath = path.Contains('/') ? path.Substring(0, path.IndexOf('/')) : null; + string rpath = shpath == null ? null : path.Substring(shpath.Length + 1); + string action = GET.ContainsKey("Action") ? GET["Action"] : null; + rpath = UDec(rpath); + WShared sh = WebXplorer.Get(shpath); + if (sh == null) + Menu(); + else if (action != null) + { + switch (action) + { + case "ICO": + GetIcon(sh, rpath); + break; + case "GET": + Download(sh, rpath); + break; + case "REN": + PageRename(sh, rpath); + break; + case "RENDO": + PageRenameDo(sh, rpath); + break; + case "RUN": + PageExecute(sh, rpath); + break; + case "DEL": + PageDelete(sh, rpath); + break; + case "DELDO": + PageDeleteDo(sh, rpath); + break; + case "MKD": + PageCreateFolder(sh, rpath); + break; + case "MKDDO": + PageCreateFolderDo(sh, rpath); + break; + } + } + else + if (sh.Enabled) + Shared(sh, rpath); + else + Menu(); + } + } + + private void Resource(string res) + { + switch (res) + { + case "logo": + BinaryOut(WebXplorer.res_logo, "image/png"); + break; + case "avicon.ico": + BinaryOut(WebXplorer.res_favicon, "image/vnd.microsoft.icon"); + break; + case "t_delete": + BinaryOut(WebXplorer.res_tdelete, "image/png"); + break; + case "t_execute": + BinaryOut(WebXplorer.res_texecute, "image/png"); + break; + case "rename": + BinaryOut(WebXplorer.res_rename, "image/png"); + break; + case "screen": + BinaryOut(WebXplorer.res_screen, "image/png"); + break; + case "folder": + BinaryOut(WebXplorer.res_folder, "image/png"); + break; + case "/Sunfish.exe": + BinaryOut(GetMyself(), "application/x-msdownload"); + break; + } + } + + private void GetIcon(WShared sh, string path) + { + path = sh.GetLocalPath(path); + try + { + //FileInfo fi = new FileInfo(path); + //if (fi.Length < 1024 * 1024) + //{ + // try{ + // using (Image i = Image.FromFile(path)) + // { + // using (Image t = i.GetThumbnailImage(32, 32, null, IntPtr.Zero)) + // { + // BinaryOut((Bitmap)t); + // return; + // } + // } + // }catch{}; + //} + using (ShellIcon i = new ShellIcon(path)) + BinaryOut(i.Image); + } + catch (Exception e) + { + Out.WriteLine(e.GetType().Name); + Out.WriteLine(e.Message); + } + } + + private void BinaryOut(Bitmap image) + { + using (MemoryStream ms = new MemoryStream()) + { + image.Save(ms, ImageFormat.Png); + ms.Position = 0; + BinaryOut(ms, "image/png"); + } + } + + private void BinaryOut(Icon image) + { + using (MemoryStream ms = new MemoryStream()) + { + image.Save(ms); + ms.Position = 0; + BinaryOut(ms, "image/vnd.microsoft.icon"); + } + } + + private void BinaryOut(MemoryStream ms, string mimetype) + { + Response.Headers[HttpResponseHeader.ContentType] = mimetype; + Write(ms.ToArray()); + } + + private void BinaryOut(FileStream fs, string mimetype) + { + if (mimetype != null) + Response.Headers[HttpResponseHeader.ContentType] = mimetype; + byte[] buffer = new byte[1024 * 64]; + int readed = buffer.Length; + while (readed == buffer.Length) + { + readed = fs.Read(buffer, 0, buffer.Length); + Write(buffer, 0, readed); + } + } + + private void BinaryOut(byte[] data, string mimetype) + { + Response.Headers[HttpResponseHeader.ContentType] = mimetype; + Write(data); + } + + private byte[] GetMyself() + { + return File.ReadAllBytes(Assembly.GetExecutingAssembly().Location); + } + + private void Menu() + { + Header("Home", null, null); + foreach (WShared s in WebXplorer.Shares) + { + if (!s.Enabled) + continue; + ItemDirectory(null, s.Name, '/' + s.Name + '/'); + } + Footer(); + } + + private void Shared(WShared sh, string path) + { + if (!sh.AllowSubfolders) + path = ""; + Header(sh.Name, sh, path.Split('/')); + string rpath = sh.GetLocalPath(path); + try + { + if (sh.AllowSubfolders) + { + foreach (string dir in Directory.GetDirectories(rpath)) + { + string name = System.IO.Path.GetFileName(dir); + ItemDirectory(sh, name, sh.GetRemotePath(path + name) + '/'); + } + } + foreach (string fil in Directory.GetFiles(rpath)) + { + string name = System.IO.Path.GetFileName(fil); + ItemFile(sh, name, sh.GetRemotePath(path + name), fil); + } + } + catch (Exception e) + { + Error(e); + } + Footer(); + } + + private void Download(WShared sh, string path) + { + string rpath = sh.GetLocalPath(path); + string name = System.IO.Path.GetFileName(rpath); + try + { + using (FileStream fs = new FileStream(rpath, FileMode.Open, FileAccess.Read)) + { + //Response.Headers["Content-Disposition"] = "attachment; filename=\"" + name + "\""; + BinaryOut(fs, Win32.GetMimeType(name)); + } + } + catch (Exception e) + { + Header(sh.Name, sh, path.Split('/')); + Error(e); + Footer(); + } + } + + private void PageRename(WShared sh, string path) + { + Header(sh.Name, sh, path.Split('/')); + if (!sh.AllowRename) + Error("Forbidden", "Renaming is not allowed on this site"); + else + { + string oname = System.IO.Path.GetFileName(path); + string acode = WebXplorer.CreateACode("R" + path); + Out.Write("
"); + Out.Write(""); + Out.Write(""); + Out.Write("Renaming file: "); + Out.Write(oname); + Out.Write("
Enter new name:
"); + Out.Write("
"); + } + Footer(); + } + + private void PageRenameDo(WShared sh, string path) + { + Header(sh.Name, sh, path.Split('/')); + if (!sh.AllowRename) + Error("Forbidden", "Renaming is not allowed on this site"); + else if (!WebXplorer.CheckACode("R" + path,GET["acode"])) + Error("Auth code error", ""); + else + { + string dir = System.IO.Path.GetDirectoryName(path); + if (!dir.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && !(dir.Length==0)) + dir+=System.IO.Path.DirectorySeparatorChar; + string oname = System.IO.Path.GetFileName(path); + string nname = GET["newname"]; + if (oname != nname) + if (nname.Contains("/") || nname.Contains("\\") || nname.Contains(":")) + Error("New File error", "Path separator char not allowed as file name"); + else + try + { + File.Move(path, dir + nname); + Out.WriteLine(""); + } + catch (Exception e) + { + Error(e); + } + } + Footer(); + } + + private void PageExecute(WShared sh, string path) + { + Header(sh.Name, sh, path.Split('/')); + if (!sh.AllowExecution) + Error("Forbidden", "Remote execution is not allowed on this site"); + else + { + try + { + System.Diagnostics.Process.Start(path); + Out.WriteLine(""); + } + catch (Exception e) + { + Error(e); + } + } + Footer(); + } + + private void PageDelete(WShared sh, string path) + { + Header(sh.Name, sh, path.Split('/')); + if (!sh.AllowDeletion) + Error("Forbidden", "Deletion is not allowed on this site"); + else + { + string oname = System.IO.Path.GetFileName(path); + string acode = WebXplorer.CreateACode("D" + path); + Out.Write("
"); + Out.Write(""); + Out.Write(""); + Out.Write("Delete file "); + Out.Write(oname); + Out.Write("?
"); + Out.Write("
"); + } + Footer(); + } + + private void PageDeleteDo(WShared sh, string path) + { + Header(sh.Name, sh, path.Split('/')); + if (!sh.AllowDeletion) + Error("Forbidden", "Deletion is not allowed on this site"); + else if (!WebXplorer.CheckACode("D" + path, GET["acode"])) + Error("Auth code error", ""); + else + { + try + { + File.Delete(sh.GetLocalPath(path)); + Out.WriteLine(""); + } + catch (Exception e) + { + Error(e); + } + } + Footer(); + } + + private void PageCreateFolder(WShared sh, string path) + { + Header(sh.Name, sh, path.Split('/')); + if (!sh.AllowNewFolder) + Error("Forbidden", "Folder creation is not allowed on this site"); + else + { + string oname = System.IO.Path.GetFileName(path); + string acode = WebXplorer.CreateACode("C" + path); + Out.Write("
"); + Out.Write(""); + Out.Write(""); + Out.Write("Create Directory: "); + Out.Write("
Enter new name:
"); + Out.Write("
"); + } + Footer(); + } + + private void PageCreateFolderDo(WShared sh, string path) + { + Header(sh.Name, sh, path.Split('/')); + if (!sh.AllowNewFolder) + Error("Forbidden", "Folder creation is not allowed on this site"); + else if (!WebXplorer.CheckACode("C" + path, GET["acode"])) + Error("Auth code error", ""); + else + { + string dname = GET["dirname"]; + if (dname.Contains("/") || dname.Contains("\\") || dname.Contains(":")) + Error("Create directory error", "Path separator char not allowed as file name"); + string dir = path.Replace('/',System.IO.Path.DirectorySeparatorChar); + if (!dir.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && !(dir.Length == 0)) + dir += System.IO.Path.DirectorySeparatorChar; + try + { + Directory.CreateDirectory(sh.GetLocalPath(dir + dname)); + Out.WriteLine(""); + } + catch (Exception e) + { + Error(e); + } + } + Footer(); + } + + private void Header(string title, WShared sh, string[] path) + { + Out.Write("Sunfish ["); + Out.Write(title); + Out.Write("]
"); + } + + private void Footer() + { + Out.Write("
"); + } + + private string UEnc(string url) + { + return url == null ? null : url.Replace("#", "|1"); + } + + private string UDec(string url) + { + return url == null ? null : url.Replace("|1", "#"); + } + + private void ItemDirectory(WShared sh, string name, string path) + { + ItemBegin(path, null, name, "Directory"); + if (sh != null) + { + if (sh.AllowExecution) + ItemTool(path, "REN", "Rename folder", "rename"); + if (sh.AllowDeletion) + ItemTool(path, "DEL", "Delete folder", "t_delete"); + } + ItemEnd(); + } + + private void ItemFile(WShared sh, string name, string path, string realpath) + { + FileInfo f = new FileInfo(realpath); + ItemBegin(path, "?Action=GET", name, FBytes(f.Length)); + if (sh != null) + { + if (sh.AllowExecution) + ItemTool(path, "RUN", "Execute on server", "t_execute"); + if (sh.AllowExecution) + ItemTool(path, "REN", "Rename file", "rename"); + if (sh.AllowDeletion) + ItemTool(path, "DEL", "Delete file", "t_delete"); + } + ItemEnd(); + } + + private void ItemBegin(string path, string param, string name, string info) + { + Out.Write("
"); + Out.Write(info); + Out.Write("
"); + Out.Write("
"); + } + + private void ItemTool(string path, string action, string title, string icon) + { + Out.Write(""); + } + + private void ItemEnd() + { + Out.Write("
"); + Out.Write("
"); + } + + private string FBytes(double lng) + { + string[] tail = { " bytes", "Kb", "Mb", "Gb", "Tb", "Pb", "Yb" }; + int taili = 0; + while (lng > 1024) + { + lng /= 1024; + taili++; + } + return lng.ToString("#0.00") + (taili >= tail.Length ? "^b" : tail[taili]); + } + + private void Error(Exception e) + { + Error(e.GetType().Name, e.Message.Replace("\n", "
")); + } + + private void Error(string title, string message) + { + Out.Write("
"); + Out.Write(title); + Out.Write("
"); + Out.Write(message); + Out.Write("
"); + } + } +}