aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Applications/FileSkimmer.cs
diff options
context:
space:
mode:
authorwilliam341 <[email protected]>2017-06-29 13:13:45 -0700
committerwilliam341 <[email protected]>2017-06-29 13:13:45 -0700
commitad387c41e7d6cc547431e88695d4723ea2dba913 (patch)
treea68282dda40c4f0b28883241c7adcf9010f4550e /ShiftOS.WinForms/Applications/FileSkimmer.cs
parentb4b19e7a4d203b58537f5b98214296ab52c49b2d (diff)
parent5bebd4411bc6266cbee482a429ba794eefa8f9b6 (diff)
downloadshiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.tar.gz
shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.tar.bz2
shiftos_thereturn-ad387c41e7d6cc547431e88695d4723ea2dba913.zip
Merge remote-tracking branch 'refs/remotes/shiftos-game/master'
Diffstat (limited to 'ShiftOS.WinForms/Applications/FileSkimmer.cs')
-rw-r--r--ShiftOS.WinForms/Applications/FileSkimmer.cs103
1 files changed, 103 insertions, 0 deletions
diff --git a/ShiftOS.WinForms/Applications/FileSkimmer.cs b/ShiftOS.WinForms/Applications/FileSkimmer.cs
index 51d7bd8..3e17420 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,24 @@ 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()
+ {
+ Desktop.InvokeOnWorkerThread(() =>
+ {
+ 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 +72,15 @@ namespace ShiftOS.WinForms.Applications
{
ChangeDirectory(Paths.GetPath("root"));
};
+ OnDisconnect += FileSkimmer_OnDisconnect;
+ }
+
+ private void FileSkimmer_OnDisconnect()
+ {
+ connectToRemoteServerToolStripMenuItem.Text = "Start Remote Session";
+ disconnectToolStripMenuItem.Visible = false;
+ currentdir = "__system";
+ ResetList();
}
private void lvitems_DoubleClick(object sender, EventArgs e)
@@ -300,6 +328,7 @@ namespace ShiftOS.WinForms.Applications
public bool OnUnload()
{
+ OnDisconnect -= FileSkimmer_OnDisconnect;
return true;
}
@@ -497,5 +526,79 @@ 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";
+ disconnectToolStripMenuItem.Visible = true;
+ 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();
+ }
+
+ private void disconnectToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ DisconnectRemote();
+ }
}
}