Beispiel #1
0
 public void RaiseToastActivated(ToastActivationData toastActivationData)
 {
     OnToastActivated.InvokeRemote(
         nameof(OnToastActivated),
         toastActivationData,
         h => OnToastActivated -= h
         );
 }
Beispiel #2
0
        private void OnToastActivated(ToastActivationData activationData)
        {
            if (activationData.WasTriggeredByThisPlugin() == false)
            {
                return;
            }

            if (!ValidateToS())
            {
                return;
            }

            var action = activationData.Arguments.SafeGet("action");

            switch (action)
            {
            case "importFeeds_view":
                Application.Current.Dispatcher.Invoke(
                    () => new FeedsImportWindow(_feedsData, true).ShowAndActivate()
                    );
                break;
            }
        }
Beispiel #3
0
        /// <inheritdoc />
        public override void OnActivated(string arguments, NotificationUserInput userInput, string appUserModelId)
        {
            Application.Current.Dispatcher.Invoke(delegate
            {
                if (arguments.Length == 0)
                {
                    return;
                }

                var args = QueryString.Parse(arguments);

                if (args.Contains(NotificationManager.PluginSessionGuidArgName))
                {
                    var pluginSessionGuidStr = args[NotificationManager.PluginSessionGuidArgName];

                    if (Guid.TryParse(pluginSessionGuidStr, out var pluginSessionGuid) == false)
                    {
                        LogTo.Error("A notification was activated for an invalid GUID.\r\nGUID: {Guid}\r\nArgs: {Args}", pluginSessionGuidStr, args);
                        return;
                    }

                    var plugin = SMAPluginManager.Instance[pluginSessionGuid];

                    if (plugin == null)
                    {
                        LogTo.Debug("A notification was activated for an expired plugin.\r\n{Args}", args);
                        return;
                    }

                    LogTo.Debug("Plugin Toast activated.\r\nArgs: {Args}", args);

                    var argDict       = args.ToDictionary(k => k.Name, v => v.Value);
                    var userInputDict = userInput.ToDictionary(k => k.Key, v => v.Value);

                    var activationData = new ToastActivationData(
                        plugin.Package.Id,
                        plugin.Package.Version,
                        argDict,
                        userInputDict);

                    SMA.Core.NotificationMgr.RaiseToastActivated(activationData);

                    return;
                }

                if (args.Contains("action") == false)
                {
                    LogTo.Warning("Received a Toast activation without an action argument: '{Args}'", args);
                    return;
                }

                LogTo.Debug("SMA Toast activated.\r\nArgs: {Args}", args);

                switch (args["action"])
                {
                // Restart plugin after crash
                case SMAPluginManager.ToastActionRestartAfterCrash:
                    if (args.Contains(SMAPluginManager.ToastActionParameterPluginId) == false)
                    {
                        LogTo.Warning("Received a ToastActionRestartAfterCrash toast activation without a plugin id parameter: '{Arguments}'",
                                      arguments);
                        return;
                    }

                    var packageId = args[SMAPluginManager.ToastActionParameterPluginId];
                    SMAPluginManager.Instance.StartPluginAsync(packageId).RunAsync();
                    break;

                default:
                    LogTo.Warning("Unknown notification action {V}: '{Arguments}'", args["action"], arguments);
                    break;
                }
            });