Skip to content

Commit b26b5ba

Browse files
committed
protocol
1 parent 2ed9efb commit b26b5ba

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

src/Client/Client.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010

1111
#include "Command/CommandManager.hpp"
1212

13+
#include <winrt/Windows.UI.Core.h>
14+
#include <winrt/Windows.Foundation.h>
15+
#include <winrt/Windows.ApplicationModel.Core.h>
16+
#include <winrt/Windows.ApplicationModel.Activation.h>
17+
#include <winrt/Windows.Foundation.Collections.h>
18+
19+
using namespace winrt::Windows::UI::Core;
20+
using namespace winrt::Windows::Foundation;
21+
using namespace winrt::Windows::ApplicationModel::Activation;
22+
using namespace winrt::Windows::ApplicationModel::Core;
23+
1324
Settings Client::settings = Settings();
1425

1526
bool notifiedOfConnectionIssue = false;
@@ -131,6 +142,25 @@ void Client::initialize() {
131142

132143
FlarialGUI::LoadFont(IDR_MINECRAFTIA_TTF);
133144

145+
CoreApplication::MainView().Activated([](const auto &, const IActivatedEventArgs &context) {
146+
if (context.Kind() != ActivationKind::Protocol)
147+
return;
148+
149+
auto uri = winrt::unbox_value<ProtocolActivatedEventArgs>(context).Uri();
150+
151+
std::vector<std::pair<std::wstring, std::wstring>> dataList;
152+
153+
for (const auto& dataContext : uri.QueryParsed()) {
154+
std::wstring name = dataContext.Name().c_str();
155+
std::wstring value = dataContext.Value().c_str();
156+
157+
dataList.emplace_back(name, value);
158+
}
159+
160+
161+
auto event = nes::make_holder<ProtocolEvent>(uri.Host().c_str(), dataList);
162+
eventMgr.trigger(event);
163+
});
134164
HookManager::initialize();
135165
ModuleManager::initialize();
136166
CommandManager::initialize();

src/Client/Events/Events.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@
3535
#include "Render/RenderOrderExecuteEvent.hpp"
3636
#include "Render/HandleVisibilityUpdatesEvent.hpp"
3737
#include "Render/UIControlGetPositionEvent.hpp"
38+
#include "Misc/ProtocolEvent.hpp"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
#pragma once
3+
4+
#include <vector>
5+
#include "../Event.hpp"
6+
#include "../Cancellable.hpp"
7+
8+
class ProtocolEvent : public Event {
9+
10+
std::vector<std::pair<std::wstring, std::wstring>> args;
11+
std::wstring path;
12+
13+
public:
14+
std::vector<std::pair<std::wstring, std::wstring>> getProtocolArgs() {
15+
return this->args;
16+
}
17+
std::wstring getPath() { return this->path; }
18+
19+
explicit ProtocolEvent(std::wstring path, std::vector<std::pair<std::wstring, std::wstring>> a) {
20+
this->args = a;
21+
this->path = path;
22+
}
23+
};

0 commit comments

Comments
 (0)