Skip to content
Permalink
Browse files

Added the URI parser framework or #42

  • Loading branch information...
COM8 committed Sep 2, 2019
1 parent 1b80d77 commit 70574085dba98175c65349fd8d1c9037201cfb11
@@ -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
{
@@ -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--
@@ -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--
@@ -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--
@@ -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--
@@ -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
{
@@ -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!");
@@ -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
}
}
@@ -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
}
}
@@ -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);
}

/// <summary>
/// TODO: Not done yet.
/// </summary>
/// <param name="uri"></param>
/// <returns></returns>
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)--
@@ -339,7 +339,9 @@
<Compile Include="Classes\OmemoCommandHelper.cs" />
<Compile Include="Classes\Presence.cs" />
<Compile Include="Classes\PubSubCommandHelper.cs" />
<Compile Include="Classes\UriUtils.cs" />
<Compile Include="Classes\XmppUri\UriUtils.cs" />
<Compile Include="Classes\XmppUri\AbstractUriAction.cs" />
<Compile Include="Classes\XmppUri\SendMessageUriAction.cs" />
<Compile Include="Classes\Utils.cs" />
<Compile Include="Classes\XMPPClient.cs" />
<Compile Include="Classes\XMPPUser.cs" />

0 comments on commit 7057408

Please sign in to comment.
You can’t perform that action at this time.