From 702ee1f467e0801964bd6f8337d863e6a1eda10e Mon Sep 17 00:00:00 2001 From: atraczyk <andreastraczyk@gmail.com> Date: Wed, 17 Aug 2016 09:50:52 -0400 Subject: [PATCH] Add basic functionality for UWP - adds debug output signal for UWP - allows UWP app path to passed in during initialization Change-Id: I7cff8c14a2e710a0784ba9eec5d0237328369e8d --- src/client/ring_signal.cpp | 4 ++++ src/dring/callmanager_interface.h | 10 ++++++++++ src/dring/dring.h | 3 ++- src/logger.cpp | 6 ++++++ src/logger.h | 4 ++++ src/ring_api.cpp | 5 ++++- 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/client/ring_signal.cpp b/src/client/ring_signal.cpp index d8f91e9dce..9a0d75dcbf 100644 --- a/src/client/ring_signal.cpp +++ b/src/client/ring_signal.cpp @@ -26,6 +26,10 @@ SignalHandlerMap& getSignalHandlers() { static SignalHandlerMap handlers = { +#ifdef WIN32_NATIVE + /* UWP Debug */ + exported_callback<DRing::Debug::MessageSend>(), +#endif /* Call */ exported_callback<DRing::CallSignal::StateChange>(), exported_callback<DRing::CallSignal::TransferFailed>(), diff --git a/src/dring/callmanager_interface.h b/src/dring/callmanager_interface.h index a1c1cba907..7a2830d3c9 100644 --- a/src/dring/callmanager_interface.h +++ b/src/dring/callmanager_interface.h @@ -94,6 +94,16 @@ void acceptEnrollment(const std::string& callID, bool accepted); /* Instant messaging */ void sendTextMessage(const std::string& callID, const std::map<std::string, std::string>& messages, const std::string& from, bool isMixed); +#ifdef WIN32_NATIVE +/* Debug for UWP Client */ +struct Debug { + struct MessageSend { + constexpr static const char* name = "MessageSend"; + using cb_type = void(const std::string&); + }; +}; +#endif + // Call signal type definitions struct CallSignal { struct StateChange { diff --git a/src/dring/dring.h b/src/dring/dring.h index ff8b8fa550..f70ae30bcc 100644 --- a/src/dring/dring.h +++ b/src/dring/dring.h @@ -46,9 +46,10 @@ const char* version() noexcept; * Initialize globals, create underlaying daemon. * * @param flags Flags to customize this initialization + * @param app_path Universal Windows Platform Application path * @returns true if initialization succeed else false. */ -bool init(enum InitFlag flags) noexcept; +bool init(enum InitFlag flags, const char* app_path = "") noexcept; /** * Start asynchronously daemon created by init(). diff --git a/src/logger.cpp b/src/logger.cpp index c7a2094ac9..222ee91374 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -49,6 +49,7 @@ #if defined _WIN32 || defined WIN32_NATIVE #include "winsyslog.h" +#include "client\ring_signal.h" #endif #define BLACK "\033[22;30m" @@ -205,6 +206,11 @@ vlogger(const int level, const char *format, va_list ap) std::string ctx(format, sep - format); format = sep + 2; fputs(getHeader(ctx.c_str()).c_str(), stderr); +#ifdef WIN32_NATIVE + char tmp[2048]; + vsprintf(tmp, format, ap); + ring::emitSignal<DRing::Debug::MessageSend>(getHeader(ctx.c_str()).c_str() + std::string(tmp)); +#endif #ifndef _WIN32 fputs(END_COLOR, stderr); #else diff --git a/src/logger.h b/src/logger.h index ab36b2c844..f3604df853 100644 --- a/src/logger.h +++ b/src/logger.h @@ -72,7 +72,11 @@ void strErr(); #define XSTR(X) STR(X) // Line return char in a string +#ifdef WIN32_NATIVE +#define ENDL " " +#else #define ENDL "\n" +#endif // Do not remove the "| " in following without modifying vlogger() code #ifndef WIN32_NATIVE diff --git a/src/ring_api.cpp b/src/ring_api.cpp index 9e5524a9d2..ca278fc39b 100644 --- a/src/ring_api.cpp +++ b/src/ring_api.cpp @@ -42,7 +42,7 @@ namespace DRing { bool -init(enum InitFlag flags) noexcept +init(enum InitFlag flags, const char* app_path) noexcept { ::setDebugMode(flags & DRING_FLAG_DEBUG); ::setConsoleLog(flags & DRING_FLAG_CONSOLE_LOG); @@ -55,6 +55,9 @@ init(enum InitFlag flags) noexcept try { // current implementation use static variable auto& manager = ring::Manager::instance(); +#ifdef WIN32_NATIVE + manager.setUWPAppPath(app_path); +#endif manager.setAutoAnswer(flags & DRING_FLAG_AUTOANSWER); return true; } catch (...) { -- GitLab