private void SaveEntryPoint(EntryPointItem entryPoint) { RegistryKey EntryPointsTree = Registry.LocalMachine.OpenSubKey(Constants.ENTRYPOINTS_REGISTRY_PATH, true); try { RegistryKey EntryPointsSubKey = EntryPointsTree.OpenSubKey(entryPoint.GUID, true); if (EntryPointsSubKey == null) { EntryPointsTree.CreateSubKey(entryPoint.GUID); EntryPointsSubKey = EntryPointsTree.OpenSubKey(entryPoint.GUID, true); } if (EntryPointsSubKey != null) { WriteValue(EntryPointsSubKey, entryPoint.Title); WriteValue(EntryPointsSubKey, entryPoint.Context); WriteValue(EntryPointsSubKey, entryPoint.TimeStamp); WriteValue(EntryPointsSubKey, entryPoint.AddIn); WriteValue(EntryPointsSubKey, entryPoint.AppID); WriteValue(EntryPointsSubKey, entryPoint.Description); WriteValue(EntryPointsSubKey, entryPoint.ImageUrl); WriteValue(EntryPointsSubKey, entryPoint.InactiveImageUrl); } } catch (Exception ex) { throw new Exception("Error saving entrypoint. " + ex.Message); } }
private void CreateEntryPoint(EntryPointItem entryPoint) { try { String GUID = "{" + CreateGuid().ToString() + "}"; entryPoint = new EntryPointItem(this._MainMBEntryPoint.AppID.Value, this._MainMBEntryPoint.AddIn.Value, entryPoint.Context.Value, entryPoint.Title.Value, GUID, this._MainMBEntryPoint.Description.Value, this._MainMBEntryPoint.ImageUrl.Value, this._MainMBEntryPoint.InactiveImageUrl.Value); this.SaveEntryPoint(entryPoint); CreateHiddenCategoryEntryPoint(GUID); } catch (Exception ex) { throw new Exception("Error creating Entrypoint. " + ex.Message); } }
public EntryPointManager() { if (!TestRegistryAccess()) { throw new Exception("This account does not have suffisant privileges to write to the registry."); } this._MainMBEntryPoint = FetchEntryPoint(Constants.MB_MAIN_ENTRYPOINT_GUID); try { if (ValidateHiddenEntryPoint(Constants.MB_CONFIG_ENTRYPOINT_GUID) == false) { CreateHiddenCategoryEntryPoint(Constants.MB_CONFIG_ENTRYPOINT_GUID); } } catch (Exception ex) { throw new Exception("Error validating Hidden entrypoint for " + Constants.MB_CONFIG_ENTRYPOINT_GUID + ". " + ex.Message); } }
private List <EntryPointItem> FetchMediaBrowserEntryPoints() { List <EntryPointItem> EntryPoints = new List <EntryPointItem>(); RegistryKey EntryPointsTree = Registry.LocalMachine.OpenSubKey(Constants.ENTRYPOINTS_REGISTRY_PATH); foreach (var Key in EntryPointsTree.GetSubKeyNames()) { try { if (Key.ToLower() == Constants.MB_MAIN_ENTRYPOINT_GUID.ToLower() || Key.ToLower() == Constants.MB_CONFIG_ENTRYPOINT_GUID.ToLower()) { continue; } if (FetchAppID(Key).ToLower() == Constants.APPLICATION_ID.ToLower()) { EntryPointItem entryPoint = FetchEntryPoint(Key); if (entryPoint != null) { if (FetchAddIn(Key).ToLower() != FetchAddIn(Constants.MB_MAIN_ENTRYPOINT_GUID).ToLower()) {// If the value in Addin is differnet than in the main entrypoint key, update the value entryPoint.AddIn.Value = (FetchAddIn(Constants.MB_MAIN_ENTRYPOINT_GUID)); SaveEntryPoint(entryPoint); } EntryPoints.Add(entryPoint); } } } catch (Exception ex) { Logger.ReportException("Failed in FetchMediaBrowserEntryPoints " + ex.Message + ". Deleting entrypoing " + Key, ex); this.DeleteEntryPointKey(Key); } } return(EntryPoints); }
private void RefreshEntryPoints(bool RefreshPlugins) { Async.Queue("Configurator ep refresh", () => { using (new MediaBrowser.Util.Profiler("Entry Point Refresh")) { EntryPointManager epm = null; try { epm = new EntryPointManager(); } catch (Exception ex) { //Write to error log, don't prompt user. Logger.ReportError("Error starting Entry Point Manager in RefreshEntryPoints(). " + ex.Message); return; } try { List<EntryPointItem> entryPoints = new List<EntryPointItem>(); try { Logger.ReportInfo("Reloading Virtual children"); if (RefreshPlugins) { //Kernel.Init(KernelLoadDirective.ShadowPlugins); Kernel.Instance.ReLoadRoot(); } Kernel.Instance.RootFolder.ValidateChildren(); } catch (Exception ex) { Logger.ReportError("Error validating children. " + ex.Message, ex); throw new Exception("Error validating children. " + ex.Message); } foreach (var folder in Kernel.Instance.RootFolder.Children) { String displayName = folder.Name; if (displayName == null || displayName.Length <= 0) continue; String path = string.Empty; if (folder.GetType() == typeof(Folder) && folder.Path != null && folder.Path.Length > 1) { path = folder.Path; } else { path = folder.Id.ToString(); } EntryPointItem ep = new EntryPointItem(displayName, path); entryPoints.Add(ep); } epm.ValidateEntryPoints(entryPoints); } catch (Exception ex) { String msg = "Error Refreshing Entry Points. " + ex.Message; Logger.ReportError(msg, ex); //MessageBox.Show(msg); } } }); }
private void SaveEntryPoint(EntryPointItem entryPoint) { RegistryKey EntryPointsTree = Registry.LocalMachine.OpenSubKey(Constants.ENTRYPOINTS_REGISTRY_PATH, true); try { RegistryKey EntryPointsSubKey = EntryPointsTree.OpenSubKey(entryPoint.GUID, true); if (EntryPointsSubKey == null) { EntryPointsTree.CreateSubKey(entryPoint.GUID); EntryPointsSubKey = EntryPointsTree.OpenSubKey(entryPoint.GUID, true); } if (EntryPointsSubKey != null) { WriteValue(EntryPointsSubKey, entryPoint.Title); WriteValue(EntryPointsSubKey, entryPoint.Context); WriteValue(EntryPointsSubKey, entryPoint.TimeStamp); WriteValue(EntryPointsSubKey, entryPoint.AddIn); WriteValue(EntryPointsSubKey, entryPoint.AppID); WriteValue(EntryPointsSubKey, entryPoint.Description); WriteValue(EntryPointsSubKey, entryPoint.ImageUrl); WriteValue(EntryPointsSubKey, entryPoint.InactiveImageUrl); } } catch (Exception ex) { throw new Exception ("Error saving entrypoint. " + ex.Message); } }
private void CreateEntryPoint(EntryPointItem entryPoint) { try { String GUID = "{" + CreateGuid().ToString() + "}"; entryPoint = new EntryPointItem(this._MainMBEntryPoint.AppID.Value, this._MainMBEntryPoint.AddIn.Value, entryPoint.Context.Value, entryPoint.Title.Value, GUID, this._MainMBEntryPoint.Description.Value, this._MainMBEntryPoint.ImageUrl.Value, this._MainMBEntryPoint.InactiveImageUrl.Value); this.SaveEntryPoint(entryPoint); CreateHiddenCategoryEntryPoint(GUID); } catch (Exception ex) { throw new Exception("Error creating Entrypoint. " +ex.Message); } }
public EntryPointManager() { if (!TestRegistryAccess()) { throw new Exception("This account does not have suffisant privileges to write to the registry."); } this._MainMBEntryPoint = FetchEntryPoint(Constants.MB_MAIN_ENTRYPOINT_GUID); try { if (ValidateHiddenEntryPoint(Constants.MB_CONFIG_ENTRYPOINT_GUID) == false) { CreateHiddenCategoryEntryPoint(Constants.MB_CONFIG_ENTRYPOINT_GUID); } } catch (Exception ex) { throw new Exception("Error validating Hidden entrypoint for " + Constants.MB_CONFIG_ENTRYPOINT_GUID + ". " + ex.Message); } }