Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide WinRT - Part II #290

Merged
merged 12 commits into from
Sep 20, 2023
27 changes: 18 additions & 9 deletions msix/storeapi/StoreApi.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#include "StoreApi.hpp"

#include <combaseapi.h>
#include <string.h>
#include <winrt/base.h>

#include <agent/ServerStoreService.hpp>
#include <base/Exception.hpp>
#include <string>
#include <exception>

#include "framework.hpp"

EduardGomezEscandell marked this conversation as resolved.
Show resolved Hide resolved
#ifndef DNDEBUG
#include <format>
#include <iostream>
#endif

#include "StoreApi.hpp"
#include "framework.hpp"

// Syntactic sugar to convert the enum [value] into a Int.
constexpr Int toInt(StoreApi::ErrorCode value) {
return static_cast<Int>(value);
Expand All @@ -24,9 +34,9 @@ static constexpr std::size_t MaxProductIdLen = 129;
StoreApi::ErrorCode validateArg(const char* input, std::size_t maxLength);

void logError(std::string_view functionName, std::string_view errMsg) {
#ifndef DNDEBUG
std::cerr << std::format("storeapi: {}: {}\n", functionName , errMsg);
#endif
#ifndef DNDEBUG
std::cerr << std::format("storeapi: {}: {}\n", functionName, errMsg);
#endif
}

#define LOG_ERROR(msg) \
Expand Down Expand Up @@ -75,10 +85,9 @@ Int GenerateUserJWT(const char* accessToken, char** userJWT,
}

try {
auto user = StoreApi::UserInfo::Current().get();

StoreApi::ServerStoreService service{};
const std::string jwt = service.GenerateUserJwt(accessToken, user).get();
auto user = service.CurrentUserInfo();
const std::string jwt = service.GenerateUserJwt(accessToken, user);

// Allocates memory using some OS API so we can free this buffer on the
// other side of the ABI without assumptions on specifics of the programming
Expand Down
2 changes: 0 additions & 2 deletions msix/storeapi/StoreApi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// the ABI. Zero or positive values have no special meaning other than success.
#pragma once

#include <agent/ServerStoreService.hpp>
#include <cstdint>

extern "C" {
Expand Down Expand Up @@ -37,5 +36,4 @@ DLL_EXPORT Int GetSubscriptionExpirationDate(const char* productID,
DLL_EXPORT Int GenerateUserJWT(const char* accessToken,
// output
char** userJWT, std::uint64_t* userJWTLen);

}