Beispiel #1
0
        /// <inheritdoc/>
        protected override ExitCode ExecuteHelper(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri)
        {
            #region Sanity checks
            if (integrationManager == null)
            {
                throw new ArgumentNullException("integrationManager");
            }
            if (interfaceUri == null)
            {
                throw new ArgumentNullException("interfaceUri");
            }
            #endregion

            try
            {
                CreateAppEntry(integrationManager, ref interfaceUri);
                return(ExitCode.OK);
            }
            #region Error handling
            catch (WebException)
            {
                // WebException is a subclass of InvalidOperationException but we don't want to catch it here
                throw;
            }
            catch (InvalidOperationException ex)
            { // Application already in AppList
                Handler.OutputLow(Resources.DesktopIntegration, ex.Message);
                return(ExitCode.NoChanges);
            }
            #endregion
        }
Beispiel #2
0
        /// <inheritdoc/>
        protected override ExitCode ExecuteHelper(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri)
        {
            #region Sanity checks
            if (interfaceUri == null)
            {
                throw new ArgumentNullException("interfaceUri");
            }
            if (integrationManager == null)
            {
                throw new ArgumentNullException("integrationManager");
            }
            #endregion

            try
            {
                integrationManager.RemoveApp(integrationManager.AppList[interfaceUri]);
            }
            #region Sanity checks
            catch (KeyNotFoundException ex)
            {
                // Wrap exception since only certain exception types are allowed
                throw new IOException(ex.Message, ex);
            }
            #endregion

            return(ExitCode.OK);
        }
Beispiel #3
0
        /// <inheritdoc/>
        protected override ExitCode ExecuteHelper(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri)
        {
            #region Sanity checks
            if (interfaceUri == null)
            {
                throw new ArgumentNullException(nameof(interfaceUri));
            }
            if (integrationManager == null)
            {
                throw new ArgumentNullException(nameof(integrationManager));
            }
            #endregion

            if (RemoveOnly())
            {
                RemoveOnly(integrationManager, interfaceUri);
                return(ExitCode.OK);
            }

            CheckInstallBase();

            var appEntry = GetAppEntry(integrationManager, ref interfaceUri);
            var feed     = FeedManager[interfaceUri];

            if (NoSpecifiedIntegrations())
            {
                var state = new IntegrationState(integrationManager, appEntry, feed);
Retry:
                Handler.ShowIntegrateApp(state);
                try
                {
                    state.ApplyChanges();
                }
                #region Error handling
                catch (ConflictException ex)
                {
                    if (Handler.Ask(
                            Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry,
                            defaultAnswer: false, alternateMessage: ex.Message))
                    {
                        goto Retry;
                    }
                }
                catch (InvalidDataException ex)
                {
                    if (Handler.Ask(
                            Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry,
                            defaultAnswer: false, alternateMessage: ex.Message))
                    {
                        goto Retry;
                    }
                }
                #endregion

                return(ExitCode.OK);
            }

            RemoveAndAdd(integrationManager, feed, appEntry);
            return(ExitCode.OK);
        }
Beispiel #4
0
        /// <inheritdoc/>
        protected override ExitCode ExecuteHelper(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri)
        {
            #region Sanity checks
            if (integrationManager == null) throw new ArgumentNullException("integrationManager");
            if (interfaceUri == null) throw new ArgumentNullException("interfaceUri");
            #endregion

            try
            {
                var entry = CreateAppEntry(integrationManager, ref interfaceUri);

                if (!CatalogManager.GetCachedSafe().ContainsFeed(entry.InterfaceUri))
                    WindowsUtils.BroadcastMessage(AddedNonCatalogAppWindowMessageID); // Notify Zero Install GUIs of changes

                return ExitCode.OK;
            }
                #region Error handling
            catch (WebException)
            {
                // WebException is a subclass of InvalidOperationException but we don't want to catch it here
                throw;
            }
            catch (InvalidOperationException ex)
            { // Application already in AppList
                Handler.OutputLow(Resources.DesktopIntegration, ex.Message);
                return ExitCode.NoChanges;
            }
            #endregion
        }
Beispiel #5
0
        /// <inheritdoc/>
        protected override ExitCode ExecuteHelper(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri)
        {
            #region Sanity checks
            if (integrationManager == null)
            {
                throw new ArgumentNullException(nameof(integrationManager));
            }
            if (interfaceUri == null)
            {
                throw new ArgumentNullException(nameof(interfaceUri));
            }
            #endregion

            try
            {
                var entry = CreateAppEntry(integrationManager, ref interfaceUri);

                if (!CatalogManager.GetCachedSafe().ContainsFeed(entry.InterfaceUri))
                {
                    WindowsUtils.BroadcastMessage(AddedNonCatalogAppWindowMessageID); // Notify Zero Install GUIs of changes
                }
                return(ExitCode.OK);
            }
            #region Error handling
            catch (InvalidOperationException ex)
                // WebException is a subclass of InvalidOperationException but we don't want to catch it here
                when(!(ex is WebException))
                { // Application already in AppList
                    Handler.OutputLow(Resources.DesktopIntegration, ex.Message);
                    return(ExitCode.NoChanges);
                }
            #endregion
        }
Beispiel #6
0
        /// <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());
            }
        }
Beispiel #7
0
        /// <inheritdoc/>
        protected override ExitCode ExecuteHelper(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri)
        {
            #region Sanity checks
            if (interfaceUri == null) throw new ArgumentNullException("interfaceUri");
            if (integrationManager == null) throw new ArgumentNullException("integrationManager");
            #endregion

            try
            {
                integrationManager.RemoveApp(integrationManager.AppList[interfaceUri]);
            }
                #region Sanity checks
            catch (KeyNotFoundException ex)
            {
                // Wrap exception since only certain exception types are allowed
                throw new IOException(ex.Message, ex);
            }
            #endregion

            return ExitCode.OK;
        }
Beispiel #8
0
        /// <inheritdoc/>
        protected override ExitCode ExecuteHelper(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri)
        {
            #region Sanity checks
            if (interfaceUri == null) throw new ArgumentNullException(nameof(interfaceUri));
            if (integrationManager == null) throw new ArgumentNullException(nameof(integrationManager));
            #endregion

            if (RemoveOnly())
            {
                RemoveOnly(integrationManager, interfaceUri);
                return ExitCode.OK;
            }

            CheckInstallBase();

            var appEntry = GetAppEntry(integrationManager, ref interfaceUri);
            var feed = FeedManager[interfaceUri];

            if (NoSpecifiedIntegrations())
            {
                var state = new IntegrationState(integrationManager, appEntry, feed);
                Retry:
                Handler.ShowIntegrateApp(state);
                try
                {
                    state.ApplyChanges();
                }
                    #region Error handling
                catch (ConflictException ex)
                {
                    if (Handler.Ask(
                        Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry,
                        defaultAnswer: false, alternateMessage: ex.Message))
                        goto Retry;
                }
                catch (InvalidDataException ex)
                {
                    if (Handler.Ask(
                        Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry,
                        defaultAnswer: false, alternateMessage: ex.Message))
                        goto Retry;
                }
                #endregion

                return ExitCode.OK;
            }

            RemoveAndAdd(integrationManager, feed, appEntry);
            return ExitCode.OK;
        }
Beispiel #9
0
        /// <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());
        }
Beispiel #10
0
 /// <summary>
 /// Applies the <see cref="_removeCategories"/> specified by the user.
 /// </summary>
 private void RemoveOnly(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri)
 {
     integrationManager.RemoveAccessPointCategories(integrationManager.AppList[interfaceUri], _removeCategories.ToArray());
 }
Beispiel #11
0
 /// <summary>
 /// Template method that performs the actual operation.
 /// </summary>
 /// <param name="integrationManager">Manages desktop integration operations.</param>
 /// <param name="interfaceUri">The interface for the application to perform the operation on.</param>
 /// <returns>The exit status code to end the process with.</returns>
 protected abstract ExitCode ExecuteHelper([NotNull] ICategoryIntegrationManager integrationManager, [NotNull] FeedUri interfaceUri);
Beispiel #12
0
 /// <summary>
 /// Applies the <see cref="_removeCategories"/> specified by the user.
 /// </summary>
 private void RemoveOnly(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri)
 {
     integrationManager.RemoveAccessPointCategories(integrationManager.AppList[interfaceUri], _removeCategories.ToArray());
 }