From f950957b76c7924a2de2ce1a48de491daa4f9eb0 Mon Sep 17 00:00:00 2001 From: JacobTech Date: Mon, 18 Nov 2024 23:24:23 -0500 Subject: [PATCH] Project --- Luski.net/Enums/ConnectionStatus.cs | 10 ++ Luski.net/Luski.net.csproj | 4 +- Luski.net/PublicServer.Account.cs | 2 + Luski.net/PublicServer.cs | 100 ++---------------- Luski.net/Server.Globals.cs | 1 + .../Structures/Main/MainSocketUserBase.cs | 6 +- Luski.net/Structures/Public/ServerProfile.cs | 12 --- Luski.net/Structures/Public/SocketCategory.cs | 2 - Luski.net/Structures/Public/SocketChannel.cs | 2 - Luski.net/Structures/Public/SocketUser.cs | 10 -- 10 files changed, 23 insertions(+), 126 deletions(-) create mode 100644 Luski.net/Enums/ConnectionStatus.cs diff --git a/Luski.net/Enums/ConnectionStatus.cs b/Luski.net/Enums/ConnectionStatus.cs new file mode 100644 index 0000000..bf6993f --- /dev/null +++ b/Luski.net/Enums/ConnectionStatus.cs @@ -0,0 +1,10 @@ +namespace Luski.net.Enums; + +public enum ConnectionStatus +{ + FailedToConnect, + CommunicationError, + FailedToLogin, + ConnectedNotLoggedIn, + LoggedIn, +} \ No newline at end of file diff --git a/Luski.net/Luski.net.csproj b/Luski.net/Luski.net.csproj index 7520fae..485e5cb 100755 --- a/Luski.net/Luski.net.csproj +++ b/Luski.net/Luski.net.csproj @@ -13,11 +13,11 @@ https://github.com/JacobTech-com/Luski.net True 1.0.0 - 2.0.1-alpha15 + 2.0.1-alpha18 - + diff --git a/Luski.net/PublicServer.Account.cs b/Luski.net/PublicServer.Account.cs index d1353de..7af40df 100644 --- a/Luski.net/PublicServer.Account.cs +++ b/Luski.net/PublicServer.Account.cs @@ -88,6 +88,7 @@ public partial class PublicServer Console.WriteLine("Account Result: " + DateTime.UtcNow.Subtract(dt).ToString("g")); if (json.Error is not null) { + ConnectionStatus = ConnectionStatus.FailedToLogin; Console.WriteLine(json.ErrorMessage); return false; throw new Exception($"Luski appears to be down at the current moment: {json.ErrorMessage}"); @@ -121,6 +122,7 @@ public partial class PublicServer Token.Split('.')[0] ))); User = await GetUser(id, CancellationToken); + ConnectionStatus = ConnectionStatus.LoggedIn; User.Username = Username; Console.WriteLine("Get our info: " + DateTime.UtcNow.Subtract(dt).ToString("g")); diff --git a/Luski.net/PublicServer.cs b/Luski.net/PublicServer.cs index 8da6be1..436fabd 100644 --- a/Luski.net/PublicServer.cs +++ b/Luski.net/PublicServer.cs @@ -101,9 +101,12 @@ public partial class PublicServer : Server if (si is null) { Failed.Add(s); + s.ConnectionStatus = ConnectionStatus.FailedToConnect; throw; } } + + s.ConnectionStatus = ConnectionStatus.ConnectedNotLoggedIn; s.Storage.SetJson(StorageDirectory.ServerInfo, "server.json", new() { AlternateServers = Array.Empty(), @@ -180,19 +183,6 @@ public partial class PublicServer : Server Encryption.AES.Decrypt(Convert.FromBase64String(request.Name), nkey.Key)), _ => Encryption.Generic.Encoders[(short)request.TitleEncoderType].GetString(Convert.FromBase64String(request.Name)) }; - List cols = new(); - if (request.ColorType == ColorType.Full) - { - Color nc = new(request.Color); - cols.Add(nc); - } - else - { - for (int i = 0; i < request.Color.Length - 7; i+=8) - { - cols.Add(new(request.Color[i..(i+8)])); - } - } TCategory bob = new() { @@ -208,9 +198,7 @@ public partial class PublicServer : Server UserOverides = request.UserOverrides, TitleEncoderType = request.TitleEncoderType, TitleEncryptionKey = request.TitleEncryptionKey, - Server = this, - ColorType = request.ColorType, - Colors = cols.ToArray() + Server = this }; cats.Add(bob); return bob; @@ -528,19 +516,6 @@ public partial class PublicServer : Server Encryption.AES.Decrypt(Convert.FromBase64String(request.Name), nkey.Key)), _ => Encryption.Generic.Encoders[(short)request.TitleEncoderType].GetString(Convert.FromBase64String(request.Name)) }; - List cols = new(); - if (request.ColorType == ColorType.Full) - { - Color nc = new(request.Color); - cols.Add(nc); - } - else - { - for (int i = 0; i < request.Color.Length - 7; i+=8) - { - cols.Add(new(request.Color[i..(i+8)])); - } - } TChannel bob = new() { @@ -560,8 +535,6 @@ public partial class PublicServer : Server TitleEncryptionKey = request.TitleEncryptionKey, PictureType = request.PictureType, Server = this, - ColorType = request.ColorType, - Colors = cols.ToArray() }; chans.Add(bob); @@ -595,25 +568,11 @@ public partial class PublicServer : Server RoleOverrides = Array.Empty(), UserOverrides = Array.Empty(), Type = ChannelType.TextAndVoice, - Color = "FFFFFFFF", PictureType = PictureType.none }, ChannelPostCTSContext.Default.ChannelPostCTS, ChannelSTCContext.Default.ChannelSTC, CancellationToken.None); - List cols = new(); - if (res.ColorType == ColorType.Full) - { - Color nc = new(res.Color); - cols.Add(nc); - } - else - { - for (int i = 0; i < res.Color.Length - 7; i+=8) - { - cols.Add(new(res.Color[i..(i+8)])); - } - } return new SocketChannel() { @@ -632,9 +591,7 @@ public partial class PublicServer : Server TitleEncoderType = res.TitleEncoderType, TitleEncryptionKey = res.TitleEncryptionKey, PictureType = res.PictureType, - Server = this, - ColorType = res.ColorType, - Colors = cols.ToArray() + Server = this }; } @@ -795,26 +752,6 @@ public partial class PublicServer : Server throw new Exception($"Something went wrong getting your user information\n{error}"); } - Color[]? colss = null; - if (user.Color is not null) - { - List cols = new(); - if (user.ColorType == ColorType.Full) - { - Color nc = new(user.Color); - cols.Add(nc); - } - else - { - for (int i = 0; i < user.Color.Length - 7; i+=8) - { - cols.Add(new(user.Color[i..(i+8)])); - } - } - colss = cols.ToArray(); - } - - ServerProfile u = new() { Server = this, @@ -822,9 +759,7 @@ public partial class PublicServer : Server DisplayName = user.DisplayName, PictureType = user.PictureType, Controllers = user.Controllers, - RoleControllers = user.RoleControllers, - ColorType = user.ColorType, - Color = colss + RoleControllers = user.RoleControllers }; profiles.Add(u); return u; @@ -859,25 +794,6 @@ public partial class PublicServer : Server throw new Exception($"Something went wrong getting your profile information\n{error}"); } - Color[]? colss = null; - if (user.Color is not null) - { - List cols = new(); - if (user.ColorType == ColorType.Full) - { - Color nc = new(user.Color); - cols.Add(nc); - } - else - { - for (int i = 0; i < user.Color.Length - 7; i+=8) - { - cols.Add(new(user.Color[i..(i+8)])); - } - } - colss = cols.ToArray(); - } - ServerProfile u = new() { Server = this, @@ -885,9 +801,7 @@ public partial class PublicServer : Server DisplayName = user.DisplayName, PictureType = user.PictureType, Controllers = user.Controllers, - RoleControllers = user.RoleControllers, - ColorType = user.ColorType, - Color = colss + RoleControllers = user.RoleControllers }; profiles_.Add(u); profiles.Add(u); diff --git a/Luski.net/Server.Globals.cs b/Luski.net/Server.Globals.cs index a3f4e04..5776ad3 100644 --- a/Luski.net/Server.Globals.cs +++ b/Luski.net/Server.Globals.cs @@ -24,4 +24,5 @@ public partial class Server internal bool CanRequest = false, login = false; internal List poeople = new(); internal List profiles = new(); + public ConnectionStatus ConnectionStatus { get; protected set; } = ConnectionStatus.FailedToConnect; } \ No newline at end of file diff --git a/Luski.net/Structures/Main/MainSocketUserBase.cs b/Luski.net/Structures/Main/MainSocketUserBase.cs index 1f6fbb6..4183825 100644 --- a/Luski.net/Structures/Main/MainSocketUserBase.cs +++ b/Luski.net/Structures/Main/MainSocketUserBase.cs @@ -26,11 +26,7 @@ public class MainSocketUserBase : STC, IUser [JsonPropertyName("picture_type")] [JsonInclude] public PictureType PictureType { get; internal set; } = default!; - - public Task GetColor() - { - throw new NotImplementedException(); - } + public async Task GetAvatar(CancellationToken CancellationToken) { bool isc = System.IO.File.Exists(Server.Storage.GetStorageDirectory(StorageDirectory.Avatars) + Id.ToString()); diff --git a/Luski.net/Structures/Public/ServerProfile.cs b/Luski.net/Structures/Public/ServerProfile.cs index 2ac1694..92af256 100644 --- a/Luski.net/Structures/Public/ServerProfile.cs +++ b/Luski.net/Structures/Public/ServerProfile.cs @@ -15,18 +15,6 @@ public class ServerProfile public PictureType? PictureType { get; init; } = default!; public long[] Controllers { get; internal set; } = default!; public long[] RoleControllers { get; internal set; } = default!; - internal ColorType? ColorType { get; set; } = default!; - internal Color[]? Color { get; set; } = default!; - - public Task GetColors() - { - return Task.FromResult(Color); - } - - public Task GetColorType() - { - return Task.FromResult(ColorType); - } public async Task GetAvatar(CancellationToken CancellationToken) { diff --git a/Luski.net/Structures/Public/SocketCategory.cs b/Luski.net/Structures/Public/SocketCategory.cs index fd8aef7..9f49dd5 100644 --- a/Luski.net/Structures/Public/SocketCategory.cs +++ b/Luski.net/Structures/Public/SocketCategory.cs @@ -12,8 +12,6 @@ public class SocketCategory { public PublicServer Server { get; init; } = default!; public long ID { get; init; } - public ColorType ColorType { get; init; } = ColorType.Full; - public Color[] Colors { get; init; } internal long ParentID { get; set; } internal RoleOverrideSTC[] RoleOverides { get; set; } internal UserOverrideSTC[] UserOverides { get; set; } diff --git a/Luski.net/Structures/Public/SocketChannel.cs b/Luski.net/Structures/Public/SocketChannel.cs index 328f757..301a027 100644 --- a/Luski.net/Structures/Public/SocketChannel.cs +++ b/Luski.net/Structures/Public/SocketChannel.cs @@ -15,8 +15,6 @@ namespace Luski.net.Structures.Public; public class SocketChannel { public PublicServer Server { get; init; } = default!; - public ColorType ColorType { get; init; } = ColorType.Full; - public Color[] Colors { get; init; } public long ID { get; internal set; } internal long CategoryID { get; set; } internal RoleOverrideSTC[] RoleOverrides { get; set; } diff --git a/Luski.net/Structures/Public/SocketUser.cs b/Luski.net/Structures/Public/SocketUser.cs index 1d6d889..4e705d8 100644 --- a/Luski.net/Structures/Public/SocketUser.cs +++ b/Luski.net/Structures/Public/SocketUser.cs @@ -22,16 +22,6 @@ public class SocketUser : IUser public long[] RoleIds { get; init; } = default!; private List? RawRoles = null; - public async Task GetColorType() - { - return (await GetRoles())[0].ColorType; - } - - public async Task GetColors() - { - return (await GetRoles())[0].Colors; - } - public async Task GetRoles() { if (RawRoles is null)