diff --git a/App.xaml b/App.xaml new file mode 100644 index 0000000..f96b30b --- /dev/null +++ b/App.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/App.xaml.cs b/App.xaml.cs new file mode 100644 index 0000000..74ad738 --- /dev/null +++ b/App.xaml.cs @@ -0,0 +1,35 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using System; +using System.IO; +using WinUIEx; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace wakka +{ + public partial class App : Application + { + public Window m_window; + + public readonly static Windows.Storage.ApplicationDataContainer LocalSettingsData = + Windows.Storage.ApplicationData.Current.LocalSettings; + + public readonly static Windows.Storage.StorageFolder LocalStroageData = + Windows.Storage.ApplicationData.Current.LocalFolder; + + public App() + { + this.InitializeComponent(); + } + + protected override void OnLaunched(LaunchActivatedEventArgs args) + { + m_window = new MainWindow(); + m_window.SetWindowSize(width: 800, height: 600); + m_window.CenterOnScreen(); + m_window.Activate(); + } + } +} diff --git a/Assets/LargeTile.scale-100.png b/Assets/LargeTile.scale-100.png new file mode 100644 index 0000000..97208d0 Binary files /dev/null and b/Assets/LargeTile.scale-100.png differ diff --git a/Assets/LargeTile.scale-125.png b/Assets/LargeTile.scale-125.png new file mode 100644 index 0000000..63300e4 Binary files /dev/null and b/Assets/LargeTile.scale-125.png differ diff --git a/Assets/LargeTile.scale-150.png b/Assets/LargeTile.scale-150.png new file mode 100644 index 0000000..6372025 Binary files /dev/null and b/Assets/LargeTile.scale-150.png differ diff --git a/Assets/LargeTile.scale-200.png b/Assets/LargeTile.scale-200.png new file mode 100644 index 0000000..41796ec Binary files /dev/null and b/Assets/LargeTile.scale-200.png differ diff --git a/Assets/LargeTile.scale-400.png b/Assets/LargeTile.scale-400.png new file mode 100644 index 0000000..a91b118 Binary files /dev/null and b/Assets/LargeTile.scale-400.png differ diff --git a/Assets/LockScreenLogo.scale-200.png b/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 0000000..7440f0d Binary files /dev/null and b/Assets/LockScreenLogo.scale-200.png differ diff --git a/Assets/SmallTile.scale-100.png b/Assets/SmallTile.scale-100.png new file mode 100644 index 0000000..af14555 Binary files /dev/null and b/Assets/SmallTile.scale-100.png differ diff --git a/Assets/SmallTile.scale-125.png b/Assets/SmallTile.scale-125.png new file mode 100644 index 0000000..794c6d7 Binary files /dev/null and b/Assets/SmallTile.scale-125.png differ diff --git a/Assets/SmallTile.scale-150.png b/Assets/SmallTile.scale-150.png new file mode 100644 index 0000000..9631fbe Binary files /dev/null and b/Assets/SmallTile.scale-150.png differ diff --git a/Assets/SmallTile.scale-200.png b/Assets/SmallTile.scale-200.png new file mode 100644 index 0000000..a478516 Binary files /dev/null and b/Assets/SmallTile.scale-200.png differ diff --git a/Assets/SmallTile.scale-400.png b/Assets/SmallTile.scale-400.png new file mode 100644 index 0000000..78dc189 Binary files /dev/null and b/Assets/SmallTile.scale-400.png differ diff --git a/Assets/SplashScreen.scale-100.png b/Assets/SplashScreen.scale-100.png new file mode 100644 index 0000000..0d9ddfb Binary files /dev/null and b/Assets/SplashScreen.scale-100.png differ diff --git a/Assets/SplashScreen.scale-125.png b/Assets/SplashScreen.scale-125.png new file mode 100644 index 0000000..833ab97 Binary files /dev/null and b/Assets/SplashScreen.scale-125.png differ diff --git a/Assets/SplashScreen.scale-150.png b/Assets/SplashScreen.scale-150.png new file mode 100644 index 0000000..4593091 Binary files /dev/null and b/Assets/SplashScreen.scale-150.png differ diff --git a/Assets/SplashScreen.scale-200.png b/Assets/SplashScreen.scale-200.png new file mode 100644 index 0000000..216018c Binary files /dev/null and b/Assets/SplashScreen.scale-200.png differ diff --git a/Assets/SplashScreen.scale-400.png b/Assets/SplashScreen.scale-400.png new file mode 100644 index 0000000..f8d5025 Binary files /dev/null and b/Assets/SplashScreen.scale-400.png differ diff --git a/Assets/Square150x150Logo.scale-100.png b/Assets/Square150x150Logo.scale-100.png new file mode 100644 index 0000000..9a064ed Binary files /dev/null and b/Assets/Square150x150Logo.scale-100.png differ diff --git a/Assets/Square150x150Logo.scale-125.png b/Assets/Square150x150Logo.scale-125.png new file mode 100644 index 0000000..28f6245 Binary files /dev/null and b/Assets/Square150x150Logo.scale-125.png differ diff --git a/Assets/Square150x150Logo.scale-150.png b/Assets/Square150x150Logo.scale-150.png new file mode 100644 index 0000000..ec44d64 Binary files /dev/null and b/Assets/Square150x150Logo.scale-150.png differ diff --git a/Assets/Square150x150Logo.scale-200.png b/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 0000000..19ef7f8 Binary files /dev/null and b/Assets/Square150x150Logo.scale-200.png differ diff --git a/Assets/Square150x150Logo.scale-400.png b/Assets/Square150x150Logo.scale-400.png new file mode 100644 index 0000000..ffa64ec Binary files /dev/null and b/Assets/Square150x150Logo.scale-400.png differ diff --git a/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png b/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png new file mode 100644 index 0000000..7f74489 Binary files /dev/null and b/Assets/Square44x44Logo.altform-lightunplated_targetsize-16.png differ diff --git a/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png b/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png new file mode 100644 index 0000000..3df7811 Binary files /dev/null and b/Assets/Square44x44Logo.altform-lightunplated_targetsize-24.png differ diff --git a/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png b/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png new file mode 100644 index 0000000..af12409 Binary files /dev/null and b/Assets/Square44x44Logo.altform-lightunplated_targetsize-256.png differ diff --git a/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png b/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png new file mode 100644 index 0000000..8cd534b Binary files /dev/null and b/Assets/Square44x44Logo.altform-lightunplated_targetsize-32.png differ diff --git a/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png b/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png new file mode 100644 index 0000000..addc7da Binary files /dev/null and b/Assets/Square44x44Logo.altform-lightunplated_targetsize-48.png differ diff --git a/Assets/Square44x44Logo.altform-unplated_targetsize-16.png b/Assets/Square44x44Logo.altform-unplated_targetsize-16.png new file mode 100644 index 0000000..7f74489 Binary files /dev/null and b/Assets/Square44x44Logo.altform-unplated_targetsize-16.png differ diff --git a/Assets/Square44x44Logo.altform-unplated_targetsize-256.png b/Assets/Square44x44Logo.altform-unplated_targetsize-256.png new file mode 100644 index 0000000..af12409 Binary files /dev/null and b/Assets/Square44x44Logo.altform-unplated_targetsize-256.png differ diff --git a/Assets/Square44x44Logo.altform-unplated_targetsize-32.png b/Assets/Square44x44Logo.altform-unplated_targetsize-32.png new file mode 100644 index 0000000..8cd534b Binary files /dev/null and b/Assets/Square44x44Logo.altform-unplated_targetsize-32.png differ diff --git a/Assets/Square44x44Logo.altform-unplated_targetsize-48.png b/Assets/Square44x44Logo.altform-unplated_targetsize-48.png new file mode 100644 index 0000000..addc7da Binary files /dev/null and b/Assets/Square44x44Logo.altform-unplated_targetsize-48.png differ diff --git a/Assets/Square44x44Logo.scale-100.png b/Assets/Square44x44Logo.scale-100.png new file mode 100644 index 0000000..93a5b44 Binary files /dev/null and b/Assets/Square44x44Logo.scale-100.png differ diff --git a/Assets/Square44x44Logo.scale-125.png b/Assets/Square44x44Logo.scale-125.png new file mode 100644 index 0000000..769d53d Binary files /dev/null and b/Assets/Square44x44Logo.scale-125.png differ diff --git a/Assets/Square44x44Logo.scale-150.png b/Assets/Square44x44Logo.scale-150.png new file mode 100644 index 0000000..4b2a419 Binary files /dev/null and b/Assets/Square44x44Logo.scale-150.png differ diff --git a/Assets/Square44x44Logo.scale-200.png b/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 0000000..d4229f6 Binary files /dev/null and b/Assets/Square44x44Logo.scale-200.png differ diff --git a/Assets/Square44x44Logo.scale-400.png b/Assets/Square44x44Logo.scale-400.png new file mode 100644 index 0000000..16d36c8 Binary files /dev/null and b/Assets/Square44x44Logo.scale-400.png differ diff --git a/Assets/Square44x44Logo.targetsize-16.png b/Assets/Square44x44Logo.targetsize-16.png new file mode 100644 index 0000000..8d061e8 Binary files /dev/null and b/Assets/Square44x44Logo.targetsize-16.png differ diff --git a/Assets/Square44x44Logo.targetsize-24.png b/Assets/Square44x44Logo.targetsize-24.png new file mode 100644 index 0000000..0e4e729 Binary files /dev/null and b/Assets/Square44x44Logo.targetsize-24.png differ diff --git a/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 0000000..3df7811 Binary files /dev/null and b/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/Assets/Square44x44Logo.targetsize-256.png b/Assets/Square44x44Logo.targetsize-256.png new file mode 100644 index 0000000..357b485 Binary files /dev/null and b/Assets/Square44x44Logo.targetsize-256.png differ diff --git a/Assets/Square44x44Logo.targetsize-32.png b/Assets/Square44x44Logo.targetsize-32.png new file mode 100644 index 0000000..9b69c6e Binary files /dev/null and b/Assets/Square44x44Logo.targetsize-32.png differ diff --git a/Assets/Square44x44Logo.targetsize-48.png b/Assets/Square44x44Logo.targetsize-48.png new file mode 100644 index 0000000..f5c1ce1 Binary files /dev/null and b/Assets/Square44x44Logo.targetsize-48.png differ diff --git a/Assets/StoreLogo.backup.png b/Assets/StoreLogo.backup.png new file mode 100644 index 0000000..a4586f2 Binary files /dev/null and b/Assets/StoreLogo.backup.png differ diff --git a/Assets/StoreLogo.scale-100.png b/Assets/StoreLogo.scale-100.png new file mode 100644 index 0000000..9062cff Binary files /dev/null and b/Assets/StoreLogo.scale-100.png differ diff --git a/Assets/StoreLogo.scale-125.png b/Assets/StoreLogo.scale-125.png new file mode 100644 index 0000000..7549b17 Binary files /dev/null and b/Assets/StoreLogo.scale-125.png differ diff --git a/Assets/StoreLogo.scale-150.png b/Assets/StoreLogo.scale-150.png new file mode 100644 index 0000000..bdf0481 Binary files /dev/null and b/Assets/StoreLogo.scale-150.png differ diff --git a/Assets/StoreLogo.scale-200.png b/Assets/StoreLogo.scale-200.png new file mode 100644 index 0000000..fdb5d9b Binary files /dev/null and b/Assets/StoreLogo.scale-200.png differ diff --git a/Assets/StoreLogo.scale-400.png b/Assets/StoreLogo.scale-400.png new file mode 100644 index 0000000..656977e Binary files /dev/null and b/Assets/StoreLogo.scale-400.png differ diff --git a/Assets/Wide310x150Logo.scale-100.png b/Assets/Wide310x150Logo.scale-100.png new file mode 100644 index 0000000..1ebe38a Binary files /dev/null and b/Assets/Wide310x150Logo.scale-100.png differ diff --git a/Assets/Wide310x150Logo.scale-125.png b/Assets/Wide310x150Logo.scale-125.png new file mode 100644 index 0000000..bcfecdc Binary files /dev/null and b/Assets/Wide310x150Logo.scale-125.png differ diff --git a/Assets/Wide310x150Logo.scale-150.png b/Assets/Wide310x150Logo.scale-150.png new file mode 100644 index 0000000..d06d059 Binary files /dev/null and b/Assets/Wide310x150Logo.scale-150.png differ diff --git a/Assets/Wide310x150Logo.scale-200.png b/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 0000000..0d9ddfb Binary files /dev/null and b/Assets/Wide310x150Logo.scale-200.png differ diff --git a/Assets/Wide310x150Logo.scale-400.png b/Assets/Wide310x150Logo.scale-400.png new file mode 100644 index 0000000..216018c Binary files /dev/null and b/Assets/Wide310x150Logo.scale-400.png differ diff --git a/Bink.cs b/Bink.cs new file mode 100644 index 0000000..27bd611 --- /dev/null +++ b/Bink.cs @@ -0,0 +1,44 @@ +using Microsoft.VisualBasic; +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace wakka +{ + public class BinkPost + { + [JsonPropertyName("user")] + public string? User { get; set; } + [JsonPropertyName("body")] + public string? Body { get; set; } + [JsonPropertyName("time")] + public long Time { get; set; } + public string TimeString { get; set; } = string.Empty; + } + + public class Bink + { + private static SshConnection Ssh { get; set; } = new SshConnection(); + + public string RunBinkCommand(string command) + { + return Ssh.RunCommand($"town bink --{command}"); + } + + public List? AllBinks() + { + return JsonSerializer.Deserialize>(RunBinkCommand("dump")); + } + + public List? BinksBefore(long TimeStamp) + { + return JsonSerializer.Deserialize>(RunBinkCommand("dump-before")); + } + + public List? BinksAfter(long TimeStamp) + { + return JsonSerializer.Deserialize>(RunBinkCommand("dump-after")); + } + } +} diff --git a/BinkPage.xaml b/BinkPage.xaml new file mode 100644 index 0000000..f97a979 --- /dev/null +++ b/BinkPage.xaml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BinkPage.xaml.cs b/BinkPage.xaml.cs new file mode 100644 index 0000000..166d9fc --- /dev/null +++ b/BinkPage.xaml.cs @@ -0,0 +1,47 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace wakka +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class BinkPage : Page + { + private readonly ObservableCollection Binks = []; + private static SshConnection Ssh { get; set; } = new SshConnection(); + + public BinkPage() + { + this.InitializeComponent(); + var Bink = new Bink(); + var BinkList = Bink.AllBinks(); + if (BinkList != null) + { + foreach (var bink in BinkList) + { + var date = DateTimeOffset.FromUnixTimeSeconds(bink.Time / 1000000000).DateTime.ToLocalTime(); + bink.TimeString = date.ToString("HH:mm (dddd, MMMM dd, yyyy)"); + Binks.Add(bink); + } + } + binksListView.ItemsSource = Binks; + } + } +} diff --git a/MainWindow.xaml b/MainWindow.xaml new file mode 100644 index 0000000..c5f952c --- /dev/null +++ b/MainWindow.xaml @@ -0,0 +1,14 @@ + + + + + + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs new file mode 100644 index 0000000..f61a766 --- /dev/null +++ b/MainWindow.xaml.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using Windows.Foundation; +using Windows.Foundation.Collections; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace wakka +{ + /// + /// An empty window that can be used on its own or navigated to within a Frame. + /// + /// + + public sealed partial class MainWindow : Window + { + private static SshConnection Ssh { get; set; } = new SshConnection(); + public Frame RootFrame; + + public MainWindow() + { + this.InitializeComponent(); + this.AppWindow.MoveAndResize(new Windows.Graphics.RectInt32(100, 100, 854, 480)); + Ssh.DeleteSshKey(); + RootFrame = rootFrame; + if (Ssh.KeyExists() & (string)App.LocalSettingsData.Values["username"] != null) + { + Ssh.InitializeConnection((string)App.LocalSettingsData.Values["username"]); + RootFrame.Content = new NavigationPage(); + } + else + { + RootFrame.Content = new StartupSshPage(); + } + } + + + //private void myButton_Click(object sender, RoutedEventArgs e) + //{ + // myButton.Content = "Clicked"; + //} + } +} diff --git a/NavigationPage.xaml b/NavigationPage.xaml new file mode 100644 index 0000000..f44a08f --- /dev/null +++ b/NavigationPage.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + diff --git a/NavigationPage.xaml.cs b/NavigationPage.xaml.cs new file mode 100644 index 0000000..9c6a964 --- /dev/null +++ b/NavigationPage.xaml.cs @@ -0,0 +1,32 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace wakka +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class NavigationPage : Page + { + public NavigationPage() + { + this.InitializeComponent(); + navigationFrame.Content = new BinkPage(); + } + } +} diff --git a/Package.appxmanifest b/Package.appxmanifest new file mode 100644 index 0000000..d59f119 --- /dev/null +++ b/Package.appxmanifest @@ -0,0 +1,51 @@ + + + + + + + + + + wakka + helix + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json new file mode 100644 index 0000000..fc7d727 --- /dev/null +++ b/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "wakka (Package)": { + "commandName": "MsixPackage" + }, + "wakka (Unpackaged)": { + "commandName": "Project" + } + } +} \ No newline at end of file diff --git a/SshConnection.cs b/SshConnection.cs new file mode 100644 index 0000000..1ff9ade --- /dev/null +++ b/SshConnection.cs @@ -0,0 +1,76 @@ +using Org.BouncyCastle.Crypto; +using Org.BouncyCastle.Crypto.Generators; +using Org.BouncyCastle.OpenSsl; +using Org.BouncyCastle.Security; +using Renci.SshNet; +using Renci.SshNet.Common; +using System; +using System.IO; + +namespace wakka +{ + public class SshConnection + { + public static string User { get; set; } = string.Empty; + + public static SshClient? Client { get; set; } = null; + + public readonly static string SshKeyPath = Path.Combine(App.LocalStroageData.Path, "key"); + + public static PrivateKeyFile? Key { get; set; } = null; + + public static string? PublicKey { get; set; } = null; + + public bool KeyExists() => File.Exists(SshKeyPath); + + public void InitializeConnection(string user) + { + if (!File.Exists(SshKeyPath) || user == string.Empty) + { + throw new InvalidOperationException("No SSH key or user is empty"); + } + else + { + User = user; + Key = new PrivateKeyFile(SshKeyPath); + Client = new SshClient("tilde.town", User, Key); + try + { + Client.Connect(); + } + catch (SshAuthenticationException) + { + Key = null; + throw; + } + } + } + + public string RunCommand(string command) + { + if (Client == null || !Client.IsConnected) + { + throw new InvalidOperationException("SSH client is not connected."); + } + var rc = Client.RunCommand(command); + return rc.Result; + } + + public string CreateSshKey() + { + var keygen = new SshKeyGenerator.SshKeyGenerator(2048); + var privateKey = keygen.ToPrivateKey(); + File.WriteAllText(SshKeyPath, privateKey); + return keygen.ToRfcPublicKey("wakka"); + } + + public void DeleteSshKey() + { + if (File.Exists(SshKeyPath)) + { + File.Delete(SshKeyPath); + } + } + } +} + diff --git a/StartupSshPage.xaml b/StartupSshPage.xaml new file mode 100644 index 0000000..45e86e5 --- /dev/null +++ b/StartupSshPage.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + +