aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Applications/FileSkimmer.cs
diff options
context:
space:
mode:
authorwilliam341 <[email protected]>2017-06-24 10:53:22 -0700
committerGitHub <[email protected]>2017-06-24 10:53:22 -0700
commitbae34710cf86240b2744196c4b95e569fb161c90 (patch)
treed5ff99e5cc8f3db8a9236b247886866601b915b9 /ShiftOS.WinForms/Applications/FileSkimmer.cs
parentb4b19e7a4d203b58537f5b98214296ab52c49b2d (diff)
parent1661f9a5bd46dbd7d2586787c55bfc407c027629 (diff)
downloadshiftos_thereturn-bae34710cf86240b2744196c4b95e569fb161c90.tar.gz
shiftos_thereturn-bae34710cf86240b2744196c4b95e569fb161c90.tar.bz2
shiftos_thereturn-bae34710cf86240b2744196c4b95e569fb161c90.zip
Merge pull request #5 from shiftos-game/master
merge
Diffstat (limited to 'ShiftOS.WinForms/Applications/FileSkimmer.cs')
-rw-r--r--ShiftOS.WinForms/Applications/FileSkimmer.cs92
1 files changed, 92 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs
index 51d7bd8..34f9e9c 100644
--- a/ShiftOS.WinForms/Applications/FileSkimmer.cs
+++ b/ShiftOS.WinForms/Applications/FileSkimmer.cs
@@ -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();
+ }
}
}