Utils.h 3.43 KB
Newer Older
1 2
#pragma once

3
#include <string>
Sylvain Berfini's avatar
Sylvain Berfini committed
4
#include <inspectable.h>
5 6 7 8 9 10 11

namespace Linphone
{
    namespace Core
    {
		class Utils
		{
12
		public:
13 14 15 16
			/// <summary>
			/// Converts a Platform::String into a C char*.
			/// Required to send strings from C# to C.
			/// </summary>
17 18
			static const char* pstoccs(Platform::String^ ps);

19 20 21 22
			/// <summary>
			/// Converts a C char* to a Platform::String.
			/// Required to send strings from C to C#.
			/// </summary>
Sylvain Berfini's avatar
Sylvain Berfini committed
23 24
			static Platform::String^ Linphone::Core::Utils::cctops(const char*);

25 26 27 28
			/// <summary>
			/// Define a log handler.
			/// <param name="logfunc">The function pointer of the log handler.</param>
			/// </summary>
29
			static void LinphoneCoreSetLogHandler(void* logfunc);
30 31 32 33 34 35 36 37 38

			/// <summary>
			/// Define the log level.
			/// The loglevel parameter is a bitmask parameter. Therefore to enable only warning and error
			/// messages, use ORTP_WARNING | ORTP_ERROR. To disable logs, simply set loglevel to 0.
			/// <param name="loglevel">A bitmask of the log levels to set.</param>
			/// </summary>
			static void LinphoneCoreSetLogLevel(int loglevel);

39 40 41
			/// <summary>
			/// Creates a C++/CX LpConfig object using pointer to C structure.
			/// </summary>
42
			static Platform::Object^ CreateLpConfig(void* config);
43

44 45 46 47 48 49 50 51
			/// <summary>
			/// Creates a C++/CX LpConfig object using the path to linphonerc files.
			/// </summary>
			static Platform::Object^ CreateLpConfig(Platform::String^ configPath, Platform::String^ factoryConfigPath);
			
			/// <summary>
			/// Creates a C++/CX PayloadType object using pointer to C structure.
			/// </summary>
52
			static Platform::Object^ CreatePayloadType(void* pt);
53 54 55 56
			
			/// <summary>
			/// Creates a C++/CX LinphoneCall object using pointer to C structure.
			/// </summary>
57
			static Platform::Object^ CreateLinphoneCall(void* call);
58 59 60 61
			
			/// <summary>
			/// Creates a C++/CX LinphoneAddress object using pointer to C structure.
			/// </summary>
62
			static Platform::Object^ CreateLinphoneAddress(void* addr);
63 64 65 66
			
			/// <summary>
			/// Creates a C++/CX LinphoneAddress object using an URI.
			/// </summary>
67
			static Platform::Object^ CreateLinphoneAddressFromUri(const char* uri);
68 69 70 71
			
			/// <summary>
			/// Creates a C++/CX LinphoneAuthInfo object using pointer to C structure.
			/// </summary>
72
			static Platform::Object^ CreateLinphoneAuthInfo(void* auth_info);
73
			
74 75 76
			/// <summary>
			/// Creates a C++/CX LinphoneProxyConfig object using pointer to C structure.
			/// </summary>
77
			static Platform::Object^ CreateLinphoneProxyConfig(void* proxy_config);
78
			
79 80 81
			/// <summary>
			/// Creates a C++/CX LinphoneCallLog object using pointer to C structure.
			/// </summary>
Sylvain Berfini's avatar
Sylvain Berfini committed
82
			static Platform::Object^ CreateLinphoneCallLog(void* calllog);
83 84 85 86 87
			
			/// <summary>
			/// Creates a C++/CX LinphoneCallParams object using pointer to C structure.
			/// </summary>
			static Platform::Object^ CreateLinphoneCallParams(void* callParams);
88 89 90 91 92
			
			/// <summary>
			/// Creates a C++/CX LinphoneCallStats object using pointer to C structure.
			/// </summary>
			static Platform::Object^ CreateLinphoneCallStats(void* callStats, void* call);
Sylvain Berfini's avatar
Sylvain Berfini committed
93

94 95 96 97
		private:
			static std::string wstos(std::wstring ws);

			static std::string pstos(Platform::String^ ps);
98
		};
99

100 101 102 103 104 105 106 107 108 109
		template <class T>
		class RefToPtrProxy
		{
		public:
			RefToPtrProxy(T obj) : mObj(obj) {}
			~RefToPtrProxy() { mObj = nullptr; }
			T Ref() { return mObj; }
		private:
			T mObj;
		};
110 111
	}
}