Commit 3dfbdc8a authored by Ghislain MARY's avatar Ghislain MARY

Complete AuthInfo handling.

parent 60054626
......@@ -4,32 +4,72 @@
Platform::String^ Linphone::Core::LinphoneAuthInfo::GetUsername()
{
return nullptr;
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
return Utils::cctops(linphone_auth_info_get_username(this->auth_info));
}
void Linphone::Core::LinphoneAuthInfo::SetUsername(Platform::String^ username)
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
const char *cc = Linphone::Core::Utils::pstoccs(username);
linphone_auth_info_set_username(this->auth_info, cc);
delete(cc);
}
Platform::String^ Linphone::Core::LinphoneAuthInfo::GetUserId()
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
return Utils::cctops(linphone_auth_info_get_userid(this->auth_info));
}
void Linphone::Core::LinphoneAuthInfo::SetUserId(Platform::String^ userid)
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
const char *cc = Linphone::Core::Utils::pstoccs(userid);
linphone_auth_info_set_userid(this->auth_info, cc);
delete(cc);
}
Platform::String^ Linphone::Core::LinphoneAuthInfo::GetPassword()
{
return nullptr;
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
return Utils::cctops(linphone_auth_info_get_passwd(this->auth_info));
}
void Linphone::Core::LinphoneAuthInfo::SetPassword(Platform::String^ password)
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
const char *cc = Linphone::Core::Utils::pstoccs(password);
linphone_auth_info_set_passwd(this->auth_info, cc);
delete(cc);
}
Platform::String^ Linphone::Core::LinphoneAuthInfo::GetRealm()
{
return nullptr;
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
return Utils::cctops(linphone_auth_info_get_realm(this->auth_info));
}
void Linphone::Core::LinphoneAuthInfo::SetRealm(Platform::String^ realm)
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
const char *cc = Linphone::Core::Utils::pstoccs(realm);
linphone_auth_info_set_realm(this->auth_info, cc);
delete(cc);
}
Platform::String^ Linphone::Core::LinphoneAuthInfo::GetHa1()
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
return Utils::cctops(linphone_auth_info_get_ha1(this->auth_info));
}
void Linphone::Core::LinphoneAuthInfo::SetHa1(Platform::String^ ha1)
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
const char *cc = Linphone::Core::Utils::pstoccs(ha1);
linphone_auth_info_set_ha1(this->auth_info, cc);
delete(cc);
}
Linphone::Core::LinphoneAuthInfo::LinphoneAuthInfo(Platform::String^ username, Platform::String^ userid, Platform::String^ password, Platform::String^ ha1, Platform::String^ realm)
......@@ -47,6 +87,12 @@ Linphone::Core::LinphoneAuthInfo::LinphoneAuthInfo(Platform::String^ username, P
delete(cc_realm);
}
Linphone::Core::LinphoneAuthInfo::LinphoneAuthInfo(::LinphoneAuthInfo *auth_info) :
auth_info(auth_info)
{
}
Linphone::Core::LinphoneAuthInfo::~LinphoneAuthInfo()
{
......
......@@ -24,6 +24,10 @@ namespace Linphone
void SetUsername(Platform::String^ username);
Platform::String^ GetUserId();
void SetUserId(Platform::String^ userid);
Platform::String^ GetPassword();
void SetPassword(Platform::String^ password);
......@@ -32,10 +36,16 @@ namespace Linphone
void SetRealm(Platform::String^ realm);
Platform::String^ GetHa1();
void SetHa1(Platform::String^ ha1);
private:
friend class Linphone::Core::Utils;
friend ref class Linphone::Core::LinphoneCore;
LinphoneAuthInfo(Platform::String^ username, Platform::String^ userid, Platform::String^ password, Platform::String^ ha1, Platform::String^ realm);
LinphoneAuthInfo(::LinphoneAuthInfo *auth_info);
~LinphoneAuthInfo();
::LinphoneAuthInfo *auth_info;
......
......@@ -126,6 +126,26 @@ Linphone::Core::LinphoneAuthInfo^ Linphone::Core::LinphoneCore::CreateAuthInfo(P
return authInfo;
}
static void AddAuthInfoToVector(void *vAuthInfo, void *vector)
{
::LinphoneAuthInfo *ai = (LinphoneAuthInfo *)vAuthInfo;
Linphone::Core::RefToPtrProxy<IVector<Object^>^> *list = reinterpret_cast< Linphone::Core::RefToPtrProxy<IVector<Object^>^> *>(vector);
IVector<Object^>^ authInfos = (list) ? list->Ref() : nullptr;
Linphone::Core::LinphoneAuthInfo^ authInfo = (Linphone::Core::LinphoneAuthInfo^)Linphone::Core::Utils::CreateLinphoneAuthInfo(ai);
authInfos->Append(authInfo);
}
IVector<Object^>^ Linphone::Core::LinphoneCore::GetAuthInfos()
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
IVector<Object^>^ authInfos = ref new Vector<Object^>();
const MSList *authlist = linphone_core_get_auth_info_list(this->lc);
RefToPtrProxy<IVector<Object^>^> *authInfosPtr = new RefToPtrProxy<IVector<Object^>^>(authInfos);
ms_list_for_each2(authlist, AddAuthInfoToVector, authInfosPtr);
return authInfos;
}
void Linphone::Core::LinphoneCore::Destroy()
{
IterateTimer->Cancel();
......
......@@ -97,6 +97,11 @@ namespace Linphone
/// Creates an empty auth info.
/// </summary>
LinphoneAuthInfo^ CreateAuthInfo(Platform::String^ username, Platform::String^ userid, Platform::String^ password, Platform::String^ ha1, Platform::String^ realm);
/// <summary>
/// Gets the current auth infos.
/// </summary>
Windows::Foundation::Collections::IVector<Platform::Object^>^ GetAuthInfos();
/// <summary>
/// Destroys LinphoneCore and free all underlying resources.
......
#include "Utils.h"
#include "LinphoneCall.h"
#include "LinphoneAddress.h"
#include "LinphoneAuthInfo.h"
#include "LinphoneCallLog.h"
#include "PayloadType.h"
......@@ -54,6 +55,11 @@ Platform::Object^ Linphone::Core::Utils::CreateLinphoneAddressFromUri(const char
return ref new Linphone::Core::LinphoneAddress(uri);
}
Platform::Object^ Linphone::Core::Utils::CreateLinphoneAuthInfo(void *auth_info)
{
return ref new Linphone::Core::LinphoneAuthInfo((::LinphoneAuthInfo *)auth_info);
}
Platform::Object^ Linphone::Core::Utils::CreateLinphoneCallLog(void* callLog)
{
return ref new Linphone::Core::LinphoneCallLog((::LinphoneCallLog*)callLog);
......
......@@ -20,6 +20,8 @@ namespace Linphone
static Platform::Object^ CreateLinphoneAddressFromUri(const char *uri);
static Platform::Object^ CreateLinphoneAuthInfo(void *auth_info);
static Platform::Object^ CreateLinphoneCallLog(void* calllog);
private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment