diff --git a/Component_Tests/Classes/Misc/Test_UriUtils.cs b/Component_Tests/Classes/Misc/Test_UriUtils.cs index d05f54fd2..d97d11746 100644 --- a/Component_Tests/Classes/Misc/Test_UriUtils.cs +++ b/Component_Tests/Classes/Misc/Test_UriUtils.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using Windows.Foundation; -using XMPP_API.Classes; +using XMPP_API.Classes.XmppUri; namespace Component_Tests.Classes.Misc { diff --git a/Data_Manager2/Classes/Toast/ChatToastActivation.cs b/Data_Manager2/Classes/Toast/ChatToastActivation.cs index 993517083..7b603fd60 100644 --- a/Data_Manager2/Classes/Toast/ChatToastActivation.cs +++ b/Data_Manager2/Classes/Toast/ChatToastActivation.cs @@ -2,11 +2,11 @@ using System.Collections.Generic; using System.Linq; using Windows.Foundation; -using XMPP_API.Classes; +using XMPP_API.Classes.XmppUri; namespace Data_Manager2.Classes.Toast { - public class ChatToastActivation : AbstractToastActivation + public class ChatToastActivation: AbstractToastActivation { //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\ #region --Attributes-- diff --git a/Data_Manager2/Classes/Toast/MarkChatAsReadToastActivation.cs b/Data_Manager2/Classes/Toast/MarkChatAsReadToastActivation.cs index fd87115cc..f686b5dd9 100644 --- a/Data_Manager2/Classes/Toast/MarkChatAsReadToastActivation.cs +++ b/Data_Manager2/Classes/Toast/MarkChatAsReadToastActivation.cs @@ -2,11 +2,11 @@ using System.Collections.Generic; using System.Linq; using Windows.Foundation; -using XMPP_API.Classes; +using XMPP_API.Classes.XmppUri; namespace Data_Manager2.Classes.Toast { - public class MarkChatAsReadToastActivation : AbstractToastActivation + public class MarkChatAsReadToastActivation: AbstractToastActivation { //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\ #region --Attributes-- diff --git a/Data_Manager2/Classes/Toast/MarkMessageAsReadToastActivation.cs b/Data_Manager2/Classes/Toast/MarkMessageAsReadToastActivation.cs index 1f83a1261..35d881942 100644 --- a/Data_Manager2/Classes/Toast/MarkMessageAsReadToastActivation.cs +++ b/Data_Manager2/Classes/Toast/MarkMessageAsReadToastActivation.cs @@ -2,11 +2,11 @@ using System.Collections.Generic; using System.Linq; using Windows.Foundation; -using XMPP_API.Classes; +using XMPP_API.Classes.XmppUri; namespace Data_Manager2.Classes.Toast { - public class MarkMessageAsReadToastActivation : AbstractToastActivation + public class MarkMessageAsReadToastActivation: AbstractToastActivation { //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\ #region --Attributes-- diff --git a/Data_Manager2/Classes/Toast/SendReplyToastActivation.cs b/Data_Manager2/Classes/Toast/SendReplyToastActivation.cs index f0bc06ca5..eb1516290 100644 --- a/Data_Manager2/Classes/Toast/SendReplyToastActivation.cs +++ b/Data_Manager2/Classes/Toast/SendReplyToastActivation.cs @@ -2,11 +2,11 @@ using System.Collections.Generic; using System.Linq; using Windows.Foundation; -using XMPP_API.Classes; +using XMPP_API.Classes.XmppUri; namespace Data_Manager2.Classes.Toast { - public class SendReplyToastActivation : AbstractToastActivation + public class SendReplyToastActivation: AbstractToastActivation { //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\ #region --Attributes-- diff --git a/Data_Manager2/Classes/Toast/ToastActivationArgumentParser.cs b/Data_Manager2/Classes/Toast/ToastActivationArgumentParser.cs index a7da1ffce..e631441e2 100644 --- a/Data_Manager2/Classes/Toast/ToastActivationArgumentParser.cs +++ b/Data_Manager2/Classes/Toast/ToastActivationArgumentParser.cs @@ -1,8 +1,8 @@ -using Logging; -using System; +using System; using System.Linq; +using Logging; using Windows.Foundation; -using XMPP_API.Classes; +using XMPP_API.Classes.XmppUri; namespace Data_Manager2.Classes.Toast { diff --git a/UWPX_UI/Pages/ExtendedSplashScreenPage.xaml.cs b/UWPX_UI/Pages/ExtendedSplashScreenPage.xaml.cs index 6fec825d5..9e2b8601c 100644 --- a/UWPX_UI/Pages/ExtendedSplashScreenPage.xaml.cs +++ b/UWPX_UI/Pages/ExtendedSplashScreenPage.xaml.cs @@ -15,6 +15,7 @@ using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media.Imaging; using Windows.UI.Xaml.Navigation; +using XMPP_API.Classes.XmppUri; using BackgroundTaskHelper = UWPX_UI_Context.Classes.BackgroundTaskHelper; namespace UWPX_UI.Pages @@ -226,13 +227,13 @@ private void EvaluateActivationArgs() { Logger.Info("App activated by protocol activation with: " + protocolActivationArgs.Uri.ToString()); - // If we're currently not on a page, navigate to the main page - ROOT_FRAME.Navigate(typeof(ChatPage), protocolActivationArgs); // ToDo add arguments + // If we're currently not on a page, navigate to the main page: + ROOT_FRAME.Navigate(typeof(ChatPage), UriUtils.parse(protocolActivationArgs.Uri)); } else if (ACTIVATION_ARGS is ToastNotificationActivatedEventArgs toastActivationArgs) { Logger.Info("App activated by toast with: " + toastActivationArgs.Argument); - // If empty args, no specific action (just launch the app) + // If empty args, no specific action (just launch the app): if (string.IsNullOrEmpty(toastActivationArgs.Argument)) { Logger.Warn("Toast activation with no argument!"); diff --git a/XMPP_API/Classes/XmppUri/AbstractUriAction.cs b/XMPP_API/Classes/XmppUri/AbstractUriAction.cs new file mode 100644 index 000000000..78913119f --- /dev/null +++ b/XMPP_API/Classes/XmppUri/AbstractUriAction.cs @@ -0,0 +1,41 @@ +namespace XMPP_API.Classes.XmppUri +{ + public abstract class AbstractUriAction + { + //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\ + #region --Attributes-- + + + #endregion + //--------------------------------------------------------Constructor:----------------------------------------------------------------\\ + #region --Constructors-- + + + #endregion + //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\ + #region --Set-, Get- Methods-- + + + #endregion + //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\ + #region --Misc Methods (Public)-- + + + #endregion + + #region --Misc Methods (Private)-- + + + #endregion + + #region --Misc Methods (Protected)-- + + + #endregion + //--------------------------------------------------------Events:---------------------------------------------------------------------\\ + #region --Events-- + + + #endregion + } +} diff --git a/XMPP_API/Classes/XmppUri/SendMessageUriAction.cs b/XMPP_API/Classes/XmppUri/SendMessageUriAction.cs new file mode 100644 index 000000000..71602ba1b --- /dev/null +++ b/XMPP_API/Classes/XmppUri/SendMessageUriAction.cs @@ -0,0 +1,41 @@ +namespace XMPP_API.Classes.XmppUri +{ + public class SendMessageUriAction: AbstractUriAction + { + //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\ + #region --Attributes-- + + + #endregion + //--------------------------------------------------------Constructor:----------------------------------------------------------------\\ + #region --Constructors-- + + + #endregion + //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\ + #region --Set-, Get- Methods-- + + + #endregion + //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\ + #region --Misc Methods (Public)-- + + + #endregion + + #region --Misc Methods (Private)-- + + + #endregion + + #region --Misc Methods (Protected)-- + + + #endregion + //--------------------------------------------------------Events:---------------------------------------------------------------------\\ + #region --Events-- + + + #endregion + } +} diff --git a/XMPP_API/Classes/UriUtils.cs b/XMPP_API/Classes/XmppUri/UriUtils.cs similarity index 71% rename from XMPP_API/Classes/UriUtils.cs rename to XMPP_API/Classes/XmppUri/UriUtils.cs index 7fa44e3a1..ad74ec913 100644 --- a/XMPP_API/Classes/UriUtils.cs +++ b/XMPP_API/Classes/XmppUri/UriUtils.cs @@ -3,9 +3,10 @@ using System.Linq; using System.Net; using System.Text; +using Logging; using Windows.Foundation; -namespace XMPP_API.Classes +namespace XMPP_API.Classes.XmppUri { public static class UriUtils { @@ -85,6 +86,54 @@ public static WwwFormUrlDecoder parseUriQuery(Uri uri) return new WwwFormUrlDecoder(uri.Query); } + /// + /// TODO: Not done yet. + /// + /// + /// + public static AbstractUriAction parse(Uri uri) + { + if (!string.IsNullOrEmpty(uri?.OriginalString)) + { + string tmp = uri.OriginalString; + + // 1. 'xmpp:' + if (tmp.StartsWith("xmpp:")) + { + tmp = tmp.Substring(5); + + // 2. Authority + string authority = null; + if (tmp.StartsWith("//")) + { + tmp.Substring(2); + int authEnd = tmp.IndexOf('/'); + if (authEnd < 0) + { + authEnd = tmp.IndexOf('?'); + if (authEnd < 0) + { + authEnd = tmp.IndexOf('#'); + if (authEnd < 0) + { + authEnd = tmp.Length <= 0 ? 0 : tmp.Length - 1; + } + } + authority = tmp.Substring(0, authEnd); + tmp = tmp.Substring(authEnd + 1); + } + } + + // 3. + } + else + { + Logger.Warn("Unable to parse XMPP URI - 'xmpp:' missing."); + } + } + return null; + } + #endregion #region --Misc Methods (Private)-- diff --git a/XMPP_API/XMPP_API.csproj b/XMPP_API/XMPP_API.csproj index 62ea9b998..cfcdc0299 100644 --- a/XMPP_API/XMPP_API.csproj +++ b/XMPP_API/XMPP_API.csproj @@ -339,7 +339,9 @@ - + + +