Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't create launch file on Linux #298

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions Grayjay.ClientServer/Changelogs/4.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
Features:
- Headless mode (--headless): Allow you to use Grayjay from your browser instead, while still allowing system, login, and captcha dialogs. (Assumes local)
- Server mode (--server): Allows you to use Grayjay from a server in your browser, binds to all ips, DISABLES system, login, and captcha dialogs. (Assumes remote)
WARNING: Server mode is still intended single-user, and has no security features built in yet, so not really intended to use yet unless you know what you're doing!

- Changelog support
- Hotkey (i) now minimizes the player alongside esc
- Sidebar on left side of video (hover left if in theater mode)
- Developer Portal support (Add "DEV" file to executable directory)

- Server mode (--server): Allows you to use Grayjay from a server in your browser, binds to all ips, DISABLES system, login, and captcha dialogs. (Assumes remote)
WARNING: Server mode is still intended single-user, and has no security features built in yet, so not really intended to use yet unless you know what you're doing!
- Testing tab support (limited methods, rest via console)
- Integration tab support
- Desktop exclusive feature: Clone login to integration dev plugin from primary plugin

- Unstable pipeline, can be used by modifying UpdaterConfig's server property by changing "Grayjay.Desktop" => "Grayjay.Desktop.Unstable"
WARNING: Not recommended for most people, as there might be broken functionality in that release pipeline.

- Updater version visible in settings

Improvements:
- Directory used on Windows changed when Portable file does not exist, in the following priority (higher is higher priority):
Expand All @@ -19,16 +22,21 @@ Improvements:

- Directory used on Linux changed when Portable file does not exist, in the following priority (higher is higher priority):
- ~/Grayjay if exists
- {XDG_DATA_HOME}/Grayjay if XDG_DATA_HOME variable exists
- ~/.local/share/Grayjay if exists
- ~/.local/config/Grayjay if exists
- ~/Grayjay if not exists

- Scrollbar for official sources dialog
- Improved Grayjay's ability to find its CEF dependency
- PeekChannelContents support (for users with large amount of subscriptions (>150+))

Fixes:
- Fix issue where setStartTime was not available
- License not re-loading on boot
- Fix License not re-loading on boot
- Several fixes related to Sync
- Some dialog scaling fixes
- Some fixes related to Linux updater interactions

- Fixes with Updater
- Updater not properly truncating files that became shorter
Expand Down
40 changes: 0 additions & 40 deletions Grayjay.ClientServer/Changelogs/5.txt

This file was deleted.

6 changes: 5 additions & 1 deletion Grayjay.ClientServer/Constants/Directories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ public static class Directories
else if (OperatingSystem.IsMacOS())
{
string oldStyleDir = Path.Combine(userDir, "Library/Application Support", "Grayjay");
dir = oldStyleDir;
string newStyleDir = Path.Combine(userDir, "Containers", "com.futo.grayjay.desktop", "Data", "Library", "Application Support");
if (Directory.Exists(oldStyleDir))
dir = oldStyleDir;
else
dir = newStyleDir;
}
else
{
Expand Down
38 changes: 36 additions & 2 deletions Grayjay.ClientServer/Controllers/DeveloperController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Xml;
using Futo.PlatformPlayer.States;
using Grayjay.ClientServer.Developer;
using Grayjay.ClientServer.Dialogs;
using Grayjay.ClientServer.Settings;
Expand Down Expand Up @@ -77,7 +78,7 @@ public IActionResult Index()
return NotFound();
var html = Encoding.UTF8.GetString(ReadResource("Grayjay.ClientServer.Developer.Embed.index.html"));
html = html
.Replace("SUPPORT_INTEGRATION: true", "SUPPORT_INTEGRATION: false");
.Replace("SUPPORT_INTEGRATION: true", "SUPPORT_INTEGRATION: true");
if (!string.IsNullOrEmpty(lastDevUrl.Value))
html = html.Replace("LAST_DEV_URLS: []", "LAST_DEV_URLS: [" + JsonConvert.SerializeObject(lastDevUrl.Value) + "]");
return File(Encoding.UTF8.GetBytes(html), "text/html");
Expand Down Expand Up @@ -277,7 +278,7 @@ public IActionResult GetDevLogs(int index)
{
if (!IsDeveloperMode())
return NotFound();
return Ok(new string[] { });
return Ok(StateDeveloper.Instance.GetLogs(index));
}

public class ProxyRequest
Expand Down Expand Up @@ -333,6 +334,39 @@ public IActionResult IsLoggedIn()
return Ok(_testPluginAuth.Item2 != null && _testPluginAuth.Item1 == _testPlugin?.ID);
}

[HttpPost]
public IActionResult LoadDevPlugin([FromBody]PluginConfig config)
{
if (!IsDeveloperMode())
return NotFound();
try
{
config.IconUrl = GrayjayServer.Instance.BaseUrl + "/web/src/assets/favicon.png";
string script = null;
if (IsFileUrl(config.AbsoluteScriptUrl))
{
string path = config.AbsoluteScriptUrl;
if (config.AbsoluteScriptUrl.StartsWith("file:///"))
path = config.AbsoluteScriptUrl.Substring("file:///".Length);
script = System.IO.File.ReadAllText(path);
}
else
{
var resp = _client.GET(config.AbsoluteScriptUrl, new Dictionary<string, string>());
if (!resp.IsOk)
return BadRequest($"URL {config.ScriptUrl} return code {resp.Code}");
if(resp.Body == null)
return BadRequest($"URL {config.ScriptUrl} return no body");
script = resp.Body.AsString();
}
string devId = StatePlatform.InjectDevPlugin(config, script);
return Ok(devId);
}
catch(Exception ex)
{
return BadRequest(ex);
}
}



Expand Down
10 changes: 6 additions & 4 deletions Grayjay.ClientServer/Controllers/SettingsController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json.Nodes;
using Futo.PlatformPlayer.States;
using Grayjay.ClientServer.Settings;
using Grayjay.ClientServer.States;
using Grayjay.ClientServer.Store;
Expand Down Expand Up @@ -49,7 +50,7 @@ public bool SettingsSave([FromBody]GrayjaySettings settings)

//Source app settings
public SettingsObject<PluginAppSettings> SourceAppSettings(string id)
=> StatePlugins.GetPlugin(id)?.AppSettings?.GetSettingsObject(id);
=> (id == StateDeveloper.DEV_ID) ? StatePlatform.GetDevClient()?.Descriptor?.AppSettings?.GetSettingsObject() : StatePlugins.GetPlugin(id)?.AppSettings?.GetSettingsObject(id);

[HttpPost]
public bool SourceAppSettingsSave(string id, [FromBody]PluginAppSettings settings)
Expand All @@ -66,16 +67,17 @@ public bool SourceAppSettingsSave(string id, [FromBody]PluginAppSettings setting

//Source-defined settings
public SettingsObject<Dictionary<string, string>> SourceSettings(string id)
=> StatePlugins.GetPlugin(id)?.GetSettingsObject();
=> (id == StateDeveloper.DEV_ID) ? StatePlatform.GetDevClient()?.Descriptor?.GetSettingsObject() : StatePlugins.GetPlugin(id)?.GetSettingsObject();

[HttpPost]
public bool SourceSettingsSave(string id, [FromBody] Dictionary<string, object> settings)
{
if (settings == null)
return false;
PluginDescriptor descriptor = StatePlugins.GetPlugin(id);
PluginDescriptor descriptor = (id == StateDeveloper.DEV_ID) ? StatePlatform.GetDevClient()?.Descriptor : StatePlugins.GetPlugin(id);
descriptor.Settings = settings.ToDictionary(x=>x.Key, y=>y.Value?.ToString() ?? "");
StatePlugins.UpdatePlugin(id);
if(id != StateDeveloper.DEV_ID)
StatePlugins.UpdatePlugin(id);
StateUI.Toast($"Saved [{descriptor.Config.Name}] plugin settings");
return true;
}
Expand Down
70 changes: 62 additions & 8 deletions Grayjay.ClientServer/Controllers/SourcesController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Grayjay.ClientServer.Exceptions;
using Futo.PlatformPlayer.States;
using Grayjay.ClientServer.Exceptions;
using Grayjay.ClientServer.Models;
using Grayjay.ClientServer.Models.Sources;
using Grayjay.Desktop.POC;
Expand Down Expand Up @@ -59,7 +60,20 @@ public PluginConfig[] SourcesDisabled()
[HttpGet]
public async Task<bool> SourceEnable(string id)
{
await StatePlatform.EnableClient(id);
try
{
await StatePlatform.EnableClient(id, true);
}
catch( Exception ex)
{
PluginDescriptor config = null;
try
{
config = StatePlugins.GetPlugin(id);
}
catch (Exception _) { }
throw DialogException.FromException($"Failed to enable plugin [{config?.Config.Name}]", ex);
}
return true;
}
[HttpGet]
Expand All @@ -77,7 +91,7 @@ public async Task<bool> SourceLogin(string id)
throw new NotImplementedException("Running headless, login only supported in UI application mode");
}

var descriptor = StatePlugins.GetPlugin(id);
var descriptor = (id == StateDeveloper.DEV_ID) ? StatePlatform.GetDevClient()?.Descriptor : StatePlugins.GetPlugin(id);
var pluginConfig = descriptor.Config;
var authConfig = pluginConfig.Authentication;

Expand Down Expand Up @@ -128,13 +142,14 @@ void _closed()
//Finished
if (_didLogIn())
{
var plugin = StatePlugins.GetPlugin(id);
var plugin = (id == StateDeveloper.DEV_ID) ? StatePlatform.GetDevClient()?.Descriptor : StatePlugins.GetPlugin(id);
plugin.SetAuth(new SourceAuth()
{
Headers = headersFoundMap,
CookieMap = cookiesFoundMap
});
StatePlugins.UpdatePlugin(id, true);
if (id != StateDeveloper.DEV_ID)
StatePlugins.UpdatePlugin(id, true);
}
}

Expand Down Expand Up @@ -231,16 +246,49 @@ void _closed()
return true;
}

[HttpGet]
public async Task<bool> SourceLoginDevClone()
{
var plugin = StatePlatform.GetDevClient();
if (plugin == null)
return false;

if(plugin.OriginalID == null)
{
StateUI.Toast("DEV Plugin has no original id");
return false;
}

var mainPlugin = StatePlugins.GetPlugin(plugin.OriginalID);
if (mainPlugin == null)
{
StateUI.Toast("No main plugin found for id");
return false;
}

var auth = mainPlugin.GetAuth();
if(auth == null)
{
StateUI.Toast("Main plugin is not authenticated");
return false;
}
plugin.Descriptor.SetAuth(auth);
StateUI.Toast("Plugin auth copied to dev plugin");
return true;
}


[HttpGet]
public async Task<bool> SourceLogout(string id)
{
var descriptor = StatePlugins.GetPlugin(id);
var descriptor = (id == StateDeveloper.DEV_ID) ? StatePlatform.GetDevClient()?.Descriptor : StatePlugins.GetPlugin(id);
var pluginConfig = descriptor.Config;
var authConfig = pluginConfig.Authentication;
if(authConfig != null)
{
descriptor.SetAuth(null);
StatePlugins.UpdatePlugin(id, true);
if(id != StateDeveloper.DEV_ID)
StatePlugins.UpdatePlugin(id, true);
}
_ = StateUI.Dialog("", "Please restart Grayjay before logging in again", "Grayjay does not clear past cookies yet after logout, please restart before trying to login again, or it will reuse your current login.", null, 0, new StateUI.DialogAction("Ok", () => { }));
return true;
Expand Down Expand Up @@ -399,7 +447,13 @@ public object InstallOfficialPlugins([FromBody]string[] ids)
Text = "Enable",
Action = async (resp) =>
{
_ = StatePlatform.EnableClients(toQueryEnable.Select(x=>x.ID).ToArray());
try {
_ = StatePlatform.EnableClients(toQueryEnable.Select(x=>x.ID).ToArray());
}
catch(Exception ex)
{
StateUI.DialogError("Failed to enable Plugin", ex);
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions Grayjay.ClientServer/Controllers/WindowController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,16 @@ public void StartWindow()
OSHelper.OpenUrl($"{GrayjayServer.Instance.BaseUrl}/web/index.html");
}).Start();
}

[HttpGet]
public void Ready()
{
var state = this.State();
if (state != null)
{
state.Ready = true;
StateWindow.StateReadyChanged(state, true);
}
}
}
}
Loading