Exemple #1
0
        public ExtensionLite(AppExtension ext, IPropertySet properties) : this() {
            AppExtension = ext;
            _valueset = properties;
            AppExtensionUniqueId = ext.AppInfo.AppUserModelId + "!" + ext.Id;

            Manifest = new ExtensionManifest();
            Manifest.AppExtensionUniqueID = AppExtensionUniqueId;
            foreach (var prop in properties)
            {
                switch (prop.Key)
                {
                    case "Title": Manifest.Title = GetValueFromProperty(prop.Value); break;
                    case "IconUrl": Manifest.IconUrl = GetValueFromProperty(prop.Value); break;
                    case "Publisher": Manifest.Publisher = GetValueFromProperty(prop.Value); break;
                    case "Version": Manifest.Version = GetValueFromProperty(prop.Value); break;
                    case "Abstract": Manifest.Abstract = GetValueFromProperty(prop.Value); break;
                    case "FoundInToolbarPositions": Manifest.FoundInToolbarPositions = (ExtensionInToolbarPositions)Enum.Parse(typeof(ExtensionInToolbarPositions), GetValueFromProperty(prop.Value)); break;
                    case "LaunchInDockPositions": Manifest.LaunchInDockPositions = (ExtensionInToolbarPositions)Enum.Parse(typeof(ExtensionInToolbarPositions), GetValueFromProperty(prop.Value)); break;
                    case "ContentControl": Manifest.ContentControl = GetValueFromProperty(prop.Value); break;
                    case "AssemblyName": Manifest.AssemblyName = GetValueFromProperty(prop.Value); break;
                    case "IsExtEnabled": Manifest.IsExtEnabled = bool.Parse(GetValueFromProperty(prop.Value)); AppSettings.AppExtensionEnabled = Manifest.IsExtEnabled; break;
                    case "IsUWPExtension": Manifest.IsUWPExtension = bool.Parse(GetValueFromProperty(prop.Value)); break;
                    case "Size": Manifest.Size = int.Parse(GetValueFromProperty(prop.Value)); break;
                }
            }

        }
Exemple #2
0
        public Toast()
        {
            this.InitializeComponent();
            this.Visibility = Visibility.Collapsed;

            ExtensionManifest = new ExtensionManifest("Inline Toasts", string.Empty, "Sample Extensions", "1.0", "Show toast messages inline within the browser", ExtensionInToolbarPositions.None, ExtensionInToolbarPositions.None);
        }
        public async Task InitExtensions()
        {
            ExtensionManifest = new ExtensionManifest("Browser Shell", string.Empty, "Sample Extensions", "1.0", "The chrome of the browser is itself an extension. Enabling/Disabling this will affect ALL extensions.", ExtensionInToolbarPositions.None, ExtensionInToolbarPositions.None);

            await X.Services.Extensions.ExtensionsService.Instance.Install(this);

            await X.Services.Extensions.ExtensionsService.Instance.Install(ctlToast);


            //Find a way to reflect this in
            //Installer.GetExtensionManifests().ForEach(x => { X.Services.Extensions.ExtensionsService.Instance.Install(x); });
            //X.Services.Extensions.ExtensionsService.Instance.Install(X.Extensions.ThirdParty.GitX.Installer.GetManifest());
            //LoadThirdPartyExtensions(Installer.GetExtensionManifests());  //<== example bulk extensions (30+ extension shells)
            X.Extensions.UI.Shared.ExtensionUtils.LoadThirdPartyExtensions(new List <ExtensionManifest> {
                X.Extensions.FirstParty.Settings.Installer.GetManifest(),
            });

            await X.Services.Extensions.ExtensionsService.Instance.PopulateAllUWPExtensions();

            X.Extensions.UI.Shared.ExtensionUtils.UpdateUWPExtensionsWithStateSavedData(X.Services.Extensions.ExtensionsService.Instance.GetUWPExtensions());


            ctlExtensionsBarTop.InstallMyself();    // does Install + LoadExtensions
            ctlExtensionsBarLeft.InstallMyself();   // does Install + LoadExtensions
            ctlExtensionsBarRight.InstallMyself();  // does Install + LoadExtensions
            ctlExtensionsBarBottom.InstallMyself(); // does Install + LoadExtensions

            //Messenger.Default.Register<ShowInstalledExtensionsMessage>(this, ShowInstalledExtensionsMessage);
        }
Exemple #4
0
        public async Task InitExtensions()
        {
            if (isRunning)
            {
                return;
            }
            isRunning = true;

            ExtensionManifest = new ExtensionManifest("X.Player", string.Empty, "X.Player", "1.0", "Generic X Extension Player", ExtensionInToolbarPositions.None, ExtensionInToolbarPositions.None);
            await X.Services.Extensions.ExtensionsService.Instance.Install(this);

            X.Extensions.UI.Shared.ExtensionUtils.LoadThirdPartyExtensions(new List <ExtensionManifest> {
                X.Extensions.FirstParty.Settings.Installer.GetManifest(),
            });

            await X.Services.Extensions.ExtensionsService.Instance.PopulateAllUWPExtensions();

            X.Extensions.UI.Shared.ExtensionUtils.UpdateUWPExtensionsWithStateSavedData(X.Services.Extensions.ExtensionsService.Instance.GetUWPExtensions());

            ctlExtensionsBarTop.InstallMyself();
            ctlExtensionsBarBottom.InstallMyself();
            ctlExtensionsBarLeft.InstallMyself();
            ctlExtensionsBarRight.InstallMyself();

            isRunning = false;
        }
Exemple #5
0
 public static ExtensionManifest InstallPackedExtension(string path)
 {
     return(InstallPackedFile <ExtensionManifest>(
                path,
                PlaynitePaths.ExtensionManifestFileName,
                PlayniteSettings.IsPortable ? PlaynitePaths.ExtensionsProgramPath : PlaynitePaths.ExtensionsUserDataPath,
                (a) => ExtensionManifest.FromFile(a)));
 }
Exemple #6
0
 public ScriptEngine(string extensionId, ExtensionManifest manifest)
 {
     _extensionId = extensionId;
     _manifest    = manifest;
     _fetch       = new Fetch(manifest, HentaiHttpHandler.Instance);
     _storage     = new LocalStorage(_extensionId, HentaiApp.Instance.Resolve <IExtensionStorage>());
     _log         = new Log(_extensionId);
     _enginePool  = new ObjectPool <Engine>(GetEngine);
 }
        public async Task UnInstallExtension(ExtensionManifest model)
        {
            var rootFolder = await GetExtensionFolder();

            var extensionFolder = await rootFolder.GetFolderAsync(model.Name);

            await extensionFolder.DeleteAsync(StorageDeleteOption.PermanentDelete);

            RemoveExtension(extensionFolder.Path);
        }
Exemple #8
0
        public void FromFileTest()
        {
            var path        = Path.Combine(PlayniteTests.ResourcesPath, PlaynitePaths.ExtensionManifestFileName);
            var description = ExtensionManifest.FromFile(path);

            Assert.IsNotEmpty(description.Module);
            Assert.IsNotEmpty(description.Author);
            Assert.IsNotEmpty(description.Name);
            Assert.IsNotEmpty(description.DescriptionPath);
            Assert.IsNotNull(description.Version);
            Assert.AreEqual(ExtensionType.GameLibrary, description.Type);
        }
Exemple #9
0
 protected void AddOrUpgradeExtension(string path, ExtensionManifest manifest)
 {
     if (_extensions.ContainsKey(path))
     {
         var current = _extensions[path];
         _extensions[path] = manifest;
         Extensions.Remove(current);
         Extensions.Add(manifest);
         _cacheEngines.Remove(path);
         _cacheApis.Remove(current);
     }
     else
     {
         _extensions.Add(path, manifest);
         Extensions.Add(manifest);
     }
 }
Exemple #10
0
        public async Task <ScriptApi?> GetApi(ExtensionManifest manifest)
        {
            if (_cacheApis.ContainsKey(manifest))
            {
                return(_cacheApis[manifest]);
            }

            var(key, _) = _extensions.FirstOrDefault(it => it.Value == manifest);
            if (!string.IsNullOrEmpty(key))
            {
                var api = new ScriptApi(await GetScriptEngineAsync(key), key, manifest);
                HentaiHttpHandler.Instance.RegisterHandler(api);
                _cacheApis.Add(manifest, api);
                return(api);
            }

            return(null);
        }
Exemple #11
0
 public InstallExtension(ExtensionManifest manifest)
 {
     InitializeComponent();
     PluginType.Content = manifest.ExtensionType.ToString();
     PluginName.Content = manifest.Name;
     foreach (var requiredPlugin in manifest.RequiredPlugins)
     {
         RequiredPlugins.Add(new ColoredText()
         {
             Text  = requiredPlugin,
             Color = (PluginLoader.Plugins.Find(x => x.Slug == requiredPlugin) != null) ? Brushes.Black : Brushes.Red
         });
     }
     foreach (var requiredPlugin in manifest.RequiredCors)
     {
         RequiredCORS.Add(new ColoredText()
         {
             Text  = requiredPlugin,
             Color = Brushes.Black
         });
     }
     //TODO: Show favicon
 }
Exemple #12
0
 public ScriptApi(ScriptEngine engine, string extensionId, ExtensionManifest manifest)
 {
     _engine      = engine;
     _extensionId = extensionId;
     _manifest    = manifest;
 }
 public ExtensionsIconBarRight()
 {
     this.InitializeComponent();
     ExtensionManifest = new ExtensionManifest("Right Extensions Toolbar", string.Empty, "Sample Extensions", "1.0", "A UI to manage all the installed extensions in the Right Toolbar", ExtensionInToolbarPositions.None, ExtensionInToolbarPositions.None);
 }
 public HandleNavigationFailedAsInlineToast()
 {
     ExtensionManifest = new ExtensionManifest("Navigation Failed Interceptor", string.Empty, "Sample Extensions", "1.0", "Listen to a webview's 'NavigationFailed' event and pass it on to other extensions. etc.", ExtensionInToolbarPositions.None, ExtensionInToolbarPositions.None);
 }
        public async Task UnInstallExtension(ExtensionManifest model)
        {
            await _manager.UnInstallExtension(model);

            NetworkExtensions.Refresh();
        }
 public LoadedPlugin(Plugin plugin, ExtensionManifest description)
 {
     Plugin      = plugin;
     Description = description;
 }
Exemple #17
0
 public Fetch(ExtensionManifest manifest, HttpMessageHandler handler)
 {
     _manifest = manifest;
     _client   = new HttpClient(handler);
 }
        public bool Check(string PluginName, string PluginFolder)
        {
            this.PluginName = PluginName;
            var deserializer = new DeserializerBuilder().IgnoreUnmatchedProperties().Build();

            var path = Path.Combine(PluginFolder, PlaynitePaths.ExtensionManifestFileName);

            PluginInfo = ExtensionManifest.FromFile(path);

            // Get Github info
            string url = string.Format(urlGithub, PluginName.ToLower());

#if DEBUG
            logger.Debug($"PluginCommon - Download {url} for {PluginName}");
#endif

            string ResultWeb = string.Empty;
            try
            {
                ResultWeb = Web.DownloadStringData(url, WebUserAgentType.Request).GetAwaiter().GetResult();
            }
            catch (WebException ex)
            {
                logger.Error($"Failed to load from {url} for {PluginName}");
#if DEBUG
                Common.LogError(ex, "PluginCommon", $"Failed to load from {url} for {PluginName}");
#endif
            }

            LastReleaseUrl     = string.Empty;
            LastReleaseTagName = string.Empty;
            LastReleaseBody    = string.Empty;

            if (!ResultWeb.IsNullOrEmpty())
            {
                try
                {
                    JArray resultObj = JArray.Parse(ResultWeb);
                    if (resultObj[0]["html_url"] != null)
                    {
                        LastReleaseUrl     = (string)resultObj[0]["html_url"];
                        LastReleaseTagName = (string)resultObj[0]["tag_name"];
                        LastReleaseBody    = (string)resultObj[0]["body"];
                    }

                    logger.Info($"PluginCommon - {PluginName} - Find {LastReleaseTagName} - Actual v{PluginInfo.Version}");
                }
                catch (Exception ex)
                {
                    Common.LogError(ex, "PluginCommon", $"Failed to parse Github response for {PluginName} - {ResultWeb}");
                    return(false);
                }
            }
            else
            {
                logger.Warn($"PluginCommon - No Data from {url} for {PluginName}");
            }

            //Check actual vs Github
            return(!LastReleaseTagName.IsNullOrEmpty() && LastReleaseTagName != "v" + PluginInfo.Version);
        }
Exemple #19
0
 public OSToast()
 {
     ExtensionManifest = new ExtensionManifest("OS Toasts", string.Empty, "Sample Extensions", "1.0", "Bubble toasts to the OS which appear in the Action Center and as a floating Toast", ExtensionInToolbarPositions.None, ExtensionInToolbarPositions.None);
 }
 public HandleNewWindowAsInlineLink()
 {
     ExtensionManifest = new ExtensionManifest("New Window Interceptor", string.Empty, "Sample Extensions", "1.0", "Listen to a webview's 'NewWindowRequested' event and pass it on to other extensions. This can be used by popup blockers etc.", ExtensionInToolbarPositions.None, ExtensionInToolbarPositions.None);
 }
Exemple #21
0
 public ExtensionsIconBarTop()
 {
     this.InitializeComponent();
     ExtensionManifest = new ExtensionManifest("Top Extensions Toolbar", string.Empty, "Sample Extensions", "1.0", "A UI to manage all the installed extensions in the Top Toolbar", ExtensionInToolbarPositions.None, ExtensionInToolbarPositions.None);
     //layoutRoot.DataContext = this;
 }