-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPhpLinphoneAuth.cpp
More file actions
executable file
·59 lines (51 loc) · 1.82 KB
/
Copy pathPhpLinphoneAuth.cpp
File metadata and controls
executable file
·59 lines (51 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "PhpLinphoneAuth.h"
// Implementation of PHP constructor.
void PhpLinphoneAuth::__construct(Php::Parameters ¶meters) {
this->core = (PhpLinphoneCore *)parameters[0].implementation();
}
// Implementation of PHP destructor.
void PhpLinphoneAuth::__destruct() {
if (this->from != nullptr) {
linphone_address_unref(this->from);
}
if (this->info != nullptr) {
linphone_auth_info_destroy(this->info);
}
}
// Implementation of setUsername method.
void PhpLinphoneAuth::setUsername(Php::Parameters ¶meters) {
std::string user = parameters[0];
this->username = user;
this->from = linphone_address_new((this->username).c_str());
if (this->from == nullptr) {
Php::error<<"The username specified is not a valid sip URI."<<std::endl;
}
}
// Implementation of setPassword method.
void PhpLinphoneAuth::setPassword(Php::Parameters ¶meters) {
this->password = parameters[0].stringValue();
}
// Implementation of build method.
void PhpLinphoneAuth::build() {
if (this->from != nullptr) {
this->info = linphone_auth_info_new(linphone_address_get_username(this->from),NULL,(this->password).c_str(),NULL,NULL,NULL);
if (this->info == nullptr) {
Php::error<<"Error while building the authentication info."<<std::endl;
}
} else {
Php::error<<"The address is not set yet. Set the username first with setUsername method."<<std::endl;
}
linphone_core_add_auth_info((this->core)->get(),this->info);
}
// Implementation of get method.
LinphoneAuthInfo *PhpLinphoneAuth::get() {
return this->info;
}
// Implementation of getFrom method.
LinphoneAddress *PhpLinphoneAuth::getFrom() {
return this->from;
}
// Implementation of getUsername method.
std::string PhpLinphoneAuth::getUsername() const {
return this->username;
}