mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-24 09:13:50 +02:00
cleanup
This commit is contained in:
35
AppApi.cs
35
AppApi.cs
@@ -59,8 +59,11 @@ namespace VRCX
|
||||
public string MD5File(string Blob)
|
||||
{
|
||||
var fileData = Convert.FromBase64CharArray(Blob.ToCharArray(), 0, Blob.Length);
|
||||
var md5 = MD5.Create().ComputeHash(fileData);
|
||||
return Convert.ToBase64String(md5);
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
var md5Hash = md5.ComputeHash(fileData);
|
||||
return Convert.ToBase64String(md5Hash);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,11 +74,13 @@ namespace VRCX
|
||||
public string SignFile(string Blob)
|
||||
{
|
||||
var fileData = Convert.FromBase64CharArray(Blob.ToCharArray(), 0, Blob.Length);
|
||||
var sig = Librsync.ComputeSignature(new MemoryStream(fileData));
|
||||
var memoryStream = new MemoryStream();
|
||||
sig.CopyTo(memoryStream);
|
||||
var sigBytes = memoryStream.ToArray();
|
||||
return Convert.ToBase64String(sigBytes);
|
||||
using (var sig = Librsync.ComputeSignature(new MemoryStream(fileData)))
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
sig.CopyTo(memoryStream);
|
||||
var sigBytes = memoryStream.ToArray();
|
||||
return Convert.ToBase64String(sigBytes);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -85,7 +90,7 @@ namespace VRCX
|
||||
/// <returns>The length of the file in bytes.</returns>
|
||||
public string FileLength(string Blob)
|
||||
{
|
||||
var fileData = Convert.FromBase64CharArray(Blob.ToCharArray(), 0, Blob.Length);
|
||||
var fileData = Convert.FromBase64String(Blob);
|
||||
return fileData.Length.ToString();
|
||||
}
|
||||
|
||||
@@ -99,7 +104,7 @@ namespace VRCX
|
||||
var configFile = Path.Combine(logPath, @"config.json");
|
||||
if (!Directory.Exists(logPath) || !File.Exists(configFile))
|
||||
{
|
||||
return "";
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var json = File.ReadAllText(configFile);
|
||||
@@ -404,7 +409,7 @@ namespace VRCX
|
||||
Icon = Image;
|
||||
}
|
||||
|
||||
var broadcastIP = IPAddress.Parse("127.0.0.1");
|
||||
var broadcastIP = IPAddress.Loopback;
|
||||
var broadcastSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
var endPoint = new IPEndPoint(broadcastIP, 42069);
|
||||
|
||||
@@ -415,7 +420,7 @@ namespace VRCX
|
||||
msg.height = 110f;
|
||||
msg.sourceApp = "VRCX";
|
||||
msg.timeout = Timeout;
|
||||
msg.audioPath = "";
|
||||
msg.audioPath = string.Empty;
|
||||
msg.useBase64Icon = UseBase64Icon;
|
||||
msg.icon = Icon;
|
||||
|
||||
@@ -430,9 +435,11 @@ namespace VRCX
|
||||
public void DownloadVRCXUpdate(string url)
|
||||
{
|
||||
var Location = Path.Combine(Program.AppDataDirectory, "update.exe");
|
||||
var client = new WebClient();
|
||||
client.Headers.Add("user-agent", Program.Version);
|
||||
client.DownloadFile(new Uri(url), Location);
|
||||
using (var client = new WebClient())
|
||||
{
|
||||
client.Headers.Add("user-agent", Program.Version);
|
||||
client.DownloadFile(new Uri(url), Location);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace VRCX
|
||||
public string GetAssetVersion(int version)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(version);
|
||||
string versionHex = String.Empty;
|
||||
string versionHex = string.Empty;
|
||||
foreach (byte b in bytes)
|
||||
{
|
||||
versionHex += b.ToString("X2");
|
||||
|
||||
@@ -162,9 +162,8 @@ namespace VRCX
|
||||
Process proc = Process.GetProcessById(pid);
|
||||
proc.Kill();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace VRCX
|
||||
_ipcServer.BeginRead(_recvBuffer, 0, _recvBuffer.Length, OnRead, _ipcServer);
|
||||
}
|
||||
|
||||
public async Task Send(IPCPacket ipcPacket)
|
||||
public void Send(IPCPacket ipcPacket)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace VRCX
|
||||
new IPCServer().CreateIPCServer();
|
||||
}
|
||||
|
||||
public static async Task Send(IPCPacket ipcPacket)
|
||||
public static void Send(IPCPacket ipcPacket)
|
||||
{
|
||||
foreach (var client in Clients)
|
||||
{
|
||||
await client.Send(ipcPacket);
|
||||
client.Send(ipcPacket);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace VRCX
|
||||
|
||||
using (var client = new WebClient())
|
||||
{
|
||||
string cookieString = String.Empty;
|
||||
string cookieString = string.Empty;
|
||||
if (WebApi.Instance != null && WebApi.Instance._cookieContainer != null)
|
||||
{
|
||||
CookieCollection cookies = WebApi.Instance._cookieContainer.GetCookies(new Uri($"https://{imageHost}"));
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace VRCX
|
||||
public static class Program
|
||||
{
|
||||
public static string BaseDirectory { get; private set; }
|
||||
public static string AppDataDirectory { get; private set; }
|
||||
public static readonly string AppDataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VRCX");
|
||||
public static string ConfigLocation;
|
||||
public static string Version { get; private set; }
|
||||
public static bool LaunchDebug;
|
||||
@@ -25,7 +25,6 @@ namespace VRCX
|
||||
static Program()
|
||||
{
|
||||
BaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
||||
AppDataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VRCX");
|
||||
ConfigLocation = Path.Combine(Program.AppDataDirectory, "VRCX.sqlite3");
|
||||
|
||||
if (!Directory.Exists(AppDataDirectory))
|
||||
|
||||
2
Properties/Resources.Designer.cs
generated
2
Properties/Resources.Designer.cs
generated
@@ -19,7 +19,7 @@ namespace VRCX.Properties {
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
26
SQLite.cs
26
SQLite.cs
@@ -484,7 +484,7 @@ namespace SQLite
|
||||
throw new ArgumentNullException (nameof (key));
|
||||
if (key.Length != 32 && key.Length != 48)
|
||||
throw new ArgumentException ("Key must be 32 bytes (256-bit) or 48 bytes (384-bit)", nameof (key));
|
||||
var s = String.Join ("", key.Select (x => x.ToString ("X2")));
|
||||
var s = string.Join(string.Empty, key.Select (x => x.ToString ("X2")));
|
||||
ExecuteScalar<string> ("pragma key = \"x'" + s + "'\"");
|
||||
}
|
||||
|
||||
@@ -816,7 +816,7 @@ namespace SQLite
|
||||
public int CreateIndex (string indexName, string tableName, string[] columnNames, bool unique = false)
|
||||
{
|
||||
const string sqlFormat = "create {2} index if not exists \"{3}\" on \"{0}\"(\"{1}\")";
|
||||
var sql = String.Format (sqlFormat, tableName, string.Join ("\", \"", columnNames), unique ? "unique" : "", indexName);
|
||||
var sql = String.Format (sqlFormat, tableName, string.Join ("\", \"", columnNames), unique ? "unique" : string.Empty, indexName);
|
||||
return Execute (sql);
|
||||
}
|
||||
|
||||
@@ -1720,7 +1720,7 @@ namespace SQLite
|
||||
if (obj == null) {
|
||||
return 0;
|
||||
}
|
||||
return Insert (obj, "", Orm.GetType (obj));
|
||||
return Insert (obj, string.Empty, Orm.GetType (obj));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1761,7 +1761,7 @@ namespace SQLite
|
||||
/// </returns>
|
||||
public int Insert (object obj, Type objType)
|
||||
{
|
||||
return Insert (obj, "", objType);
|
||||
return Insert (obj, string.Empty, objType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2170,7 +2170,7 @@ namespace SQLite
|
||||
|
||||
// Check for errors
|
||||
r = SQLite3.GetResult (destHandle);
|
||||
string msg = "";
|
||||
string msg = string.Empty;
|
||||
if (r != SQLite3.Result.OK) {
|
||||
msg = SQLite3.GetErrmsg (destHandle);
|
||||
}
|
||||
@@ -2932,16 +2932,16 @@ namespace SQLite
|
||||
public static string Collation (MemberInfo p)
|
||||
{
|
||||
#if ENABLE_IL2CPP
|
||||
return (p.GetCustomAttribute<CollationAttribute> ()?.Value) ?? "";
|
||||
return (p.GetCustomAttribute<CollationAttribute> ()?.Value) ?? string.Empty;
|
||||
#else
|
||||
return
|
||||
(p.CustomAttributes
|
||||
.Where (x => typeof (CollationAttribute) == x.AttributeType)
|
||||
.Select (x => {
|
||||
var args = x.ConstructorArguments;
|
||||
return args.Count > 0 ? ((args[0].Value as string) ?? "") : "";
|
||||
return args.Count > 0 ? ((args[0].Value as string) ?? string.Empty) : string.Empty;
|
||||
})
|
||||
.FirstOrDefault ()) ?? "";
|
||||
.FirstOrDefault ()) ?? string.Empty;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3033,7 +3033,7 @@ namespace SQLite
|
||||
{
|
||||
_conn = conn;
|
||||
_bindings = new List<Binding> ();
|
||||
CommandText = "";
|
||||
CommandText = string.Empty;
|
||||
}
|
||||
|
||||
public int ExecuteNonQuery ()
|
||||
@@ -4052,7 +4052,7 @@ namespace SQLite
|
||||
cmdText += " where " + w.CommandText;
|
||||
}
|
||||
if ((_orderBys != null) && (_orderBys.Count > 0)) {
|
||||
var t = string.Join (", ", _orderBys.Select (o => "\"" + o.ColumnName + "\"" + (o.Ascending ? "" : " desc")).ToArray ());
|
||||
var t = string.Join (", ", _orderBys.Select (o => "\"" + o.ColumnName + "\"" + (o.Ascending ? string.Empty : " desc")).ToArray ());
|
||||
cmdText += " order by " + t;
|
||||
}
|
||||
if (_limit.HasValue) {
|
||||
@@ -4127,7 +4127,7 @@ namespace SQLite
|
||||
args[i] = CompileExpr (call.Arguments[i], queryArgs);
|
||||
}
|
||||
|
||||
var sqlCall = "";
|
||||
var sqlCall = string.Empty;
|
||||
|
||||
if (call.Method.Name == "Like" && args.Length == 2) {
|
||||
sqlCall = "(" + args[0].CommandText + " like " + args[1].CommandText + ")";
|
||||
@@ -4269,7 +4269,7 @@ namespace SQLite
|
||||
if (val != null && val is System.Collections.IEnumerable && !(val is string) && !(val is System.Collections.Generic.IEnumerable<byte>)) {
|
||||
var sb = new System.Text.StringBuilder ();
|
||||
sb.Append ("(");
|
||||
var head = "";
|
||||
var head = string.Empty;
|
||||
foreach (var a in (System.Collections.IEnumerable)val) {
|
||||
queryArgs.Add (a);
|
||||
sb.Append (head);
|
||||
@@ -4726,7 +4726,7 @@ namespace SQLite
|
||||
public static Result Open (string filename, out Sqlite3DatabaseHandle db, int flags, string vfsName)
|
||||
{
|
||||
#if USE_WP8_NATIVE_SQLITE
|
||||
return (Result)Sqlite3.sqlite3_open_v2(filename, out db, flags, vfsName ?? "");
|
||||
return (Result)Sqlite3.sqlite3_open_v2(filename, out db, flags, vfsName ?? string.Empty);
|
||||
#else
|
||||
return (Result)Sqlite3.sqlite3_open_v2 (filename, out db, flags, vfsName);
|
||||
#endif
|
||||
|
||||
@@ -231,7 +231,7 @@ namespace VRCX
|
||||
{
|
||||
metadata.Add("author", new JObject
|
||||
{
|
||||
{ "id", "" },
|
||||
{ "id", string.Empty },
|
||||
{ "displayName", $"{author[1]} ({author[0]})" }
|
||||
});
|
||||
break;
|
||||
@@ -249,18 +249,18 @@ namespace VRCX
|
||||
var world = split[1].Split(',');
|
||||
metadata.Add("world", new JObject
|
||||
{
|
||||
{ "id", "" },
|
||||
{ "id", string.Empty },
|
||||
{ "name", $"{world[2]} ({world[0]})" },
|
||||
{ "instanceId", "" }
|
||||
{ "instanceId", string.Empty }
|
||||
});
|
||||
}
|
||||
else if (version == 1)
|
||||
{
|
||||
metadata.Add("world", new JObject
|
||||
{
|
||||
{ "id", "" },
|
||||
{ "id", string.Empty },
|
||||
{ "name", split[1] },
|
||||
{ "instanceId", "" }
|
||||
{ "instanceId", string.Empty }
|
||||
});
|
||||
}
|
||||
else
|
||||
@@ -297,7 +297,7 @@ namespace VRCX
|
||||
{
|
||||
playersArray.Add(new JObject
|
||||
{
|
||||
{ "id", "" },
|
||||
{ "id", string.Empty },
|
||||
{ "x", playerSplit[1] },
|
||||
{ "y", playerSplit[2] },
|
||||
{ "z", playerSplit[3] },
|
||||
@@ -342,7 +342,6 @@ namespace VRCX
|
||||
// init lookup table and store crc for iTXt
|
||||
private static readonly uint iTXtCrc = Crc32(new[] { (byte)'i', (byte)'T', (byte)'X', (byte)'t' }, 0, 4, 0);
|
||||
private readonly Encoding keywordEncoding = Encoding.GetEncoding("ISO-8859-1"); // ISO-8859-1/Latin1 is the encoding used for the keyword in text chunks.
|
||||
public List<byte> ChunkBytes;
|
||||
public List<byte> ChunkDataBytes;
|
||||
public int ChunkDataLength;
|
||||
public string ChunkType;
|
||||
|
||||
13
Update.cs
13
Update.cs
@@ -13,13 +13,16 @@ namespace VRCX
|
||||
{
|
||||
internal class Update
|
||||
{
|
||||
private static readonly string VRCX_Setup_Executable = Path.Combine(Program.AppDataDirectory, "VRCX_Setup.exe");
|
||||
private static readonly string Update_Executable = Path.Combine(Program.AppDataDirectory, "update.exe");
|
||||
|
||||
public static void Check()
|
||||
{
|
||||
if (Process.GetProcessesByName("VRCX_Setup").Length > 0)
|
||||
Environment.Exit(0);
|
||||
if (File.Exists(Path.Combine(Program.AppDataDirectory, "VRCX_Setup.exe")))
|
||||
File.Delete(Path.Combine(Program.AppDataDirectory, "VRCX_Setup.exe"));
|
||||
if (File.Exists(Path.Combine(Program.AppDataDirectory, "update.exe")))
|
||||
if (File.Exists(VRCX_Setup_Executable))
|
||||
File.Delete(VRCX_Setup_Executable);
|
||||
if (File.Exists(Update_Executable))
|
||||
Install();
|
||||
}
|
||||
|
||||
@@ -27,12 +30,12 @@ namespace VRCX
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Move(Path.Combine(Program.AppDataDirectory, "update.exe"), Path.Combine(Program.AppDataDirectory, "VRCX_Setup.exe"));
|
||||
File.Move(Update_Executable, VRCX_Setup_Executable);
|
||||
var VRCXProcess = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = Path.Combine(Program.AppDataDirectory, "VRCX_Setup.exe"),
|
||||
FileName = VRCX_Setup_Executable,
|
||||
Arguments = "/S"
|
||||
}
|
||||
};
|
||||
|
||||
@@ -134,9 +134,11 @@
|
||||
<Compile Include="WinformThemer.cs" />
|
||||
<EmbeddedResource Include="VRForm.resx">
|
||||
<DependentUpon>VRForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace VRCX
|
||||
string FormDataTemplate = "--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\n\r\n{2}\r\n";
|
||||
foreach (string key in postData.Keys)
|
||||
{
|
||||
string item = String.Format(FormDataTemplate, boundary, key, postData[key]);
|
||||
string item = string.Format(FormDataTemplate, boundary, key, postData[key]);
|
||||
byte[] itemBytes = System.Text.Encoding.UTF8.GetBytes(item);
|
||||
await requestStream.WriteAsync(itemBytes, 0, itemBytes.Length);
|
||||
}
|
||||
@@ -215,7 +215,7 @@ namespace VRCX
|
||||
string fileName = "image.png";
|
||||
string fileMimeType = "image/png";
|
||||
string HeaderTemplate = "--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{2}\"\r\nContent-Type: {3}\r\n\r\n";
|
||||
string header = String.Format(HeaderTemplate, boundary, fileFormKey, fileName, fileMimeType);
|
||||
string header = string.Format(HeaderTemplate, boundary, fileFormKey, fileName, fileMimeType);
|
||||
byte[] headerbytes = Encoding.UTF8.GetBytes(header);
|
||||
await requestStream.WriteAsync(headerbytes, 0, headerbytes.Length);
|
||||
using (MemoryStream fileStream = new MemoryStream(fileToUpload))
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace VRCX
|
||||
/// <returns>True if the world was successfully initialized, false otherwise.</returns>
|
||||
private bool TryInitializeWorld(string worldId, out string connectionKey)
|
||||
{
|
||||
if (String.IsNullOrEmpty(worldId))
|
||||
if (string.IsNullOrEmpty(worldId))
|
||||
{
|
||||
connectionKey = null;
|
||||
return false;
|
||||
@@ -421,7 +421,7 @@ namespace VRCX
|
||||
|
||||
string worldId = funcResult?.Result?.ToString();
|
||||
|
||||
if (String.IsNullOrEmpty(worldId))
|
||||
if (string.IsNullOrEmpty(worldId))
|
||||
{
|
||||
// implement
|
||||
// wait what was i going to do here again
|
||||
@@ -484,7 +484,7 @@ namespace VRCX
|
||||
/// Processes a JSON request containing world data and logs it to the world database.
|
||||
/// </summary>
|
||||
/// <param name="json">The JSON request containing the world data.</param>
|
||||
public async void ProcessLogWorldDataRequest(string json)
|
||||
public void ProcessLogWorldDataRequest(string json)
|
||||
{
|
||||
// Current format:
|
||||
// {
|
||||
@@ -519,7 +519,7 @@ namespace VRCX
|
||||
return;
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(request.RequestType))
|
||||
if (string.IsNullOrEmpty(request.RequestType))
|
||||
{
|
||||
logger.Warn("World tried to store data with no request type provided. Request: ", json);
|
||||
this.lastError = "`requestType` is missing or null";
|
||||
|
||||
Reference in New Issue
Block a user