Commit c25f69d6 authored by atraczyk's avatar atraczyk

contacts: add vcard implementation

Change-Id: Iba9a8b1c0084d16a8ef7fc2626349254bb49b84e
Tuleap: #790
parent 9e71a6bb
......@@ -24,7 +24,7 @@
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles.xaml"/>
<ResourceDictionary Source="ms-appx:///Styles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
......
......@@ -30,6 +30,7 @@ using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Interop;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::ViewManagement;
using namespace Windows::UI::Core;
using namespace RingClientUWP;
......@@ -65,7 +66,7 @@ App::OnLaunched(LaunchActivatedEventArgs^ e)
ApplicationView::GetForCurrentView()->TitleBar->ButtonForegroundColor = Colors::White;
}
void RingClientUWP::App::OnsummonWizard()
void App::OnsummonWizard()
{
rootFrame->Navigate(Windows::UI::Xaml::Interop::TypeName(Views::Wizard::typeid));
}
}
\ No newline at end of file
......@@ -23,6 +23,7 @@ using namespace Windows::UI::Xaml::Controls;
namespace RingClientUWP
{
ref class App sealed
{
protected:
......
......@@ -38,6 +38,8 @@ Contact::Contact(String^ name,
String^ GUID,
unsigned int unreadmessages)
{
vCard_ = ref new VCardUtils::VCard(this);
name_ = name;
ringID_ = ringID;
GUID_ = GUID;
......@@ -158,14 +160,15 @@ Contact::saveConversationToFile()
if (_mkdir(Utils::toString(localfolder->Path + "\\" + ".messages\\").c_str())) {
std::ofstream file(Utils::toString(messagesFile).c_str());
if (file.is_open())
{
if (file.is_open()) {
file << Utils::toString(StringifyConversation());
file.close();
}
}
}
VCardUtils::VCard^
Contact::getVCard()
{
return vCard_;
}
\ No newline at end of file
#pragma once
/**************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux *
* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
......@@ -17,6 +16,10 @@
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#pragma once
#include "VCardUtils.h"
using namespace Platform;
using namespace Windows::Data::Json;
using namespace Windows::UI::Xaml;
......@@ -25,7 +28,7 @@ using namespace Windows::UI::Xaml::Data;
/* strings required by Windows::Data::Json. Defined here on puprose */
String^ nameKey = "name";
String^ ringIDKey = "ringid";
String^ GUIDKey = "guid";
String^ GUIDKey = "id";
String^ unreadMessagesKey = "unreadmessages";
String^ contactKey = "contact";
String^ contactListKey = "contactlist";
......@@ -34,6 +37,7 @@ String^ accountIdAssociatedKey = "accountIdAssociated";
namespace RingClientUWP
{
ref class Conversation;
public ref class Contact sealed : public INotifyPropertyChanged
{
public:
......@@ -91,16 +95,20 @@ public:
}
property String^ _accountIdAssociated;
VCardUtils::VCard^ getVCard();
internal:
void saveConversationToFile();
String^ StringifyConversation();
void DestringifyConversation(String^ data);
void deleteConversationFile();
protected:
void NotifyPropertyChanged(String^ propertyName);
private:
VCardUtils::VCard^ vCard_;
Conversation^ conversation_;
Visibility notificationNewMessage_;
unsigned int unreadMessages_;
......
......@@ -28,7 +28,6 @@ using namespace Windows::Storage;
using namespace Windows::Storage::Streams;
using namespace Windows::UI::Core;
using namespace RingClientUWP;
using namespace ViewModel;
......@@ -66,7 +65,8 @@ ContactsViewModel::ContactsViewModel()
saveContactsToFile();
}
});
RingD::instance->incomingMessage += ref new RingClientUWP::IncomingMessage(this, &RingClientUWP::ViewModel::ContactsViewModel::OnincomingMessage);
RingD::instance->incomingMessage +=
ref new RingClientUWP::IncomingMessage(this, &RingClientUWP::ViewModel::ContactsViewModel::OnincomingMessage);
}
Contact^ // refacto : remove "byName"
......
......@@ -43,54 +43,43 @@ using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::ApplicationModel::Activation;
using namespace Windows::Graphics::Display;
using namespace Windows::System;
using namespace Utils;
LoadingPage::LoadingPage()
{
InitializeComponent();
Utils::fileExists(ApplicationData::Current->LocalFolder, ".config\\dring.yml")
.then([this](bool config_exists)
{
if (config_exists) {
Utils::fileExists(ApplicationData::Current->LocalFolder, "creation.token")
.then([this](bool token_exists)
std::string configFile = RingD::instance->getLocalFolder() + ".config\\dring.yml";
std::string tokenFile = RingD::instance->getLocalFolder() + "creation.token";
if (fileExists(configFile)) {
if (fileExists(tokenFile)) {
/* we have a token, the config has to be considered as corrupted, delete the config, summon the wizard */
fileDelete(configFile);
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal,
ref new Windows::UI::Core::DispatchedHandler([this]()
{
if (token_exists) {
/* we have a token, the config has to be considered as corrupted, summon the wizard */
Utils::fileExists(ApplicationData::Current->LocalFolder, ".config\\dring.yml")
.then([this](bool token_exists)
{
if (token_exists) {
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
task<StorageFile^>(storageFolder->GetFileAsync(".config\\dring.yml")).then([this](StorageFile^ folder)
{
folder->DeleteAsync();
});
}
});
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this]() {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(Wizard::typeid));
}));
}
else {
/* there is no token and we have a config.yml, summon the main page */
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this]() {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(MainPage::typeid));
}));
}
});
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(Wizard::typeid));
}));
}
else {
/* no config file, create the token and summon the wizard*/
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
storageFolder->CreateFileAsync("creation.token", CreationCollisionOption::ReplaceExisting);
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this] () {
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(Wizard::typeid));
/* there is no token and we have a config.yml, summon the main page */
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal,
ref new Windows::UI::Core::DispatchedHandler([this]()
{
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(MainPage::typeid));
}));
}
});
}
else {
/* no config file, create the token and summon the wizard*/
std::ofstream fs;
fs.open(tokenFile, std::ios::out);
fs.close();
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal,
ref new Windows::UI::Core::DispatchedHandler([this] ()
{
this->Frame->Navigate(Windows::UI::Xaml::Interop::TypeName(Wizard::typeid));
}));
}
}
......@@ -84,10 +84,10 @@ MainPage::MainPage()
visibilityChangedEventToken = Window::Current->VisibilityChanged +=
ref new WindowVisibilityChangedEventHandler(this, &MainPage::Application_VisibilityChanged);
applicationSuspendingEventToken = Application::Current->Suspending +=
/*applicationSuspendingEventToken = Application::Current->Suspending +=
ref new SuspendingEventHandler(this, &MainPage::Application_Suspending);
applicationResumingEventToken = Application::Current->Resuming +=
ref new EventHandler<Object^>(this, &MainPage::Application_Resuming);
ref new EventHandler<Object^>(this, &MainPage::Application_Resuming);*/
}
void
......@@ -237,13 +237,13 @@ void RingClientUWP::MainPage::OnsummonWelcomePage()
void RingClientUWP::MainPage::OnsummonPreviewPage()
{
WriteLine("Show Settings Preview");
MSG_("Show Settings Preview");
_previewFrame_->Visibility = VIS::Visible;
}
void RingClientUWP::MainPage::OnhidePreviewPage()
{
WriteLine("Hide Settings Preview");
MSG_("Hide Settings Preview");
_previewFrame_->Visibility = VIS::Collapsed;
}
......@@ -281,7 +281,7 @@ void RingClientUWP::MainPage::OnstateChange(Platform::String ^callId, RingClient
void
MainPage::Application_Suspending(Object^, Windows::ApplicationModel::SuspendingEventArgs^ e)
{
RingDebug::instance->WriteLine("Application_Suspending");
MSG_("Application_Suspending");
if (Frame->CurrentSourcePageType.Name ==
Interop::TypeName(MainPage::typeid).Name) {
auto deferral = e->SuspendingOperation->GetDeferral();
......@@ -291,17 +291,17 @@ MainPage::Application_Suspending(Object^, Windows::ApplicationModel::SuspendingE
previousTask.get();
}
catch (Exception^ e) {
RingDebug::instance->WriteLine("Exception: Extended Execution Begin");
MSG_("Exception: Extended Execution Begin");
}
})
.then([this, deferral](task<void> previousTask) {
try {
previousTask.get();
RingDebug::instance->WriteLine("deferral->Complete()");
MSG_("deferral->Complete()");
deferral->Complete();
}
catch (Exception^ e) {
RingDebug::instance->WriteLine("Exception: Extended Execution");
MSG_("Exception: Extended Execution");
deferral->Complete();
}
});
......@@ -313,7 +313,7 @@ MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventAr
{
auto vcm = Video::VideoManager::instance->captureManager();
if (e->Visible) {
RingDebug::instance->WriteLine("->Visible");
MSG_("->Visible");
bool isInCall = false;
for (auto item : SmartPanelItemsViewModel::instance->itemsList) {
if (item->_callId && item->_callStatus == CallStatus::IN_PROGRESS) {
......@@ -345,7 +345,7 @@ MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventAr
}
}
else {
RingDebug::instance->WriteLine("->Invisible");
MSG_("->Invisible");
bool isInCall = false;
for (auto item : SmartPanelItemsViewModel::instance->itemsList) {
if (item->_callId && item->_callStatus == CallStatus::IN_PROGRESS) {
......@@ -357,7 +357,7 @@ MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventAr
if (isInCall) {
// TODO
/*if (RingD::instance->currentCallId) {
WriteLine("Pausing call: " + RingD::instance->currentCallId);
MSG_("Pausing call: " + RingD::instance->currentCallId);
RingD::instance->pauseCall(RingD::instance->currentCallId);
}*/
if (vcm->isPreviewing) {
......@@ -375,7 +375,7 @@ MainPage::Application_VisibilityChanged(Object^ sender, VisibilityChangedEventAr
void MainPage::Application_Resuming(Object^, Object^)
{
RingDebug::instance->WriteLine("Application_Resuming");
MSG_("Application_Resuming");
}
void
......@@ -390,7 +390,7 @@ void
MainPage::ClearExtendedExecution()
{
if (session != nullptr) {
RingDebug::instance->WriteLine("End Extended Execution");
MSG_("End Extended Execution");
session->Revoked -= sessionRevokedToken;
}
}
......@@ -412,21 +412,21 @@ MainPage::BeginExtendedExecution()
{
case ExtendedExecutionResult::Allowed:
session = newSession;
RingDebug::instance->WriteLine("Request Extended Execution Allowed");
RingDebug::instance->WriteLine("Clean up camera...");
MSG_("Request Extended Execution Allowed");
MSG_("Clean up camera...");
Video::VideoManager::instance->captureManager()->CleanupCameraAsync();
RingDebug::instance->WriteLine("Hang up calls...");
MSG_("Hang up calls...");
RingD::instance->deinit();
break;
default:
case ExtendedExecutionResult::Denied:
RingDebug::instance->WriteLine("Request Extended Execution Denied");
MSG_("Request Extended Execution Denied");
break;
}
}
catch (Exception^ e) {
RingDebug::instance->WriteLine("Exception: Extended Execution Request");
EXC_(e);
}
});
}
......
......@@ -113,7 +113,6 @@ RingClientUWP::RingD::reloadAccountList()
}
sipPassword = ""; // avoid to keep password in memory
}
}
......@@ -186,6 +185,18 @@ void RingClientUWP::RingD::sendSIPTextMessage(String^ message)
contact->saveConversationToFile();
}
// send vcard
void RingClientUWP::RingD::sendSIPTextMessageVCF(std::string callID, std::map<std::string, std::string> message)
{
/* account id */
auto accountId = AccountListItemsViewModel::instance->_selectedItem->_account->accountID_;
std::wstring accountId2(accountId->Begin());
std::string accountId3(accountId2.begin(), accountId2.end());
/* daemon */
DRing::sendTextMessage(callID, message, accountId3, true /*not used*/);
}
void
RingD::createRINGAccount(String^ alias, String^ archivePassword, bool upnp, String^ registeredName)
{
......@@ -412,6 +423,16 @@ RingD::registerCallbacks()
auto state3 = translateCallStatus(state2);
if (state3 == CallStatus::OUTGOING_RINGING ||
state3 == CallStatus::INCOMING_RINGING) {
try {
Configuration::UserPreferences::instance->sendVCard(callId);
}
catch (Exception^ e) {
EXC_(e);
}
}
if (state3 == CallStatus::ENDED)
DRing::hangUp(callId); // solve a bug in the daemon API.
......@@ -455,16 +476,17 @@ RingD::registerCallbacks()
auto callId2 = toPlatformString(callId);
auto from2 = toPlatformString(from);
const std::string PROFILE_VCF = "x-ring/ring.profile.vcard";
static const unsigned int profileSize = PROFILE_VCF.size();
auto item = SmartPanelItemsViewModel::instance->findItem(callId2);
auto contact = item->_contact;
static const unsigned int profileSize = VCardUtils::PROFILE_VCF.size();
for (auto i : payloads) {
if (i.first.compare(0, profileSize, PROFILE_VCF) == 0) {
MSG_("VCARD");
if (i.first.compare(0, profileSize, VCardUtils::PROFILE_VCF) == 0) {
MSG_("payload.first = " + i.first);
MSG_("payload.second = " + i.second);
int res = contact->getVCard()->receiveChunk(i.first, i.second);
return;
}
MSG_("payload.first = " + i.first);
MSG_("payload.second = " + i.second);
auto payload = Utils::toPlatformString(i.second);
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
......@@ -510,7 +532,7 @@ RingD::registerCallbacks()
if (debugModeOn_)
dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
RingDebug::instance->print(toto);
DMSG_(toto);
}));
})
};
......@@ -633,7 +655,7 @@ RingD::registerCallbacks()
{
dispatcher->RunAsync(CoreDispatcherPriority::High,
ref new DispatchedHandler([=]() {
RingDebug::instance->print("KnownDevicesChanged ---> C PAS FINI");
MSG_("KnownDevicesChanged ---> C PAS FINI");
}));
}),
DRing::exportable_callback<DRing::ConfigurationSignal::ExportOnRingEnded>([&](const std::string& accountId, int status, const std::string& pin)
......@@ -718,22 +740,24 @@ RingD::startDaemon()
daemonRunning_ = DRing::start();
auto vcm = Video::VideoManager::instance->captureManager();
std::string deviceName = DRing::getDefaultDevice();
std::map<std::string, std::string> settings = DRing::getSettings(deviceName);
int rate = stoi(settings["rate"]);
std::string size = settings["size"];
std::string::size_type pos = size.find('x');
int width = std::stoi(size.substr(0, pos));
int height = std::stoi(size.substr(pos + 1, size.length()));
for (auto dev : vcm->deviceList) {
if (!Utils::toString(dev->name()).compare(deviceName))
vcm->activeDevice = dev;
if (vcm->deviceList->Size > 0) {
std::string deviceName = DRing::getDefaultDevice();
std::map<std::string, std::string> settings = DRing::getSettings(deviceName);
int rate = stoi(settings["rate"]);
std::string size = settings["size"];
std::string::size_type pos = size.find('x');
int width = std::stoi(size.substr(0, pos));
int height = std::stoi(size.substr(pos + 1, size.length()));
for (auto dev : vcm->deviceList) {
if (!Utils::toString(dev->name()).compare(deviceName))
vcm->activeDevice = dev;
}
vcm->activeDevice->SetDeviceProperties("", width, height, rate);
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
ref new DispatchedHandler([=]() {
finishCaptureDeviceEnumeration();
}));
}
vcm->activeDevice->SetDeviceProperties("", width, height, rate);
CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
ref new DispatchedHandler([=]() {
finishCaptureDeviceEnumeration();
}));
if (!daemonRunning_) {
ERR_("\ndaemon didn't start.\n");
......@@ -758,17 +782,10 @@ RingD::startDaemon()
}
/* at this point the config.yml is safe. */
Utils::fileExists(ApplicationData::Current->LocalFolder, "creation.token")
.then([this](bool token_exists)
{
if (token_exists) {
StorageFolder^ storageFolder = ApplicationData::Current->LocalFolder;
task<StorageFile^>(storageFolder->GetFileAsync("creation.token")).then([this](StorageFile^ file)
{
file->DeleteAsync();
});
}
});
std::string tokenFile = localFolder_ + "\\creation.token";
if (fileExists(tokenFile)) {
fileDelete(tokenFile);
}
while (daemonRunning) {
DRing::pollEvents();
......@@ -786,6 +803,12 @@ RingD::RingD()
currentCallId = nullptr;
}
std::string
RingD::getLocalFolder()
{
return localFolder_ + Utils::toString("\\");
}
void
RingD::dequeueTasks()
{
......
......@@ -91,6 +91,7 @@ internal: // why this property has to be internal and not public ?
internal:
/* functions */
std::string getLocalFolder();
void registerCallbacks();
void initDaemon(int flags);
void startDaemon();
......@@ -99,6 +100,7 @@ internal:
void reloadAccountList();
void sendAccountTextMessage(String^ message);
void sendSIPTextMessage(String^ message);
void sendSIPTextMessageVCF(std::string callID, std::map<std::string, std::string> message);
void createRINGAccount(String^ alias, String^ archivePassword, bool upnp, String^ registeredName = "");
void createSIPAccount(String^ alias, String^ sipPassword, String^ sipHostname, String^ sipusername);
void refuseIncommingCall(String^ call);
......
......@@ -20,59 +20,140 @@
/* client */
#include "pch.h"
#include "fileutils.h"
using namespace RingClientUWP;
using namespace Platform;
using namespace Windows::UI::Core;
using namespace Windows::Storage;
using namespace std::chrono;
std::string
getDebugHeader(std::string file, int line)
{
auto tid = std::this_thread::get_id();
seconds s = duration_cast< seconds >(
system_clock::now().time_since_epoch()
);
milliseconds ms = duration_cast< milliseconds >(
system_clock::now().time_since_epoch()
);
static uint64_t secs = s.count();
static uint64_t millis = ms.count() - (secs * 1000);
std::ostringstream out;
const auto prev_fill = out.fill();
out << '[' << secs
<< '.' << std::right << std::setw(3) << std::setfill('0') << millis << std::left
<< '|' << std::right << std::setw(5) << std::setfill(' ') << tid << std::left;
out.fill(prev_fill);
out << "|" << std::setw(32) << (file + ':' + Utils::toString((line.ToString())));
out << "] ";
return out.str();
}
void
RingDebug::print(const std::string& message,
const Type& type)
RingDebug::print(const std::string& message, const Type& type,
std::string file, int line)
{
/* get the current time */
std::time_t currentTime = std::time(nullptr);
char timeBuffer[64];
ctime_s(timeBuffer, sizeof timeBuffer, &currentTime);
std::string _message;
/* timestamp */
auto messageTimestamped = timeBuffer + message;
std::wstring wString = std::wstring(message.begin(), message.end());
if (type != Type::DMN)
_message = getDebugHeader(file, line) + message;
else
_message = message;
std::wstring wString = std::wstring(_message.begin(), _message.end());
/* set message type. */
switch (type) {
case Type::ERR:
wString = L"(EE) " + wString;
break;
case Type::WNG:
wString = L"(WW) " + wString;
break;
/*case Type::message:*/
}
wString = (type>Type::WNG)?(L"(EE) "):((type>Type::MSG)?(L"(WW) "):(L"")) + wString;
#if UWP_DBG_VS
/* screen it into VS debug console */
OutputDebugString((wString + L"\n").c_str());
#endif
#if UWP_DBG_CLIENT
/* fire the event. */
auto msg = ref new String(wString.c_str(), wString.length());
messageToScreen(msg);
#endif
#if UWP_DBG_FILE
/* output to file */
std::ofstream ofs;
ofs.open (RingD::instance->getLocalFolder() + "debug.log", std::ofstream::out | std::ofstream::app);
ofs << Utils::toString(msg) << "\n";
ofs.close();
#endif
}
void
RingDebug::print(String^ message, const Type& type,
std::string file, int line)
{
/* add header */
auto messageTimestamped = Utils::toPlatformString(getDebugHeader(file, line)) + message;
/* set message type. */
messageTimestamped = (type>Type::WNG)?("(EE) "):((type>Type::MSG)?("(WW) "):("")) + messageTimestamped;
#if UWP_DBG_VS
/* screen it into VS debug console */
std::wstringstream wStringstream;
wStringstream << messageTimestamped->Data() << "\n";
OutputDebugString(wStringstream.str().c_str());
#endif
#if UWP_DBG_CLIENT
/* fire the event. */
auto line = ref new String(wString.c_str(), wString.length());
messageToScreen(line);
messageToScreen(messageTimestamped);
#endif
#if UWP_DBG_FILE
/* output to file */
std::ofstream ofs;
ofs.open ("debug.log", std::ofstream::out | std::ofstream::app);
ofs << Utils::toString(line) << "\n";
ofs.open (RingD::instance->getLocalFolder() + "debug.log", std::ofstream::out | std::ofstream::app);
ofs << Utils::toString(messageTimestamped) << "\n";
ofs.close();
#endif
}
void RingClientUWP::RingDebug::WriteLine(String^ str)
void
RingDebug::print(Exception^ e, std::string file, int line)
{
/* screen in visual studio console */
/* add header */
auto message = Utils::toPlatformString(getDebugHeader(file, line)) + "0x" + e->HResult.ToString() + ": " + e->Message;
#if UWP_DBG_VS
/* screen it into VS debug console */
std::wstringstream wStringstream;
wStringstream << str->Data() << "\n";
wStringstream << message->Data() << "\n";
OutputDebugString(wStringstream.str().c_str());
#endif
#if UWP_DBG_CLIENT
/* fire the event. */
messageToScreen(message);
#endif
#if UWP_DBG_FILE
/* output to file */
std::ofstream ofs;
ofs.open (RingD::instance->getLocalFolder() + "debug.log", std::ofstream::out | std::ofstream::app);
ofs << Utils::toString(message) << "\n";
ofs.close();
#endif
}
RingClientUWP::RingDebug::RingDebug()
RingDebug::RingDebug()
{
/* clean the log file */
std::ofstream ofs;
ofs.open (RingD::instance->getLocalFolder() + "debug.log", std::ofstream::out | std::ofstream::trunc);
ofs.close();
}
......@@ -17,6 +17,10 @@
**************************************************************************/
#pragma once
#define UWP_DBG_CLIENT 0
#define UWP_DBG_VS 1
#define UWP_DBG_FILE 0
using namespace Windows::Storage;
namespace RingClientUWP
......@@ -46,10 +50,12 @@ public:
/* functions */
internal:
enum class Type { MSG, WNG, ERR };
void print(const std::string& message, const Type& type = Type::MSG);
void WriteLine(String^ str);
enum class Type { DMN, MSG, WNG, ERR };
void print(const std::string& message, const Type& type,
std::string file, int line);
void print(String^ message, const Type& type,
std::string file, int line);
void print(Exception^ e, std::string file, int line);
/* event */
event debugMessageToScreen^ messageToScreen;
......@@ -72,13 +78,19 @@ void WriteException(Exception^ ex)
OutputDebugString(wStringstream.str().c_str());
}
#define MSG_(cstr) CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, \
ref new DispatchedHandler([=]() { RingDebug::instance->print(cstr); }))
#define DMSG_(str) CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(CoreDispatcherPriority::High, \
ref new DispatchedHandler([=]() { RingDebug::instance->print(str, RingDebug::Type::DMN, __FILE__, __LINE__); }))
#define MSG_(str