AuthInfo.cpp 3.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
AuthInfo.cpp
Copyright (C) 2015  Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
15 16 17 18 19
*/

#include "AuthInfo.h"
#include "Utils.h"

20
using namespace BelledonneCommunications::Linphone::Native;
21

22
Platform::String^ AuthInfo::Ha1::get()
23 24 25 26 27
{
	API_LOCK;
	return Utils::cctops(linphone_auth_info_get_ha1(this->auth_info));
}

28
void AuthInfo::Ha1::set(Platform::String^ ha1)
29 30
{
	API_LOCK;
31
	const char *cc = Utils::pstoccs(ha1);
32 33 34 35
	linphone_auth_info_set_ha1(this->auth_info, cc);
	delete(cc);
}

36
Platform::String^ AuthInfo::Passwd::get()
37 38 39 40 41
{
	API_LOCK;
	return Utils::cctops(linphone_auth_info_get_passwd(this->auth_info));
}

42
void AuthInfo::Passwd::set(Platform::String^ password)
43 44
{
	API_LOCK;
45
	const char *cc = Utils::pstoccs(password);
46 47 48 49
	linphone_auth_info_set_passwd(this->auth_info, cc);
	delete(cc);
}

50
Platform::String^ AuthInfo::Realm::get()
51 52 53 54 55
{
	API_LOCK;
	return Utils::cctops(linphone_auth_info_get_realm(this->auth_info));
}

56
void AuthInfo::Realm::set(Platform::String^ realm)
57 58
{
	API_LOCK;
59
	const char *cc = Utils::pstoccs(realm);
60 61 62 63
	linphone_auth_info_set_realm(this->auth_info, cc);
	delete(cc);
}

64
Platform::String^ AuthInfo::Userid::get()
65 66 67 68 69
{
	API_LOCK;
	return Utils::cctops(linphone_auth_info_get_userid(this->auth_info));
}

70
void AuthInfo::Userid::set(Platform::String^ userid)
71 72
{
	API_LOCK;
73
	const char *cc = Utils::pstoccs(userid);
74 75 76 77
	linphone_auth_info_set_userid(this->auth_info, cc);
	delete(cc);
}

78
Platform::String^ AuthInfo::Username::get()
79 80 81 82 83
{
	API_LOCK;
	return Utils::cctops(linphone_auth_info_get_username(this->auth_info));
}

84
void AuthInfo::Username::set(Platform::String^ username)
85 86
{
	API_LOCK;
87
	const char *cc = Utils::pstoccs(username);
88 89 90 91
	linphone_auth_info_set_username(this->auth_info, cc);
	delete(cc);
}

92
AuthInfo::AuthInfo(Platform::String^ username, Platform::String^ userid, Platform::String^ password, Platform::String^ ha1, Platform::String^ realm, Platform::String^ domain)
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
{
	const char* cc_username = Utils::pstoccs(username);
	const char* cc_password = Utils::pstoccs(password);
	const char* cc_realm = Utils::pstoccs(realm);
	const char* cc_userid = Utils::pstoccs(userid);
	const char* cc_ha1 = Utils::pstoccs(ha1);
	const char* cc_domain = Utils::pstoccs(domain);
	this->auth_info = linphone_auth_info_new(cc_username, cc_userid, cc_password, cc_ha1, cc_realm, cc_domain);
	delete(cc_username);
	delete(cc_userid);
	delete(cc_password);
	delete(cc_ha1);
	delete(cc_realm);
	delete(cc_domain);
}

109
AuthInfo::AuthInfo(::LinphoneAuthInfo *auth_info)
110 111 112 113
	: auth_info(auth_info)
{
}

114
AuthInfo::~AuthInfo()
115
{
116
}