/// <summary> /// Creates a new integration state View-Model. /// </summary> /// <param name="integrationManager">The integration manager used to apply selected integration options.</param> /// <param name="appEntry">The application being integrated.</param> /// <param name="feed">The feed providing additional metadata, icons, etc. for the application.</param> public IntegrationState([NotNull] IIntegrationManager integrationManager, [NotNull] AppEntry appEntry, [NotNull] Feed feed) { #region Sanity checks if (integrationManager == null) { throw new ArgumentNullException("integrationManager"); } if (appEntry == null) { throw new ArgumentNullException("appEntry"); } if (feed == null) { throw new ArgumentNullException("feed"); } #endregion _integrationManager = integrationManager; AppEntry = appEntry; Feed = feed; CapabilitiyRegistration = (AppEntry.AccessPoints == null) || AppEntry.AccessPoints.Entries.OfType <AccessPoints.CapabilityRegistration>().Any(); LoadCommandAccessPoints(); LoadDefaultAccessPoints(); }
public void AccessPointCandidatesInternalConflict() { var accessPoints = new AccessPoint[] {new MockAccessPoint {ID = "a"}, new MockAccessPoint {ID = "a"}}; var appEntry = new AppEntry {Name = "App"}; Assert.Throws<ConflictException>(() => accessPoints.GetConflictData(appEntry)); }
private void btnRemoveApp_Click(object sender, RoutedEventArgs e) { AppEntry sel = tvwApps.SelectedItem as AppEntry; if (sel == null) { return; } if (sel.IsFolder && sel.Children.Count > 0) { var resp = MessageBox.Show( QTUtility.TextResourcesDic["Options_Page10_Apps"][15], QTUtility.TextResourcesDic["OptionsDialog"][3], MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); if (resp == MessageBoxResult.Cancel) { return; } } IList list = sel.ParentList; int index = list.IndexOf(sel); list.RemoveAt(index); if (list.Count == 0) { return; } if (index == list.Count) { --index; } ((ITreeViewItem)list[index]).IsSelected = true; }
public static void Main(String[] args) { if (ParseCommandLine(args)) { AppEntry.InitializeApplication(); } }
static void Main() { string commandLine = @"/run ../../../ebDataLayer.Tests/eBDataLayer.Tests.csproj"; string[] args = commandLine.Split(' '); AppEntry.Main(args); }
/// <inheritdoc/> public override void Apply(AppEntry appEntry, Feed feed, ITaskHandler handler, bool machineWide) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException("appEntry"); } if (handler == null) { throw new ArgumentNullException("handler"); } #endregion var capability = appEntry.GetCapability <Store.Model.Capabilities.UrlProtocol>(Capability); if (capability == null) { return; } var target = new FeedTarget(appEntry.InterfaceUri, feed); if (WindowsUtils.IsWindows) { Windows.UrlProtocol.Register(target, capability, machineWide, handler, accessPoint: true); } }
/// <inheritdoc/> public override void Apply(AppEntry appEntry, Feed feed, ITaskHandler handler, bool machineWide) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException("appEntry"); } if (handler == null) { throw new ArgumentNullException("handler"); } #endregion var capability = appEntry.GetCapability <Store.Model.Capabilities.ContextMenu>(Capability); if (capability == null) { return; } var target = new FeedTarget(appEntry.InterfaceUri, feed); if (WindowsUtils.IsWindows) { Windows.ContextMenu.Apply(target, capability, machineWide, handler); } else if (UnixUtils.IsUnix) { Unix.ContextMenu.Apply(target, capability, machineWide, handler); } }
public void NoConflicts() { var accessPointA = new MockAccessPoint { ID = "a" }; var appEntry1 = new AppEntry { Name = "App1", InterfaceUri = FeedTest.Test1Uri, AccessPoints = new AccessPointList { Entries = { accessPointA } } }; var accessPointB = new MockAccessPoint { ID = "b" }; var appEntry2 = new AppEntry { Name = "App2", InterfaceUri = FeedTest.Test2Uri }; var appList = new AppList { Entries = { appEntry1 } }; appList.CheckForConflicts(new[] { accessPointB }, appEntry2); }
/// <inheritdoc/> protected override void RemoveAccessPointsInternal(AppEntry appEntry, IEnumerable <AccessPoint> accessPoints) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } if (accessPoints == null) { throw new ArgumentNullException(nameof(accessPoints)); } #endregion if (appEntry.AccessPoints == null) { return; } accessPoints = accessPoints.ToArray(); foreach (var accessPoint in accessPoints) { accessPoint.Unapply(appEntry, MachineWide); } // Remove the access points from the AppList appEntry.AccessPoints.Entries.RemoveRange(accessPoints); appEntry.Timestamp = DateTime.UtcNow; }
/// <inheritdoc/> public override void Apply(AppEntry appEntry, Feed feed, IIconStore iconStore, bool machineWide) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } if (iconStore == null) { throw new ArgumentNullException(nameof(iconStore)); } #endregion ValidateName(); var target = new FeedTarget(appEntry.InterfaceUri, feed); if (WindowsUtils.IsWindows) { Windows.AppAlias.Create(target, Command, Name, iconStore, machineWide); } else if (UnixUtils.IsUnix) { Unix.AppAlias.Create(target, Command, Name, iconStore, machineWide); } }
static void Main() { string commandLine = @"/run ../../../../../DocumentsDataLayer.NUnit/bin/Debug/DocumentsDataLayer.NUnit.dll"; string[] args = commandLine.Split(' '); AppEntry.Main(args); }
/// <summary> /// Creates a new alias. /// </summary> /// <param name="appEntry">The app entry to add the alias to.</param> /// <param name="aliasName">The name of the alias to create.</param> /// <param name="command">A command within the interface the alias shall point to; can be <c>null</c>.</param> protected void CreateAlias(AppEntry appEntry, string aliasName, string?command = null) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } if (string.IsNullOrEmpty(aliasName)) { throw new ArgumentNullException(nameof(aliasName)); } #endregion CheckInstallBase(); // Check this before modifying the environment bool needsReopenTerminal = NeedsReopenTerminal(MachineWide); // Apply the new alias var alias = new AppAlias { Name = aliasName, Command = command }; IntegrationManager.AddAccessPoints(appEntry, FeedManager[InterfaceUri], new AccessPoint[] { alias }); string message = string.Format(Resources.AliasCreated, aliasName, appEntry.Name); if (needsReopenTerminal) { message += Environment.NewLine + Resources.ReopenTerminal; } Handler.OutputLow(Resources.DesktopIntegration, message); }
static void Main() { string commandLine = @"/run ../../../../../SPP3DDataLayer.NUnit/SPP3DDataLayer.NUnit.csproj"; string[] args = commandLine.Split(' '); AppEntry.Main(args); }
/// <inheritdoc/> public override void Unapply(AppEntry appEntry, bool machineWide) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } #endregion var dispatcher = new PerTypeDispatcher <Capability>(ignoreMissing: true); if (WindowsUtils.IsWindows) { dispatcher.Add((Store.Model.Capabilities.FileType fileType) => Windows.FileType.Unregister(fileType, machineWide)); dispatcher.Add((Store.Model.Capabilities.UrlProtocol urlProtocol) => Windows.UrlProtocol.Unregister(urlProtocol, machineWide)); dispatcher.Add((Store.Model.Capabilities.AutoPlay autoPlay) => Windows.AutoPlay.Unregister(autoPlay, machineWide)); dispatcher.Add((ComServer comServer) => Windows.ComServer.Unregister(comServer, machineWide)); if (machineWide || WindowsUtils.IsWindows8) { dispatcher.Add((AppRegistration appRegistration) => Windows.AppRegistration.Unregister(appRegistration, machineWide)); } if (machineWide) { dispatcher.Add((Store.Model.Capabilities.DefaultProgram defaultProgram) => Windows.DefaultProgram.Unregister(defaultProgram)); } } else if (UnixUtils.IsUnix) { dispatcher.Add((Store.Model.Capabilities.FileType fileType) => Unix.FileType.Unregister(fileType, machineWide)); dispatcher.Add((Store.Model.Capabilities.UrlProtocol urlProtocol) => Unix.UrlProtocol.Unregister(urlProtocol, machineWide)); dispatcher.Add((Store.Model.Capabilities.DefaultProgram defaultProgram) => Unix.DefaultProgram.Unregister(defaultProgram, machineWide)); } dispatcher.Dispatch(appEntry.CapabilityLists.CompatibleCapabilities()); }
private AppEntry ReplaceAppEntry(IIntegrationManager integrationManager, AppEntry entry, FeedTarget newTarget) { integrationManager.RemoveApp(entry); var newEntry = CreateAppEntry(integrationManager, newTarget); integrationManager.AddAccessPoints(newEntry, newTarget.Feed, entry.AccessPoints.Entries); return(newEntry); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); AudioBox.ItemsSource = AudioList; if ((int)localSettings.Values[Settings.ACTIONACTION] == Settings.Actions.CREATE) { return; } using (var context = new TaskSchedulerDbContext()) { Models.Action action = context.Actions.Where(x => x.Id == (int)localSettings.Values[Settings.ACTIONID]).First(); switch (action.Type) { case ActionType.URI: { UriAction uriAction = context.UriActions.Where(x => x.Id == action.ActionId).First(); Uri = uriAction.Uri; Index = 0; }; break; case ActionType.NOTIFICATION: { NotificationAction notificationAction = context.NotificationActions.Where(x => x.Id == action.ActionId).First(); Text = notificationAction.Text; Image = notificationAction.Image; Audio = notificationAction.Audio.GetValueOrDefault(0); if (notificationAction.Timeout.HasValue) { Timeout = notificationAction.Timeout.Value.ToString(); } Index = 1; }; break; case ActionType.APPLICATION: { ApplicationAction applicationAction = context.ApplicationActions.Where(x => x.Id == action.ActionId).First(); appListProvider.IsDoneTask.ContinueWith(async(result) => { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { bool ok = appListProvider.AppList.Where(x => x.Package.Id.FullName == applicationAction.ApplicationName).Any(); if (ok) { AppEntry entry = appListProvider.AppList.Where(x => x.Package.Id.FullName == applicationAction.ApplicationName).First(); LoadedContent.SelectedItem = entry; LoadedContent.ScrollIntoView(entry); } }); }); Index = 2; }; break; } } }
private AppEntry getAppEntry() { IViewHelper helper = catalog.GetHelperFor(App.ENTRY); helper.Criteria[App.ENTRY_KEY] = ENTRY_KEY_VALUE_FORMAT; helper.Execute(); AssertNominal(helper); AppEntry entry = new AppEntry(helper.Criteria); return entry; }
static void Main() { string[] args = { "/run", "../../../NUnit.Tests/NUnit.Tests.csproj" }; AppEntry.Main(args); }
private async void RunJobsAtTime(List <Job> jobs, int milisecondsDelay) { await Task.Delay(milisecondsDelay); foreach (Job job in jobs) { Debug.WriteLine("RUN JOB: " + job.Name); Cron.CronStructure cs = cronMapping[job]; ScheduleJob(job, cs); using (var context = new TaskSchedulerDbContext()) { UriAction[] uriActions = context.UriActionsForActionPredicate(x => x.JobId == job.Id); NotificationAction[] notificationActions = context.NotificationActionsForActionPredicate(x => x.JobId == job.Id); ApplicationAction[] applicationActions = context.ApplicationActionsForActionPredicate(x => x.JobId == job.Id); try { foreach (var action in uriActions) { await Launcher.LaunchUriAsync(new Uri(action.Uri)); } foreach (var action in notificationActions) { Toast.ShowToastNotification(job.Name, action.Text, action.Image, action.Audio, action.Timeout); } await appListProvider.IsDoneTask.ContinueWith(async (Task) => { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, async() => { foreach (var action in applicationActions) { var appQuery = appListProvider.AppList.Where(x => x.Package.Id.FullName == action.ApplicationName); if (appQuery.Any()) { AppEntry entry = appQuery.First(); bool opr = await entry.Entry.LaunchAsync(); while (!opr) { await Task.Delay(1000); opr = await entry.Entry.LaunchAsync(); } } } }); }); } catch (Exception e) { Debug.WriteLine(e.Message); } } } }
/// <summary> /// Creates a new integration state View-Model. /// </summary> /// <param name="integrationManager">The integration manager used to apply selected integration options.</param> /// <param name="appEntry">The application being integrated.</param> /// <param name="feed">The feed providing additional metadata, icons, etc. for the application.</param> public IntegrationState(IIntegrationManager integrationManager, AppEntry appEntry, Feed feed) { _integrationManager = integrationManager ?? throw new ArgumentNullException(nameof(integrationManager)); AppEntry = appEntry ?? throw new ArgumentNullException(nameof(appEntry)); Feed = feed ?? throw new ArgumentNullException(nameof(feed)); CapabilityRegistration = (AppEntry.AccessPoints == null) || AppEntry.AccessPoints.Entries.OfType <AccessPoints.CapabilityRegistration>().Any(); LoadCommandAccessPoints(); LoadDefaultAccessPoints(); }
public void RunGui() { Thread t = new Thread((x) => { AppEntry.Main(new[] { Assembly.GetEntryAssembly().Location }); }); t.SetApartmentState(ApartmentState.STA); t.IsBackground = true; t.Start(); }
/// <inheritdoc/> public override IEnumerable <string> GetConflictIDs(AppEntry appEntry) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } #endregion return(appEntry.CapabilityLists.CompatibleCapabilities().SelectMany(x => x.ConflictIDs)); }
public void AccessPointCandidates() { var accessPoints = new AccessPoint[] {new MockAccessPoint {ID = "a"}, new MockAccessPoint {ID = "b"}}; var appEntry = new AppEntry {Name = "App"}; accessPoints.GetConflictData(appEntry).Should().Equal(new Dictionary<string, ConflictData>() { {"mock:a", new ConflictData(accessPoints[0], appEntry)}, {"mock:b", new ConflictData(accessPoints[1], appEntry)} }); }
/// <inheritdoc/> public override IEnumerable <string> GetConflictIDs(AppEntry appEntry) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } #endregion var capability = appEntry.LookupCapability <Store.Model.Capabilities.DefaultProgram>(Capability); return(new[] { "clients:" + capability.Service }); }
/// <inheritdoc/> public override IEnumerable <string> GetConflictIDs(AppEntry appEntry) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } #endregion var capability = appEntry.LookupCapability <Model.Capabilities.AutoPlay>(Capability); return(capability.Events.Select(@event => $"autoplay-event:{@event.Name}")); }
public void ReApply() { var accessPointA = new MockAccessPoint {ID = "a"}; var appEntry1 = new AppEntry { Name = "App1", InterfaceUri = FeedTest.Test1Uri, AccessPoints = new AccessPointList {Entries = {accessPointA}} }; var appList = new AppList {Entries = {appEntry1}}; appList.CheckForConflicts(new[] {accessPointA}, appEntry1); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (Control == null || e.OldElement != null || this.Element == null) { return; } _appEntry = (this.Element as AppEntry); UpdatePadding(_appEntry); UpdateTextAlighnment(_appEntry); UpdateBackground(_appEntry); }
/// <inheritdoc/> public override IEnumerable <string> GetConflictIDs(AppEntry appEntry) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException("appEntry"); } #endregion var capability = appEntry.GetCapability <Store.Model.Capabilities.FileType>(Capability); return(capability.Extensions.Select(extension => "extension:" + extension.Value)); }
/// <inheritdoc/> public override IEnumerable <string> GetConflictIDs(AppEntry appEntry) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException("appEntry"); } #endregion var capability = appEntry.GetCapability <Store.Model.Capabilities.ContextMenu>(Capability); return(new[] { "context-menu-" + capability.Target + ":" + capability.ID + @"\" + capability.Verb }); }
/// <inheritdoc/> public override IEnumerable <string> GetConflictIDs(AppEntry appEntry) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } #endregion var capability = appEntry.LookupCapability <Model.Capabilities.FileType>(Capability); return(capability.Extensions.Select(extension => $"extension:{extension.Value}")); }
/// <inheritdoc/> public override IEnumerable <string> GetConflictIDs(AppEntry appEntry) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } #endregion var capability = appEntry.LookupCapability <Model.Capabilities.ContextMenu>(Capability); return(new[] { $@"context-menu-{capability.Target}:{(capability.Verbs.Count == 1 ? capability.Verbs.Single().Name : capability.ID)}" }); }
public void AccessPointCandidatesInternalConflict() { var accessPoints = new AccessPoint[] { new MockAccessPoint { ID = "a" }, new MockAccessPoint { ID = "a" } }; var appEntry = new AppEntry { Name = "App" }; Assert.Throws <ConflictException>(() => accessPoints.GetConflictData(appEntry)); }
public void AccessPointCandidates() { var accessPoints = new AccessPoint[] {new MockAccessPoint {ID = "a"}, new MockAccessPoint {ID = "b"}}; var appEntry = new AppEntry {Name = "App"}; CollectionAssert.AreEqual( expected: new[] { new KeyValuePair<string, ConflictData>("mock:a", new ConflictData(accessPoints[0], appEntry)), new KeyValuePair<string, ConflictData>("mock:b", new ConflictData(accessPoints[1], appEntry)) }, actual: accessPoints.GetConflictData(appEntry)); }
/// <inheritdoc/> protected override void AddAccessPointsInternal(AppEntry appEntry, Feed feed, IReadOnlyCollection <AccessPoint> accessPoints) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException(nameof(appEntry)); } if (feed == null) { throw new ArgumentNullException(nameof(feed)); } if (accessPoints == null) { throw new ArgumentNullException(nameof(accessPoints)); } if (appEntry.AccessPoints != null && ReferenceEquals(appEntry.AccessPoints.Entries, accessPoints)) { throw new ArgumentException("Must not be equal to appEntry.AccessPoints.Entries", nameof(accessPoints)); } #endregion // Skip entries with mismatching hostname if (appEntry.Hostname != null && !Regex.IsMatch(Environment.MachineName, appEntry.Hostname)) { return; } appEntry.AccessPoints ??= new(); AppList.CheckForConflicts(accessPoints, appEntry); var iconStore = IconStores.DesktopIntegration(Config, Handler, MachineWide); // Pre-cache splash screen for later use by GUI feed.SplashScreens.GetIcon(Icon.MimeTypePng)?.To(iconStore.GetFresh); accessPoints.ApplyWithRollback( accessPoint => accessPoint.Apply(appEntry, feed, iconStore, MachineWide), accessPoint => { // Don't perform rollback if the access point was already applied previously and this was only a refresh if (!appEntry.AccessPoints.Entries.Contains(accessPoint)) { accessPoint.Unapply(appEntry, MachineWide); } }); appEntry.AccessPoints.Entries.RemoveRange(accessPoints); // Replace pre-existing entries appEntry.AccessPoints.Entries.AddRange(accessPoints); appEntry.Timestamp = DateTime.UtcNow; }
/// <inheritdoc/> public override void Unapply(AppEntry appEntry, bool machineWide) { #region Sanity checks if (appEntry == null) { throw new ArgumentNullException("appEntry"); } #endregion if (WindowsUtils.IsWindows && !machineWide) { Windows.Shortcut.Remove(this); } }
//--------------------// #region Add /// <inheritdoc/> public void AddAccessPointCategories(AppEntry appEntry, Feed feed, params string[] categories) { #region Sanity checks if (appEntry == null) throw new ArgumentNullException(nameof(appEntry)); if (feed == null) throw new ArgumentNullException(nameof(feed)); if (categories == null) throw new ArgumentNullException(nameof(categories)); #endregion // Parse categories list bool capabilities = categories.Contains(CapabilityRegistration.CategoryName); bool menu = categories.Contains(MenuEntry.CategoryName); bool desktop = categories.Contains(DesktopIcon.CategoryName); bool sendTo = categories.Contains(SendTo.CategoryName); bool alias = categories.Contains(AppAlias.CategoryName); bool autoStart = categories.Contains(AutoStart.CategoryName); bool defaults = categories.Contains(DefaultAccessPoint.CategoryName); // Build capability list var accessPointsToAdd = new List<AccessPoint>(); if (capabilities) accessPointsToAdd.Add(new CapabilityRegistration()); if (menu) accessPointsToAdd.AddRange(Suggest.MenuEntries(feed)); if (desktop) accessPointsToAdd.AddRange(Suggest.DesktopIcons(feed)); if (sendTo) accessPointsToAdd.AddRange(Suggest.SendTo(feed)); if (alias) accessPointsToAdd.AddRange(Suggest.Aliases(feed)); if (autoStart) accessPointsToAdd.AddRange(Suggest.AutoStart(feed)); if (defaults) { // Add AccessPoints for all suitable Capabilities accessPointsToAdd.AddRange(( from capability in appEntry.CapabilityLists.CompatibleCapabilities().OfType<DefaultCapability>() where !capability.WindowsMachineWideOnly || MachineWide || !WindowsUtils.IsWindows where !capability.ExplicitOnly select capability.ToAcessPoint())); } try { AddAccessPointsInternal(appEntry, feed, accessPointsToAdd); if (menu && MachineWide) ToggleIconsVisible(appEntry, true); } catch (KeyNotFoundException ex) { // Wrap exception since only certain exception types are allowed throw new InvalidDataException(ex.Message, ex); } finally { Finish(); } }
public void Conflict() { var accessPointA = new MockAccessPoint {ID = "a"}; var appEntry1 = new AppEntry { Name = "App1", InterfaceUri = FeedTest.Test1Uri, AccessPoints = new AccessPointList {Entries = {accessPointA}} }; var appEntry2 = new AppEntry {Name = "App2", InterfaceUri = FeedTest.Test2Uri}; var appList = new AppList {Entries = {appEntry1}}; Assert.Throws<ConflictException>(() => appList.CheckForConflicts(new[] {accessPointA}, appEntry2)); }
public void Conflict() { var accessPointA = new MockAccessPoint {ID = "a"}; var appEntry1 = new AppEntry { Name = "App1", InterfaceUri = FeedTest.Test1Uri, AccessPoints = new AccessPointList {Entries = {accessPointA}} }; var appEntry2 = new AppEntry {Name = "App2", InterfaceUri = FeedTest.Test2Uri}; var appList = new AppList {Entries = {appEntry1}}; appList.Invoking(x => x.CheckForConflicts(new[] {accessPointA}, appEntry2)) .ShouldThrow<ConflictException>(); }
public void TestGetConflictIDs() { var capabilityRegistration = new CapabilityRegistration(); var appEntry = new AppEntry { CapabilityLists = { new CapabilityList {Entries = {new Store.Model.Capabilities.FileType {ID = "test1"}}}, new CapabilityList {Entries = {new Store.Model.Capabilities.FileType {ID = "test2"}}} } }; capabilityRegistration.GetConflictIDs(appEntry) .Should().Equal("progid:test1", "progid:test2"); }
public override bool RequestExecute(IRequestContext context) { object o = Mapper.QueryForObject(QueryID, context); IDictionary result = o as IDictionary; ICollection keys = result.Keys; foreach (string key in keys) { context[key] = result[key]; } AppEntry entry = new AppEntry(result); context[ID] = entry; return CONTINUE; }
public void TestGetConflictIDs() { var capabilityRegistration = new CapabilityRegistration(); var appEntry = new AppEntry { CapabilityLists = { new CapabilityList {Entries = {new Store.Model.Capabilities.FileType {ID = "test1"}}}, new CapabilityList {Entries = {new Store.Model.Capabilities.FileType {ID = "test2"}}} } }; CollectionAssert.AreEqual( expected: new[] {"progid:test1", "progid:test2"}, actual: capabilityRegistration.GetConflictIDs(appEntry)); }
/// <inheritdoc/> public void RemoveApp(AppEntry appEntry) { #region Sanity checks if (appEntry == null) throw new ArgumentNullException(nameof(appEntry)); #endregion try { RemoveAppInternal(appEntry); } catch (KeyNotFoundException ex) { // Wrap exception since only certain exception types are allowed throw new InvalidDataException(ex.Message, ex); } finally { Finish(); } }
internal static AppAlias GetAppAlias([NotNull] AppList appList, [NotNull] string aliasName, out AppEntry foundAppEntry) { #region Sanity checks if (appList == null) throw new ArgumentNullException(nameof(appList)); if (string.IsNullOrEmpty(aliasName)) throw new ArgumentNullException(nameof(aliasName)); #endregion var results = from entry in appList.Entries where entry.AccessPoints != null from alias in entry.AccessPoints.Entries.OfType<AppAlias>() where alias.Name == aliasName select new {entry, alias}; var result = results.FirstOrDefault(); if (result == null) { foundAppEntry = null; return null; } else { foundAppEntry = result.entry; return result.alias; } }
/// <inheritdoc/> protected override void UpdateAppInternal(AppEntry appEntry, Feed feed) { #region Sanity checks if (appEntry == null) throw new ArgumentNullException("appEntry"); if (feed == null) throw new ArgumentNullException("feed"); #endregion // Temporarily remove capability-based access points but remember them for later reapplication var toReapply = new List<AccessPoint>(); if (appEntry.AccessPoints != null) toReapply.AddRange(appEntry.AccessPoints.Entries.Where(accessPoint => accessPoint is DefaultAccessPoint || accessPoint is CapabilityRegistration)); RemoveAccessPointsInternal(appEntry, toReapply); // Update metadata and capabilities appEntry.Name = feed.Name; appEntry.CapabilityLists.Clear(); appEntry.CapabilityLists.AddRange(feed.CapabilityLists.CloneElements()); // Reapply removed access points dumping any that have become incompatible foreach (var accessPoint in toReapply) { try { AddAccessPointsInternal(appEntry, feed, new[] {accessPoint}); } #region Error handling catch (KeyNotFoundException) { Log.Warn(string.Format("Access point '{0}' no longer compatible with interface '{1}'.", accessPoint, appEntry.InterfaceUri)); } #endregion } WriteAppDir(appEntry); appEntry.Timestamp = DateTime.UtcNow; }
/// <inheritdoc/> protected override void RemoveAppInternal(AppEntry appEntry) { #region Sanity checks if (appEntry == null) throw new ArgumentNullException("appEntry"); #endregion DeleteAppDir(appEntry); if (appEntry.AccessPoints != null) { // Unapply any remaining access points foreach (var accessPoint in appEntry.AccessPoints.Entries) accessPoint.Unapply(appEntry, MachineWide); } AppList.Entries.Remove(appEntry); }
/// <inheritdoc/> protected override void AddAppInternal(AppEntry prototype, Converter<FeedUri, Feed> feedRetriever) { #region Sanity checks if (prototype == null) throw new ArgumentNullException("prototype"); if (feedRetriever == null) throw new ArgumentNullException("feedRetriever"); #endregion var appEntry = prototype.Clone(); AppList.Entries.Add(appEntry); WriteAppDir(appEntry); if (appEntry.AccessPoints != null) AddAccessPointsInternal(appEntry, feedRetriever(appEntry.InterfaceUri), appEntry.AccessPoints.Clone().Entries); }
/// <inheritdoc/> protected override void AddAccessPointsInternal(AppEntry appEntry, Feed feed, IEnumerable<AccessPoint> accessPoints) { #region Sanity checks if (appEntry == null) throw new ArgumentNullException("appEntry"); if (feed == null) throw new ArgumentNullException("feed"); if (accessPoints == null) throw new ArgumentNullException("accessPoints"); if (appEntry.AccessPoints != null && appEntry.AccessPoints.Entries == accessPoints) throw new ArgumentException("Must not be equal to appEntry.AccessPoints.Entries", "accessPoints"); #endregion // Skip entries with mismatching hostname if (appEntry.Hostname != null && !Regex.IsMatch(Environment.MachineName, appEntry.Hostname)) return; if (appEntry.AccessPoints == null) appEntry.AccessPoints = new AccessPointList(); AppList.CheckForConflicts(accessPoints, appEntry); accessPoints.ApplyWithRollback( accessPoint => accessPoint.Apply(appEntry, feed, Handler, MachineWide), accessPoint => { // Don't perform rollback if the access point was already applied previously and this was only a refresh if (!appEntry.AccessPoints.Entries.Contains(accessPoint)) accessPoint.Unapply(appEntry, MachineWide); }); appEntry.AccessPoints.Entries.RemoveRange(accessPoints); // Replace pre-existing entries appEntry.AccessPoints.Entries.AddRange(accessPoints); appEntry.Timestamp = DateTime.UtcNow; }
/// <summary> /// Tests the sync logic with pre-defined <see cref="AppList"/>s. /// local add: appEntry1, local remove: appEntry2, remote add: appEntry3, remote remove: appEntry4 /// </summary> /// <param name="resetMode">The <see cref="SyncResetMode"/> to pass to <see cref="SyncIntegrationManager.Sync"/>.</param> /// <param name="ap1Applied">The flag file used to indicate that <see cref="MockAccessPoint.Apply"/> was called for appEntry1.</param> /// <param name="ap1Unapplied">The flag file used to indicate that <see cref="MockAccessPoint.Unapply"/> was called for appEntry1.</param> /// <param name="ap2Applied">The flag file used to indicate that <see cref="MockAccessPoint.Apply"/> was called for appEntry2.</param> /// <param name="ap2Unapplied">The flag file used to indicate that <see cref="MockAccessPoint.Unapply"/> was called for appEntry2.</param> /// <param name="ap3Applied">The flag file used to indicate that <see cref="MockAccessPoint.Apply"/> was called for appEntry3.</param> /// <param name="ap3Unapplied">The flag file used to indicate that <see cref="MockAccessPoint.Unapply"/> was called for appEntry3.</param> /// <param name="ap4Applied">The flag file used to indicate that <see cref="MockAccessPoint.Apply"/> was called for appEntry4.</param> /// <param name="ap4Unapplied">The flag file used to indicate that <see cref="MockAccessPoint.Unapply"/> was called for appEntry4.</param> private void TestSync(SyncResetMode resetMode, TemporaryFlagFile ap1Applied, TemporaryFlagFile ap1Unapplied, TemporaryFlagFile ap2Applied, TemporaryFlagFile ap2Unapplied, TemporaryFlagFile ap3Applied, TemporaryFlagFile ap3Unapplied, TemporaryFlagFile ap4Applied, TemporaryFlagFile ap4Unapplied) { var appEntry1 = new AppEntry { InterfaceUri = FeedTest.Test1Uri, AccessPoints = new AccessPointList {Entries = {new MockAccessPoint {ApplyFlagPath = ap1Applied, UnapplyFlagPath = ap1Unapplied}}} }; var appEntry2 = new AppEntry { InterfaceUri = FeedTest.Test2Uri, AccessPoints = new AccessPointList {Entries = {new MockAccessPoint {ApplyFlagPath = ap2Applied, UnapplyFlagPath = ap2Unapplied}}} }; var appEntry3 = new AppEntry { InterfaceUri = FeedTest.Test3Uri, AccessPoints = new AccessPointList {Entries = {new MockAccessPoint {ApplyFlagPath = ap3Applied, UnapplyFlagPath = ap3Unapplied}}} }; var appEntry4 = new AppEntry { InterfaceUri = new FeedUri("http://0install.de/feeds/test/test4.xml"), AccessPoints = new AccessPointList {Entries = {new MockAccessPoint {ApplyFlagPath = ap4Applied, UnapplyFlagPath = ap4Unapplied}}} }; var appListLocal = new AppList {Entries = {appEntry1, appEntry4}}; var appListLast = new AppList {Entries = {appEntry2, appEntry4}}; var appListServer = new AppList {Entries = {appEntry2, appEntry3}}; TestSync(resetMode, appListLocal, appListLast, appListServer); }
private void btnAddAppFolder_Click(object sender, RoutedEventArgs e) { AppEntry sel = tvwApps.SelectedItem as AppEntry; IList list = sel == null ? CurrentApps : sel.IsFolder ? sel.Children : sel.ParentList; int idx = sel == null ? 0 : list.IndexOf(sel) + 1; AppEntry entry = new AppEntry(QTUtility.TextResourcesDic["Options_Page10_Apps"][14], new AppEntry[0]); list.Insert(idx, entry); if(sel != null && sel.IsFolder) sel.IsExpanded = true; tvwApps.Focus(); entry.IsSelected = true; entry.IsEditing = true; }
private void btnAddApp_Click(object sender, RoutedEventArgs e) { string path; using(OpenFileDialog ofd = new OpenFileDialog()) { if(System.Windows.Forms.DialogResult.OK != ofd.ShowDialog()) return; path = ofd.FileName; } AppEntry sel = tvwApps.SelectedItem as AppEntry; IList list = sel == null ? CurrentApps : sel.IsFolder ? sel.Children : sel.ParentList; int idx = sel == null ? 0 : list.IndexOf(sel) + 1; AppEntry entry = new AppEntry(System.IO.Path.GetFileName(path), path); list.Insert(idx, entry); if(sel != null && sel.IsFolder) sel.IsExpanded = true; tvwApps.Focus(); entry.IsSelected = true; }
public void AccessPointCandidatesInternalConflict() { var accessPoints = new AccessPoint[] {new MockAccessPoint {ID = "a"}, new MockAccessPoint {ID = "a"}}; var appEntry = new AppEntry {Name = "App"}; accessPoints.Invoking(x => x.GetConflictData(appEntry)).ShouldThrow<ConflictException>(); }
/// <summary> /// Toggles registry entries indicating whether icons for the application are currently visible. /// </summary> /// <param name="appEntry">The application being modified.</param> /// <param name="iconsVisible"><c>true</c> if the icons are currently visible, <c>false</c> if the icons are currently not visible.</param> /// <remarks>This is a special handler to support <see cref="Windows.DefaultProgram"/>.</remarks> private static void ToggleIconsVisible(AppEntry appEntry, bool iconsVisible) { #region Sanity checks if (appEntry == null) throw new ArgumentNullException(nameof(appEntry)); #endregion foreach (var defaultProgram in appEntry.CapabilityLists.CompatibleCapabilities().OfType<Store.Model.Capabilities.DefaultProgram>()) Windows.DefaultProgram.ToggleIconsVisible(defaultProgram, iconsVisible); }
/// <inheritdoc/> protected override AppEntry AddAppInternal(FeedTarget target) { // Prevent double entries if (AppList.ContainsEntry(target.Uri)) throw new InvalidOperationException(string.Format(Resources.AppAlreadyInList, target.Feed.Name)); // Get basic metadata and copy of capabilities from feed var appEntry = new AppEntry {InterfaceUri = target.Uri, Name = target.Feed.Name, Timestamp = DateTime.UtcNow}; appEntry.CapabilityLists.AddRange(target.Feed.CapabilityLists.CloneElements()); AppList.Entries.Add(appEntry); WriteAppDir(appEntry); return appEntry; }
/// <inheritdoc/> public void RemoveAccessPointCategories(AppEntry appEntry, params string[] categories) { #region Sanity checks if (appEntry == null) throw new ArgumentNullException(nameof(appEntry)); if (categories == null) throw new ArgumentNullException(nameof(categories)); #endregion if (appEntry.AccessPoints == null) return; // Parse categories list bool capabilities = categories.Contains(CapabilityRegistration.CategoryName); bool menu = categories.Contains(MenuEntry.CategoryName); bool desktop = categories.Contains(DesktopIcon.CategoryName); bool sendTo = categories.Contains(SendTo.CategoryName); bool alias = categories.Contains(AppAlias.CategoryName); bool autoStart = categories.Contains(AutoStart.CategoryName); bool defaults = categories.Contains(DefaultAccessPoint.CategoryName); // Build capability list var accessPointsToRemove = new List<AccessPoint>(); if (capabilities) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<CapabilityRegistration>()); if (menu) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<MenuEntry>()); if (desktop) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<DesktopIcon>()); if (sendTo) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<SendTo>()); if (alias) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<AppAlias>()); if (autoStart) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<AutoStart>()); if (defaults) accessPointsToRemove.AddRange(appEntry.AccessPoints.Entries.OfType<DefaultAccessPoint>()); try { RemoveAccessPointsInternal(appEntry, accessPointsToRemove); if (menu && MachineWide) ToggleIconsVisible(appEntry, false); } catch (KeyNotFoundException ex) { // Wrap exception since only certain exception types are allowed throw new InvalidDataException(ex.Message, ex); } finally { Finish(); } }
/// <inheritdoc/> protected override void RemoveAccessPointsInternal(AppEntry appEntry, IEnumerable<AccessPoint> accessPoints) { #region Sanity checks if (appEntry == null) throw new ArgumentNullException("appEntry"); if (accessPoints == null) throw new ArgumentNullException("accessPoints"); #endregion if (appEntry.AccessPoints == null) return; foreach (var accessPoint in accessPoints) accessPoint.Unapply(appEntry, MachineWide); // Remove the access points from the AppList appEntry.AccessPoints.Entries.RemoveRange(accessPoints); appEntry.Timestamp = DateTime.UtcNow; }
public void TestSearch() { var appA = new AppEntry {InterfaceUri = FeedTest.Test1Uri, Name = "AppA"}; var appB = new AppEntry {InterfaceUri = FeedTest.Test2Uri, Name = "AppB"}; var lib = new AppEntry {InterfaceUri = FeedTest.Test3Uri, Name = "Lib"}; var appList = new AppList {Entries = {appA, appB, lib}}; appList.Search("").Should().Equal(appA, appB, lib); appList.Search("App").Should().Equal(appA, appB); appList.Search("AppA").Should().Equal(appA); appList.Search("AppB").Should().Equal(appB); }
/// <inheritdoc/> protected override void RepairAppInternal(AppEntry appEntry, Feed feed) { #region Sanity checks if (appEntry == null) throw new ArgumentNullException("appEntry"); if (feed == null) throw new ArgumentNullException("feed"); #endregion var toReAdd = (appEntry.AccessPoints == null) ? Enumerable.Empty<AccessPoint>() : appEntry.AccessPoints.Entries.ToList(); AddAccessPointsInternal(appEntry, feed, toReAdd); WriteAppDir(appEntry); }
/// <summary> /// Applies the <see cref="_removeCategories"/> and <see cref="_addCategories"/> specified by the user. /// </summary> private void RemoveAndAdd(ICategoryIntegrationManager integrationManager, Feed feed, AppEntry appEntry) { if (_removeCategories.Any()) integrationManager.RemoveAccessPointCategories(appEntry, _removeCategories.ToArray()); if (_addCategories.Any()) integrationManager.AddAccessPointCategories(appEntry, feed, _addCategories.ToArray()); }
private static void WriteAppDir(AppEntry appEntry) { // TODO: Implement }
public void TestAddApp() { var capabilityList = CapabilityListTest.CreateTestCapabilityList(); var target = new FeedTarget(FeedTest.Test1Uri, new Feed {Name = "Test", CapabilityLists = {capabilityList}}); _integrationManager.AddApp(target); var expectedAppEntry = new AppEntry {InterfaceUri = FeedTest.Test1Uri, Name = target.Feed.Name, CapabilityLists = {capabilityList}}; CollectionAssert.AreEqual(new[] {expectedAppEntry}, _integrationManager.AppList.Entries); Assert.Throws<InvalidOperationException>(() => _integrationManager.AddApp(target), "Do not allow adding applications to AppList more than once."); }