hacking work

Me: [squeaky] IT'S WORKING!!
Phil: Michael... You just creeped me out...
This commit is contained in:
Michael 2017-06-23 20:20:38 -04:00
parent 42a7829864
commit 1661f9a5bd
19 changed files with 1546 additions and 16 deletions

169
ShiftOS.MFSProfiler/Infobox.Designer.cs generated Normal file
View file

@ -0,0 +1,169 @@
namespace ShiftOS.MFSProfiler
{
partial class Infobox
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.txtinput = new System.Windows.Forms.TextBox();
this.lbmessage = new System.Windows.Forms.Label();
this.flyesno = new System.Windows.Forms.FlowLayoutPanel();
this.btnyes = new System.Windows.Forms.Button();
this.btnno = new System.Windows.Forms.Button();
this.btnok = new System.Windows.Forms.Button();
this.pbicon = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
this.flyesno.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbicon)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.txtinput);
this.panel1.Controls.Add(this.lbmessage);
this.panel1.Controls.Add(this.flyesno);
this.panel1.Controls.Add(this.btnok);
this.panel1.Controls.Add(this.pbicon);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(325, 138);
this.panel1.TabIndex = 0;
//
// txtinput
//
this.txtinput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtinput.Location = new System.Drawing.Point(88, 77);
this.txtinput.Name = "txtinput";
this.txtinput.Size = new System.Drawing.Size(234, 20);
this.txtinput.TabIndex = 4;
//
// lbmessage
//
this.lbmessage.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.lbmessage.Location = new System.Drawing.Point(85, 19);
this.lbmessage.Name = "lbmessage";
this.lbmessage.Size = new System.Drawing.Size(237, 55);
this.lbmessage.TabIndex = 3;
this.lbmessage.Text = "label1";
this.lbmessage.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// flyesno
//
this.flyesno.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.flyesno.AutoSize = true;
this.flyesno.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flyesno.Controls.Add(this.btnyes);
this.flyesno.Controls.Add(this.btnno);
this.flyesno.Location = new System.Drawing.Point(129, 95);
this.flyesno.Name = "flyesno";
this.flyesno.Size = new System.Drawing.Size(78, 29);
this.flyesno.TabIndex = 2;
this.flyesno.WrapContents = false;
//
// btnyes
//
this.btnyes.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnyes.AutoSize = true;
this.btnyes.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnyes.Location = new System.Drawing.Point(3, 3);
this.btnyes.Name = "btnyes";
this.btnyes.Size = new System.Drawing.Size(35, 23);
this.btnyes.TabIndex = 4;
this.btnyes.Text = "Yes";
this.btnyes.UseVisualStyleBackColor = true;
this.btnyes.Click += new System.EventHandler(this.btnyes_Click);
//
// btnno
//
this.btnno.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnno.AutoSize = true;
this.btnno.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnno.Location = new System.Drawing.Point(44, 3);
this.btnno.Name = "btnno";
this.btnno.Size = new System.Drawing.Size(31, 23);
this.btnno.TabIndex = 3;
this.btnno.Text = "No";
this.btnno.UseVisualStyleBackColor = true;
this.btnno.Click += new System.EventHandler(this.btnno_Click);
//
// btnok
//
this.btnok.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnok.AutoSize = true;
this.btnok.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnok.Location = new System.Drawing.Point(149, 101);
this.btnok.Name = "btnok";
this.btnok.Size = new System.Drawing.Size(32, 23);
this.btnok.TabIndex = 1;
this.btnok.Text = "OK";
this.btnok.UseVisualStyleBackColor = true;
this.btnok.Click += new System.EventHandler(this.btnok_Click);
//
// pbicon
//
this.pbicon.Location = new System.Drawing.Point(14, 19);
this.pbicon.Name = "pbicon";
this.pbicon.Size = new System.Drawing.Size(64, 64);
this.pbicon.TabIndex = 0;
this.pbicon.TabStop = false;
//
// Infobox
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(325, 138);
this.Controls.Add(this.panel1);
this.Name = "Infobox";
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.flyesno.ResumeLayout(false);
this.flyesno.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pbicon)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label lbmessage;
private System.Windows.Forms.FlowLayoutPanel flyesno;
private System.Windows.Forms.Button btnyes;
private System.Windows.Forms.Button btnno;
private System.Windows.Forms.Button btnok;
private System.Windows.Forms.PictureBox pbicon;
private System.Windows.Forms.TextBox txtinput;
}
}

View file

@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ShiftOS.MFSProfiler
{
public partial class Infobox : Form
{
public Infobox()
{
InitializeComponent();
}
public Action<string> TextCallback = null;
public Action<bool> YesNoCallback = null;
public string MessageText
{
get
{
return lbmessage.Text;
}
set
{
lbmessage.Text = value;
}
}
public bool ShowText
{
get { return txtinput.Visible; }
set { txtinput.Visible = value; }
}
public bool ShowYesNo
{
get { return btnyes.Parent.Visible; }
set { btnyes.Parent.Visible = value; }
}
public static void PromptYesNo(string title, string message, Action<bool> callback)
{
var inf = new Infobox();
inf.ShowText = false;
inf.ShowYesNo = true;
inf.Text = title;
inf.MessageText = message;
inf.YesNoCallback = callback;
inf.ShowDialog();
}
public static void PromptText(string title, string message, Action<string> callback)
{
var inf = new Infobox();
inf.ShowYesNo = false;
inf.ShowText = true;
inf.Text = title;
inf.MessageText = message;
inf.TextCallback = callback;
inf.ShowDialog();
}
private void btnyes_Click(object sender, EventArgs e)
{
YesNoCallback?.Invoke(true);
this.Close();
}
private void btnno_Click(object sender, EventArgs e)
{
YesNoCallback?.Invoke(false);
this.Close();
}
private void btnok_Click(object sender, EventArgs e)
{
TextCallback?.Invoke(txtinput.Text);
this.Close();
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -56,6 +56,7 @@ namespace ShiftOS.MFSProfiler
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tvfiles = new System.Windows.Forms.TreeView();
this.panel1 = new System.Windows.Forms.Panel();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.pnlfileinfo = new System.Windows.Forms.Panel();
this.groupBox2 = new System.Windows.Forms.GroupBox();
@ -71,6 +72,8 @@ namespace ShiftOS.MFSProfiler
this.newFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.newDirectoryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.exportToMFSFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.button3 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@ -115,6 +118,8 @@ namespace ShiftOS.MFSProfiler
//
// panel1
//
this.panel1.Controls.Add(this.button3);
this.panel1.Controls.Add(this.button2);
this.panel1.Controls.Add(this.button1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
@ -122,6 +127,16 @@ namespace ShiftOS.MFSProfiler
this.panel1.Size = new System.Drawing.Size(246, 30);
this.panel1.TabIndex = 1;
//
// button2
//
this.button2.Location = new System.Drawing.Point(86, 4);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 1;
this.button2.Text = "Create New";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(4, 4);
@ -237,14 +252,15 @@ namespace ShiftOS.MFSProfiler
this.ctxfileoptions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.newFileToolStripMenuItem,
this.newDirectoryToolStripMenuItem,
this.deleteToolStripMenuItem});
this.deleteToolStripMenuItem,
this.exportToMFSFileToolStripMenuItem});
this.ctxfileoptions.Name = "ctxfileoptions";
this.ctxfileoptions.Size = new System.Drawing.Size(153, 92);
this.ctxfileoptions.Size = new System.Drawing.Size(171, 92);
//
// newFileToolStripMenuItem
//
this.newFileToolStripMenuItem.Name = "newFileToolStripMenuItem";
this.newFileToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.newFileToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
this.newFileToolStripMenuItem.Text = "New file";
this.newFileToolStripMenuItem.Click += new System.EventHandler(this.newFileToolStripMenuItem_Click);
//
@ -253,13 +269,31 @@ namespace ShiftOS.MFSProfiler
this.newDirectoryToolStripMenuItem.Name = "newDirectoryToolStripMenuItem";
this.newDirectoryToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.newDirectoryToolStripMenuItem.Text = "New directory";
this.newDirectoryToolStripMenuItem.Click += new System.EventHandler(this.newDirectoryToolStripMenuItem_Click);
//
// deleteToolStripMenuItem
//
this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.deleteToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
this.deleteToolStripMenuItem.Text = "Delete";
//
// exportToMFSFileToolStripMenuItem
//
this.exportToMFSFileToolStripMenuItem.Name = "exportToMFSFileToolStripMenuItem";
this.exportToMFSFileToolStripMenuItem.Size = new System.Drawing.Size(170, 22);
this.exportToMFSFileToolStripMenuItem.Text = "Export To MFS File";
this.exportToMFSFileToolStripMenuItem.Click += new System.EventHandler(this.exportToMFSFileToolStripMenuItem_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(167, 3);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 2;
this.button3.Text = "From Dir";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -306,6 +340,9 @@ namespace ShiftOS.MFSProfiler
private System.Windows.Forms.ToolStripMenuItem newFileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem newDirectoryToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ToolStripMenuItem exportToMFSFileToolStripMenuItem;
private System.Windows.Forms.Button button3;
}
}

View file

@ -135,9 +135,101 @@ System path: {tvfiles.SelectedNode.Tag.ToString()}";
private void newFileToolStripMenuItem_Click(object sender, EventArgs e)
{
var fCreator = new FileCreator(tvfiles.SelectedNode.Tag.ToString());
if(fCreator.ShowDialog() == DialogResult.OK)
var opener = new OpenFileDialog();
opener.Title = "Import file into ShiftFS";
opener.Filter = "All files|*.*";
opener.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
if (opener.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var bytes = System.IO.File.ReadAllBytes(opener.FileName);
WriteAllBytes(tvfiles.SelectedNode.Tag.ToString() + "/" + opener.SafeFileName, bytes);
SetupTree();
}
}
private void button2_Click(object sender, EventArgs e)
{
Infobox.PromptText("Create filesystem", "Please name your file system.", (result) =>
{
if(string.IsNullOrWhiteSpace(result))
MessageBox.Show(text: "ShiftFS does not allow blank volume names.", caption: "Volume name can't be blank", icon: MessageBoxIcon.Error, buttons:MessageBoxButtons.OK);
else
{
var dir = new Directory();
dir.Name = result;
dir.permissions = Objects.UserPermissions.Guest;
Mounts.Add(dir);
SetupTree();
}
});
}
private void newDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
{
if (DirectoryExists(tvfiles.SelectedNode.Tag.ToString()))
{
Infobox.PromptText("New directory", "Please name your directory.", (result) =>
{
if (string.IsNullOrWhiteSpace(result))
MessageBox.Show(text: "ShiftFS does not allow blank directory names.", caption: "Directory name can't be blank", icon: MessageBoxIcon.Error, buttons: MessageBoxButtons.OK);
else
{
var dinf = GetDirectoryInfo(tvfiles.SelectedNode.Tag.ToString());
dinf.AddDirectory(new Directory
{
Name = result,
permissions = Objects.UserPermissions.Guest
});
SetupTree();
}
});
}
}
public void Import(string win, string sfs)
{
foreach(var dir in System.IO.Directory.GetDirectories(win))
{
var dinf = new System.IO.DirectoryInfo(dir);
CreateDirectory(sfs + dinf.Name);
Import(dir, sfs + dinf.Name + "/");
}
foreach(var file in System.IO.Directory.GetFiles(win))
{
var finf = new System.IO.FileInfo(file);
WriteAllBytes(sfs + finf.Name, System.IO.File.ReadAllBytes(file));
}
}
private void exportToMFSFileToolStripMenuItem_Click(object sender, EventArgs e)
{
string path = tvfiles.SelectedNode.Tag.ToString();
string[] split = path.Split('/');
int number = Convert.ToInt32(split[0].Replace(":", ""));
string json = ExportMount(number);
var saver = new SaveFileDialog();
saver.Filter = "MFS/ShiftFS file (Why the fuck do we also call it \".mfs\"?)|*.mfs";
saver.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
if (saver.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
System.IO.File.WriteAllText(saver.FileName, json);
}
}
private void button3_Click(object sender, EventArgs e)
{
var picker = new FolderBrowserDialog();
if(picker.ShowDialog() == DialogResult.OK)
{
var inf = new System.IO.DirectoryInfo(picker.SelectedPath);
var dir = new Directory
{
Name = inf.Name,
permissions = Objects.UserPermissions.Guest,
};
Mounts.Add(dir);
string mpath = (Mounts.Count - 1) + ":/";
Import(inf.FullName, mpath);
SetupTree();
}
}

View file

@ -52,6 +52,12 @@
<Compile Include="FileCreator.Designer.cs">
<DependentUpon>FileCreator.cs</DependentUpon>
</Compile>
<Compile Include="Infobox.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Infobox.Designer.cs">
<DependentUpon>Infobox.cs</DependentUpon>
</Compile>
<Compile Include="Main.cs">
<SubType>Form</SubType>
</Compile>
@ -63,6 +69,9 @@
<EmbeddedResource Include="FileCreator.resx">
<DependentUpon>FileCreator.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Infobox.resx">
<DependentUpon>Infobox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Main.resx">
<DependentUpon>Main.cs</DependentUpon>
</EmbeddedResource>

View file

@ -52,6 +52,7 @@ namespace ShiftOS.WinForms.Applications
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FileSkimmer));
this.lvitems = new System.Windows.Forms.ListView();
this.panel1 = new System.Windows.Forms.Panel();
this.pinnedItems = new System.Windows.Forms.TreeView();
@ -63,8 +64,24 @@ namespace ShiftOS.WinForms.Applications
this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.moveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pinToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pnlconnect = new System.Windows.Forms.Panel();
this.lbctitle = new System.Windows.Forms.Label();
this.lbcdesc = new System.Windows.Forms.Label();
this.pnlcreds = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.txtcsys = new System.Windows.Forms.TextBox();
this.txtcuser = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.txtcpass = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.flcbuttons = new System.Windows.Forms.FlowLayoutPanel();
this.btncancel = new System.Windows.Forms.Button();
this.btnok = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.pnlconnect.SuspendLayout();
this.pnlcreds.SuspendLayout();
this.flcbuttons.SuspendLayout();
this.SuspendLayout();
//
// lvitems
@ -140,9 +157,9 @@ namespace ShiftOS.WinForms.Applications
// connectToRemoteServerToolStripMenuItem
//
this.connectToRemoteServerToolStripMenuItem.Name = "connectToRemoteServerToolStripMenuItem";
this.connectToRemoteServerToolStripMenuItem.Size = new System.Drawing.Size(153, 20);
this.connectToRemoteServerToolStripMenuItem.Text = "Connect to remote server";
this.connectToRemoteServerToolStripMenuItem.Visible = false;
this.connectToRemoteServerToolStripMenuItem.Size = new System.Drawing.Size(129, 20);
this.connectToRemoteServerToolStripMenuItem.Text = "Start Remote Session";
this.connectToRemoteServerToolStripMenuItem.Click += new System.EventHandler(this.connectToRemoteServerToolStripMenuItem_Click);
//
// copyToolStripMenuItem
//
@ -165,10 +182,144 @@ namespace ShiftOS.WinForms.Applications
this.pinToolStripMenuItem.Text = "Pin";
this.pinToolStripMenuItem.Click += new System.EventHandler(this.pinToolStripMenuItem_Click);
//
// pnlconnect
//
this.pnlconnect.Controls.Add(this.flcbuttons);
this.pnlconnect.Controls.Add(this.pnlcreds);
this.pnlconnect.Controls.Add(this.lbcdesc);
this.pnlconnect.Controls.Add(this.lbctitle);
this.pnlconnect.Location = new System.Drawing.Point(100, 27);
this.pnlconnect.Name = "pnlconnect";
this.pnlconnect.Size = new System.Drawing.Size(419, 306);
this.pnlconnect.TabIndex = 4;
this.pnlconnect.Visible = false;
//
// lbctitle
//
this.lbctitle.AutoSize = true;
this.lbctitle.Location = new System.Drawing.Point(13, 18);
this.lbctitle.Name = "lbctitle";
this.lbctitle.Size = new System.Drawing.Size(133, 13);
this.lbctitle.TabIndex = 0;
this.lbctitle.Tag = "header3";
this.lbctitle.Text = "Connect to Remote Server";
//
// lbcdesc
//
this.lbcdesc.Location = new System.Drawing.Point(46, 51);
this.lbcdesc.Name = "lbcdesc";
this.lbcdesc.Size = new System.Drawing.Size(357, 54);
this.lbcdesc.TabIndex = 1;
this.lbcdesc.Text = resources.GetString("lbcdesc.Text");
this.lbcdesc.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// pnlcreds
//
this.pnlcreds.Controls.Add(this.txtcpass);
this.pnlcreds.Controls.Add(this.label3);
this.pnlcreds.Controls.Add(this.txtcuser);
this.pnlcreds.Controls.Add(this.label2);
this.pnlcreds.Controls.Add(this.txtcsys);
this.pnlcreds.Controls.Add(this.label1);
this.pnlcreds.Location = new System.Drawing.Point(25, 129);
this.pnlcreds.Name = "pnlcreds";
this.pnlcreds.Size = new System.Drawing.Size(300, 104);
this.pnlcreds.TabIndex = 2;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(73, 13);
this.label1.TabIndex = 0;
this.label1.Text = "System name:";
//
// txtcsys
//
this.txtcsys.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtcsys.Location = new System.Drawing.Point(91, 10);
this.txtcsys.Name = "txtcsys";
this.txtcsys.Size = new System.Drawing.Size(196, 20);
this.txtcsys.TabIndex = 1;
//
// txtcuser
//
this.txtcuser.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtcuser.Location = new System.Drawing.Point(91, 36);
this.txtcuser.Name = "txtcuser";
this.txtcuser.Size = new System.Drawing.Size(196, 20);
this.txtcuser.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 39);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(58, 13);
this.label2.TabIndex = 2;
this.label2.Text = "Username:";
//
// txtcpass
//
this.txtcpass.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtcpass.Location = new System.Drawing.Point(91, 62);
this.txtcpass.Name = "txtcpass";
this.txtcpass.Size = new System.Drawing.Size(196, 20);
this.txtcpass.TabIndex = 5;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 65);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 13);
this.label3.TabIndex = 4;
this.label3.Text = "Password:";
//
// flcbuttons
//
this.flcbuttons.AutoSize = true;
this.flcbuttons.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flcbuttons.Controls.Add(this.btncancel);
this.flcbuttons.Controls.Add(this.btnok);
this.flcbuttons.Location = new System.Drawing.Point(116, 256);
this.flcbuttons.Name = "flcbuttons";
this.flcbuttons.Size = new System.Drawing.Size(94, 29);
this.flcbuttons.TabIndex = 3;
//
// btncancel
//
this.btncancel.AutoSize = true;
this.btncancel.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btncancel.Location = new System.Drawing.Point(3, 3);
this.btncancel.Name = "btncancel";
this.btncancel.Size = new System.Drawing.Size(50, 23);
this.btncancel.TabIndex = 0;
this.btncancel.Text = "Cancel";
this.btncancel.UseVisualStyleBackColor = true;
this.btncancel.Click += new System.EventHandler(this.btncancel_Click);
//
// btnok
//
this.btnok.AutoSize = true;
this.btnok.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnok.Location = new System.Drawing.Point(59, 3);
this.btnok.Name = "btnok";
this.btnok.Size = new System.Drawing.Size(32, 23);
this.btnok.TabIndex = 1;
this.btnok.Text = "OK";
this.btnok.UseVisualStyleBackColor = true;
this.btnok.Click += new System.EventHandler(this.btnok_Click);
//
// FileSkimmer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.pnlconnect);
this.Controls.Add(this.panel1);
this.Controls.Add(this.menuStrip1);
this.Name = "FileSkimmer";
@ -177,6 +328,12 @@ namespace ShiftOS.WinForms.Applications
this.panel1.ResumeLayout(false);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.pnlconnect.ResumeLayout(false);
this.pnlconnect.PerformLayout();
this.pnlcreds.ResumeLayout(false);
this.pnlcreds.PerformLayout();
this.flcbuttons.ResumeLayout(false);
this.flcbuttons.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
@ -195,5 +352,18 @@ namespace ShiftOS.WinForms.Applications
private System.Windows.Forms.ToolStripMenuItem moveToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem pinToolStripMenuItem;
private System.Windows.Forms.TreeView pinnedItems;
private System.Windows.Forms.Panel pnlconnect;
private System.Windows.Forms.FlowLayoutPanel flcbuttons;
private System.Windows.Forms.Button btncancel;
private System.Windows.Forms.Button btnok;
private System.Windows.Forms.Panel pnlcreds;
private System.Windows.Forms.TextBox txtcpass;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtcuser;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtcsys;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label lbcdesc;
private System.Windows.Forms.Label lbctitle;
}
}

View file

@ -36,6 +36,7 @@ using System.Windows.Forms;
using static ShiftOS.Objects.ShiftFS.Utils;
using ShiftOS.Engine;
using Newtonsoft.Json;
using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.Applications
{
@ -46,6 +47,21 @@ namespace ShiftOS.WinForms.Applications
[DefaultIcon("iconFileSkimmer")]
public partial class FileSkimmer : UserControl, IShiftOSWindow
{
public static Objects.ClientSave CurrentRemoteUser = new Objects.ClientSave();
public static ShiftOSEnvironment OpenConnection = new ShiftOSEnvironment();
private static event Action OnDisconnect;
public static void DisconnectRemote()
{
OnDisconnect?.Invoke();
CurrentRemoteUser = new Objects.ClientSave();
if (!string.IsNullOrWhiteSpace(OpenConnection.SystemName))
Infobox.Show("Connections terminated.", "All outbound File Skimmer connections have been terminated.");
OpenConnection = new ShiftOSEnvironment();
}
public FileSkimmer()
{
InitializeComponent();
@ -53,6 +69,13 @@ namespace ShiftOS.WinForms.Applications
{
ChangeDirectory(Paths.GetPath("root"));
};
OnDisconnect += FileSkimmer_OnDisconnect;
}
private void FileSkimmer_OnDisconnect()
{
currentdir = "__system";
ResetList();
}
private void lvitems_DoubleClick(object sender, EventArgs e)
@ -300,6 +323,7 @@ namespace ShiftOS.WinForms.Applications
public bool OnUnload()
{
OnDisconnect -= FileSkimmer_OnDisconnect;
return true;
}
@ -497,5 +521,73 @@ namespace ShiftOS.WinForms.Applications
}
catch { }
}
private void connectToRemoteServerToolStripMenuItem_Click(object sender, EventArgs e)
{
ShowConnectionBox();
}
public void ShowConnectionBox()
{
pnlconnect.Show();
pnlconnect.BringToFront();
pnlconnect.CenterParent();
//header
lbctitle.CenterParent();
lbctitle.Top = 5;
//description
lbcdesc.CenterParent();
lbcdesc.Top = lbctitle.Top + lbctitle.Height + 5;
//credentials
pnlcreds.CenterParent();
pnlcreds.Top = lbcdesc.Top + lbcdesc.Height + 5;
txtcsys.Text = OpenConnection.SystemName;
txtcuser.Text = CurrentRemoteUser.Username;
txtcpass.Text = CurrentRemoteUser.Password;
//controls
flcbuttons.CenterParent();
flcbuttons.Top = pnlcreds.Top + pnlcreds.Height + 5;
}
private void btncancel_Click(object sender, EventArgs e)
{
pnlconnect.Hide();
}
private void btnok_Click(object sender, EventArgs e)
{
var sys = VirtualEnvironments.Get(txtcsys.Text);
if(sys != null)
{
//user auth
var user = sys.Users.FirstOrDefault(x => x.Username == txtcuser.Text && x.Password == txtcpass.Text);
if(user != null)
{
OpenConnection = sys;
CurrentRemoteUser = user;
if (Mounts.Count == 3)
Mounts.RemoveAt(2);
Mounts.Add(sys.Filesystem);
ChangeDirectory("2:");
pnlconnect.Hide();
connectToRemoteServerToolStripMenuItem.Text = "Reauthenticate";
return;
}
Infobox.Show("Access denied.", "Authentication failed for the specified user. Connection aborted.");
return;
}
var t = new System.Threading.Thread(() =>
{
System.Threading.Thread.Sleep(5000);
Infobox.Show("Connection timeout.", "Cannot connect to the specified system name...");
});
t.IsBackground = true;
t.Start();
}
}
}

View file

@ -120,4 +120,7 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="lbcdesc.Text" xml:space="preserve">
<value>Remote servers allow you to store and retrieve documents and files on computers from all over the Digital Society. Simply enter a system name and the relevant user credentials to log in and we'll mount the remote filesystem as if it were a drive on your computer.</value>
</data>
</root>

View file

@ -182,9 +182,17 @@ namespace ShiftOS.WinForms.Applications
btnrestart.Visible = true;
lblword.Left = (this.Width - lblword.Width) / 2;
comboBox1.SelectedIndex = 0;
this.tbguess.CenterParent();
tmrcenter.Tick += (o, a) =>
{
this.tbguess.CenterParent();
this.tbguess.Parent.CenterParent();
};
tmrcenter.Interval = 50;
tmrcenter.Start();
}
Timer tmrcenter = new Timer();
public void OnUpgrade()
{
@ -192,6 +200,7 @@ namespace ShiftOS.WinForms.Applications
public bool OnUnload()
{
tmrcenter.Stop();
return true;
}

View file

@ -1088,6 +1088,37 @@ namespace ShiftOS.WinForms.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to {
/// &quot;Name&quot;: &quot;pebcak_devel&quot;,
/// &quot;Files&quot;: [],
/// &quot;Subdirectories&quot;: [
/// {
/// &quot;Name&quot;: &quot;home&quot;,
/// &quot;Files&quot;: [],
/// &quot;Subdirectories&quot;: [
/// {
/// &quot;Name&quot;: &quot;desktop&quot;,
/// &quot;Files&quot;: [],
/// &quot;Subdirectories&quot;: [],
/// &quot;ReadAccessToLowUsers&quot;: false,
/// &quot;permissions&quot;: 0
/// },
/// {
/// &quot;Name&quot;: &quot;documents&quot;,
/// &quot;Files&quot;: [],
/// &quot;Subdirectories&quot;: [],
/// &quot;ReadAccessToLowUsers&quot;: false,
/// &quot;permissions&quot;: 0
/// },
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string PebcakDevelFS {
get {
return ResourceManager.GetString("PebcakDevelFS", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@ -1330,14 +1361,21 @@ namespace ShiftOS.WinForms.Properties {
/// <summary>
/// Looks up a localized string similar to /*
/// * French translation
/// *
/// * Made by Michael VanOverbeek with his grade 9 french skills because why not.
/// * ShiftOS French Language Pack
/// *
/// * This is a default language pack distributed within the game.
/// */
///
///{
///}.
/// //General strings
/// //These strings can be used anywhere in the UI where language context isn&apos;t necessary.
/// &quot;{GEN_PROGRAMS}&quot;: &quot;Les programmes&quot;,
/// &quot;{GEN_COMMANDS}&quot;: &quot;Les ordres&quot;,
/// &quot;{GEN_OBJECTIVES}&quot;: &quot;Les objectifs&quot;,
/// &quot;{GEN_CURRENTPROCESSES}&quot;: &quot;Les procèdures actuelles&quot;,
/// &quot;{GEN_WELCOME}&quot;: &quot;Bienvenue au ShiftOS.&quot;,
/// &quot;{GEN_SYSTEMNAME}&quot;: &quot;Nom de système&quot;,
/// &quot;{GEN_PASSWORD}&quot;: &quot;Mot de [rest of string was truncated]&quot;;.
/// </summary>
internal static string strings_fr {
get {

View file

@ -34618,4 +34618,7 @@
<data name="strings_fr" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\strings_fr.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
<data name="PebcakDevelFS" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\PebcakDevelFS.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
</data>
</root>

File diff suppressed because one or more lines are too long

View file

@ -401,6 +401,12 @@
<Compile Include="ShiftnetSites\ShiftGames.Designer.cs">
<DependentUpon>ShiftGames.cs</DependentUpon>
</Compile>
<Compile Include="ShiftnetSites\ShiftOSOnline.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="ShiftnetSites\ShiftOSOnline.Designer.cs">
<DependentUpon>ShiftOSOnline.cs</DependentUpon>
</Compile>
<Compile Include="ShiftnetSites\ShiftSoft.cs">
<SubType>UserControl</SubType>
</Compile>
@ -448,6 +454,7 @@
<Compile Include="UniteSignupDialog.Designer.cs">
<DependentUpon>UniteSignupDialog.cs</DependentUpon>
</Compile>
<Compile Include="VirtualEnvironments.cs" />
<Compile Include="VisualBasicStuff.cs" />
<Compile Include="WFLanguageProvider.cs" />
<Compile Include="WidgetManager.cs" />
@ -630,6 +637,9 @@
<EmbeddedResource Include="ShiftnetSites\ShiftGames.resx">
<DependentUpon>ShiftGames.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ShiftnetSites\ShiftOSOnline.resx">
<DependentUpon>ShiftOSOnline.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ShiftnetSites\ShiftSoft.resx">
<DependentUpon>ShiftSoft.cs</DependentUpon>
</EmbeddedResource>
@ -874,6 +884,7 @@
<Content Include="Resources\GuessTheNumber.py" />
<None Include="Resources\mindblow.png" />
<None Include="Resources\strings_fr.txt" />
<None Include="Resources\PebcakDevelFS.txt" />
<Content Include="SystemIcons\iconArtpad.png" />
<Content Include="SystemIcons\iconAudioPlayer.png" />
<Content Include="SystemIcons\iconBitnoteDigger.png" />

View file

@ -0,0 +1,89 @@
namespace ShiftOS.WinForms.ShiftnetSites
{
partial class ShiftOSOnline
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShiftOSOnline));
this.lbtitle = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.btnsubscribe = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lbtitle
//
this.lbtitle.AutoSize = true;
this.lbtitle.Location = new System.Drawing.Point(242, 294);
this.lbtitle.Name = "lbtitle";
this.lbtitle.Size = new System.Drawing.Size(76, 13);
this.lbtitle.TabIndex = 0;
this.lbtitle.Tag = "header1";
this.lbtitle.Text = "ShiftOS Online";
//
// label1
//
this.label1.Location = new System.Drawing.Point(42, 64);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(327, 137);
this.label1.TabIndex = 1;
this.label1.Text = resources.GetString("label1.Text");
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// btnsubscribe
//
this.btnsubscribe.AutoSize = true;
this.btnsubscribe.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.btnsubscribe.Location = new System.Drawing.Point(45, 401);
this.btnsubscribe.Name = "btnsubscribe";
this.btnsubscribe.Size = new System.Drawing.Size(96, 23);
this.btnsubscribe.TabIndex = 2;
this.btnsubscribe.Tag = "header3";
this.btnsubscribe.Text = "Subscribe today!";
this.btnsubscribe.UseVisualStyleBackColor = true;
this.btnsubscribe.Click += new System.EventHandler(this.btnsubscribe_Click);
//
// ShiftOSOnline
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btnsubscribe);
this.Controls.Add(this.label1);
this.Controls.Add(this.lbtitle);
this.Name = "ShiftOSOnline";
this.Size = new System.Drawing.Size(562, 469);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lbtitle;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnsubscribe;
}
}

View file

@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ShiftOS.Engine;
using ShiftOS.WinForms.Tools;
namespace ShiftOS.WinForms.ShiftnetSites
{
[ShiftnetSite("shiftnet/sol/subscription", "ShiftOS Online", "SOL is the Shiftnet.")]
[ShiftnetFundamental]
public partial class ShiftOSOnline : UserControl, IShiftnetSite
{
public ShiftOSOnline()
{
InitializeComponent();
}
public event Action GoBack;
public event Action<string> GoToUrl;
public void OnSkinLoad()
{
Tools.ControlManager.SetupControls(this);
lbtitle.CenterParent();
lbtitle.Top = 15;
label1.CenterParent();
btnsubscribe.CenterParent();
btnsubscribe.Top = (label1.Top + label1.Height) + 15;
}
public void OnUpgrade()
{
}
public string SOL_YOUARESUBSCRIBED
{
get
{
return Localization.Parse("You're already subscribed! Unsubscribe here.");
}
}
public string SOL_SUBSCRIBE
{
get
{
return Localization.Parse("Subscribe today!");
}
}
public void Setup()
{
if(SaveSystem.CurrentSave.ShiftnetSubscription == 3)
{
btnsubscribe.Text = SOL_YOUARESUBSCRIBED;
}
else
{
btnsubscribe.Text = SOL_SUBSCRIBE;
}
}
private void btnsubscribe_Click(object sender, EventArgs e)
{
if(btnsubscribe.Text == SOL_YOUARESUBSCRIBED)
{
Infobox.PromptYesNo("Unsubscribe", "Are you sure you want to unsubscribe from ShiftOS Online?", (result) =>
{
if (result == true)
{
SaveSystem.CurrentSave.ShiftnetSubscription = 0;
Setup();
OnSkinLoad();
}
});
}
else
{
Infobox.PromptYesNo("Subscribe?", "Would you like to subscribe to ShiftOS Online to get 768 kb/s for 300 Codepoints?", (result) =>
{
if(result == true)
{
if(SaveSystem.CurrentSave.Codepoints >= 300)
{
SaveSystem.CurrentSave.Codepoints -= 300;
SaveSystem.CurrentSave.ShiftnetSubscription = 3;
Infobox.Show("Subscribed.", "You have sent 300 Codepoints to ShiftOS Online and have successfully subscribed to their Shiftnet Service.");
}
else
{
Infobox.Show("Insufficient Codepoints", "You do not have enough Codepoints to complete this operation.");
}
}
});
}
}
}
}

View file

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="label1.Text" xml:space="preserve">
<value>In need of a speedboost when browsing the Shiftnet? We'll be happy to provide.
With our staggering 768 kilobytes per second connection speed, and one of the cheapest subscription costs in the entire Digital Society, ShiftOS Online is the perfect choice for anyone wanting to get the best bang for their buck.</value>
</data>
</root>

View file

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using ShiftOS.Engine;
namespace ShiftOS.WinForms.Stories
@ -80,6 +81,188 @@ namespace ShiftOS.WinForms.Stories
Story.Start("aiden_shiftnet2");
}
[Story("hacker101_breakingbonds_3")]
public static void BreakingTheBonds_Outro()
{
Story.Context.AutoComplete = false;
CharacterName = "hacker101";
SysName = "pebcak";
if (!terminalOpen())
{
var term = new Applications.Terminal();
AppearanceManager.SetupWindow(term);
}
WriteLine("Now let's teach you how to hack others' systems.");
WriteLine("I'll start up a safe virtual environment for you to mess with.");
VirtualEnvironments.Create("pebcak_devel", new List<Objects.ClientSave>
{
new Objects.ClientSave
{
Username = "root",
Password = GenRandomPassword(),
Permissions = Objects.UserPermissions.Root
},
new Objects.ClientSave
{
Username = "user",
Password = "",
Permissions = Objects.UserPermissions.Admin,
}
}, 6500l, JsonConvert.DeserializeObject<ShiftOS.Objects.ShiftFS.Directory>(Properties.Resources.PebcakDevelFS));
Thread.Sleep(2000);
WriteLine("It's all set up now. The system name for this environment is \"pebcak_devel\".");
WriteLine("This server allows FTP connections through your File Skimmer.");
WriteLine("Other systems can allow RTS connections (which allows you to control their terminals remotely), SMTP (mail transfer), etc. It depends on the system's role.");
bool isFsCopyInstalled = Shiftorium.UpgradeInstalled("fs_copy");
if (isFsCopyInstalled == false)
{
WriteLine("Before we can begin, one last thing. You need the FS Copy Shiftorium upgrade.");
Story.PushObjective("Breaking The Bonds: Preparations", "You need to buy the FS Copy upgrade from the Shiftorium.", () => { return Shiftorium.UpgradeInstalled("fs_copy"); }, () =>
{
isFsCopyInstalled = true;
});
}
while (isFsCopyInstalled == false)
Thread.Sleep(10);
WriteLine("Alright, open your File Skimmer, click \"Start Remote Session\", and connect to the system name \"pebcak_devel\" with user name \"user\" and no password.");
Story.PushObjective("Breaking The Bonds: A little practice...", "hacker101 has set up a virtual environment for you to connect to. Its system name is \"pebcak_local\", and has an unsecured user account with the name \"user\". Log into that user using your File Skimmer.",
() => { return Applications.FileSkimmer.OpenConnection.SystemName == "pebcak_devel"; },
() =>
{
WriteLine("Good work. You're in. This user only has Admin privileges, and doesn't have anything useful on it. This is where hacking comes in.");
WriteLine("See that \"super private personal stuff\" folder? It can only be accessed as a root user. You'll need the root password for pebcak_devel to get in there.");
WriteLine("I'll send you a password cracking utility that can use open ShiftOS connections to sniff out all the users on the system and allow you to brute-force into an account.");
Console.WriteLine("New program unlocked: brute");
SaveSystem.CurrentSave.StoriesExperienced.Add("brute");
WriteLine("Go ahead and open it! Use it to breach the root user on pebcak_devel.");
WriteLine("Once you've got the root password, click the Reauthenticate button in File Skimmer and it will ask you to log in as a new user.");
WriteLine("Use the new credentials to log in.");
Story.PushObjective("Breaking The Bonds: The Brute", "Use your new \"brute\" application to breach the root account on pebcak_local so you can access the super secret folder and download its contents.", () =>
{
return Applications.FileSkimmer.CurrentRemoteUser == Applications.FileSkimmer.OpenConnection.Users.FirstOrDefault(x => x.Username == "root");
},
() =>
{
WriteLine("Now, open the folder and you can copy files and folders from it to your system.");
WriteLine("You've got 60 seconds before ShiftOS's internet daemon terminates this connection.");
int counter = 60;
while(counter > 0 && Applications.FileSkimmer.OpenConnection.SystemName == "pebcak_devel")
{
Thread.Sleep(1000);
Console.WriteLine("Connection termination in " + counter + " seconds...");
if (counter == 30 || counter == 15)
Engine.AudioManager.PlayStream(Properties.Resources._3beepvirus);
if (counter <= 10)
Engine.AudioManager.PlayStream(Properties.Resources.writesound);
counter--;
}
VirtualEnvironments.Clear();
Applications.FileSkimmer.DisconnectRemote();
});
});
}
[Story("brute")]
public static void BreakingBondsStubStory()
{
//just to annoy victor tran
}
public static string GenRandomPassword()
{
var rnd = new Random();
int len = rnd.Next(5, 15);
string pass = "";
for(int i = 0; i < len; i++)
{
pass += (char)rnd.Next(255);
}
return pass;
}
[Story("hacker101_breakingbonds_2")]
public static void BreakingTheBonds_Patchwork()
{
CharacterName = "hacker101";
SysName = "pebcak";
if (!terminalOpen())
{
var term = new Applications.Terminal();
AppearanceManager.SetupWindow(term);
}
WriteLine("hacker101@pebcak - user connecting to your system.", false);
Thread.Sleep(2000);
WriteLine("Alright, you've gotten the applications you need.");
WriteLine("Now, I know you're wondering, why do you need these three applications on your system?");
WriteLine("Well, you're going to be doing some shady things and we need secure ways of storing the things you learn.");
WriteLine("TriWrite is also needed so you can view rich-formatted text documents without them being garbled in TextPad.");
WriteLine("Address Book is a secure way of storing information about the people you meet and learn about in the Digital Society.");
WriteLine("And SimpleSRC is a chat system, much more advanced and secure than this remote terminal stuff you may have seen people doing to you.");
WriteLine("ALL further operations with me will be done on SimpleSRC. But, for now, let's get you set up with your task.");
WriteLine("You're going to be learning how to hack and crack systems in the Digital Society.");
WriteLine("And this ain't no hippy DDoS stuff. Pfft, that crap is boring as hell.");
WriteLine("I'm talking the ability to steal people's files remotely, read them on your system, and also, gain desktop-level and even root-level access to their ShiftOS installations, without them even knowing.");
WriteLine("You'll be able to steal documents, programs, Codepoints and even more.");
WriteLine("Of course, there's going to be defenses in place on other people's systems, such as secure passwords, advanced firewalls, network monitors, virus scanners, etc. You should get those kinds of things going on your system before we continue.");
Story.Context.AutoComplete = false;
WriteLine("I'll push out a sequence of objectives for you to follow to get your system secure.");
Story.PushObjective("Breaking The Bonds: Patchwork - Get a virus scanner.", "Viruses are programs with the intent to harm users. They spread across the Digital Society infecting whoever they can find. A virus scanner can help you fight them off. There's a minimal one in the Shiftorium. Go get it!",
() => { return Shiftorium.UpgradeInstalled("virus_scanner"); },
() =>
{
WriteLine("Alright, you've got a virus scanning program.");
WriteLine("Now, let's take care of your system's biggest vulnerability, your root account.");
bool isRootVulnerable = false;
if (string.IsNullOrWhiteSpace(SaveSystem.Users.FirstOrDefault(x => x.Username == "root").Password))
{
isRootVulnerable = true;
WriteLine("I was able to authenticate as root on your system without a password. Use the passwd command when logged in as root to change that.");
Story.PushObjective("Breaking The Bonds: Patchwork - Set a root password.", "If you aren't already, login as root using the su command. Then, Jesus Christ, set a root password!",
() => { return string.IsNullOrWhiteSpace(SaveSystem.Users.FirstOrDefault(x => x.Username == "root").Password); },
() => {
WriteLine("Man, oh man. My connection got terminated. That means you did it.");
WriteLine("Be lucky that was me and not someone who wanted to harm you.");
WriteLine("In ShiftOS, as well as most other Unix-likes, the root account has full permissions to everything on your system, no matter what.");
WriteLine("If someone gains access to your root system remotely, you must change its password immediately or you can call that system toast.");
isRootVulnerable = false; });
}
while (isRootVulnerable)
Thread.Sleep(10);
WriteLine("Alright, now let's make you another user account.");
WriteLine("This user account will have administrative permissions, but in order for you to use them, you'll need to type your root password to confirm any administrative task.");
WriteLine("Use the adduser command to add a new user. Give it a name, log into it, set a password if you'd like, then log back into root using su...");
WriteLine("Then, in root, run \"setuserpermissions --user \"yourusername\" --val 2\". This will give the specified user \"admin\" permissions.");
Story.PushObjective("Breaking The Bonds: Patchwork - Create an admin user", "Your root account looks nice and safe, but it's good practice on any Unix-like operating system, including ShiftOS, to have a user with slightly lower permissions called an Admin user. This user can do all the things that root can, but it requires you to enter your root password to verify administrative tasks.",
() =>
{
bool success = false;
if(SaveSystem.Users.Count() > 1)
{
success = SaveSystem.Users.FirstOrDefault(x => x.Username != "root" && x.Permissions == Objects.UserPermissions.Admin) != null;
}
return success;
},
() =>
{
WriteLine("It's as secure as you need now. There are a few other things you'll want to do, like setting up a firewall and a network monitor, but we'll save that for later.");
Story.Context.MarkComplete();
Story.Start("hacker101_breakingbonds_3");
});
});
}
[Story("hacker101_breakingbonds_1")]
public static void BreakingTheBondsIntro()
{
@ -99,7 +282,6 @@ namespace ShiftOS.WinForms.Stories
WriteLine("Before I can do that, however, I need you to do a few things.");
WriteLine("I'll assign what I need you to do as an objective. When you're done, I'll tell you what you need to know.");
Story.Context.MarkComplete();
TerminalBackend.PrefixEnabled = true;
Story.PushObjective("Breaking the Bonds: Errand Boy", @"hacker101 has something he needs to show you, however before he can, you need to do the following:
@ -110,7 +292,7 @@ namespace ShiftOS.WinForms.Stories
{
bool flag1 = Shiftorium.UpgradeInstalled("address_book");
bool flag2 = Shiftorium.UpgradeInstalled("triwrite");
bool flag3 = Shiftorium.UpgradeInstalled("simplesrc");
bool flag3 = Shiftorium.UpgradeInstalled("simplesrc_client");
return flag1 && flag2 && flag3;
}, () =>
{

View file

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.WinForms
{
public static class VirtualEnvironments
{
private static List<ShiftOSEnvironment> _environments = new List<ShiftOSEnvironment>();
public static void Create(string sysname, List<ShiftOS.Objects.ClientSave> users, ulong cp, ShiftOS.Objects.ShiftFS.Directory fs)
{
var env = new ShiftOSEnvironment
{
SystemName = sysname,
Users = users,
Codepoints = cp,
Filesystem = fs
};
_environments.Add(env);
}
public static void Clear()
{
_environments.Clear();
}
public static ShiftOSEnvironment Get(string sysname)
{
return _environments.FirstOrDefault(x => x.SystemName == sysname);
}
}
public class ShiftOSEnvironment
{
public string SystemName { get; set; }
public ulong Codepoints { get; set; }
public ShiftOS.Objects.ShiftFS.Directory Filesystem { get; set; }
public List<ShiftOS.Objects.ClientSave> Users { get; set; }
}
}