MT#9177 Further yealink changes

ipeshinskaya/9177
Irina Peshinskaya 11 years ago
parent 3779466cb6
commit bfd2f7a96c

@ -44,12 +44,7 @@ sub dispatch{
my $redirect_processor = get_redirect_processor($params);
my $ret;
if($redirect_processor){
if('unregister' eq $action){
$ret = $redirect_processor->redirect_unregister;
}
if('register' eq $action){
$ret = $redirect_processor->redirect_register;
}
$ret = $redirect_processor->redirect_server_call($action);
}
return $ret;
}
@ -61,7 +56,8 @@ sub get_redirect_processor{
my $redirect_processor;
if('redirect_panasonic' eq $bootstrap_method){
$redirect_processor = NGCP::Panel::Utils::DeviceBootstrap::Panasonic->new( params => $params );
}elsif('redirect_linksys' eq $bootstrap_method){
}elsif('redirect_yealink' eq $bootstrap_method){
$redirect_processor = NGCP::Panel::Utils::DeviceBootstrap::yealink->new( params => $params );
}elsif('http' eq $bootstrap_method){
#$ret = panasonic_bootstrap_register($params);
}

@ -22,17 +22,17 @@ has 'rpc_server_params' => (
isa => 'HashRef',
);
sub redirect_register{
my ($self) = @_;
sub redirect_server_call{
my ($self, $action) = @_;
my $c = $self->params->{c};
$self->init_content_params();
$c->log->debug(Dumper ($self->content_params));
my($content,$response_value);
if(defined $self->content_params->{mac_old} && $self->content_params->{mac} ne $self->content_params->{mac_old}) {
if('unregister' eq $action){
$content = $self->unregister_content();
$response_value = $self->rpc_https_call($content);
}elsif('register' eq $action){
$content = $self->register_content();
}
$content = $self->register_content();
$response_value = $self->rpc_https_call($content);
return $self->extract_response_description($response_value);
}
@ -60,12 +60,13 @@ sub rpc_https_call{
}
return $response_value;
}
sub init_content_params{
my($self) = @_;
$self->params->{redirect_uri_params} ||= '{MAC}';
my $uri = $self->get_bootstrap_uri();
$self->content_params->{uri} = $self->get_bootstrap_uri();
$self->{content_params} ||= {};
$self->content_params->{uri} = URI::Escape::uri_escape($uri);
$self->content_params->{mac} = normalize_mac($self->params->{mac});
if(defined $self->params->{mac_old}) {
$self->content_params->{mac_old} = normalize_mac($self->params->{mac_old});
@ -78,6 +79,8 @@ sub normalize_mac {
$mac = uc($mac);
return $mac;
}
sub get_basic_authorization{
my($self) = @_;
my $authorization = encode_base64(join(':',@{$self->params->{credentials}}{qw/user password/}));
@ -97,9 +100,19 @@ sub get_bootstrap_uri{
my $cfg = $self->get_bootstrap_uri_conf();
$uri = "$cfg->{schema}://$cfg->{host}:$cfg->{port}/device/autoprov/config/";
}
if ($uri !~/\{MAC\}$/){
if ($uri !~/\/$/){
$uri .= '/' ;
}
$uri .= '{MAC}' ;
}
$uri .= $uri_params;
$uri = URI::Escape::uri_escape($uri);
return $uri;
}
#separated as this logic also used in other places, so can be moved to other utils module
sub get_bootstrap_uri_conf{
my ($self) = @_;
my $c = $self->params->{c};

@ -61,14 +61,6 @@ sub unregister_content {
<value><string>".$self->content_params->{mac_old}."</string></value>
</param>
</params>
</methodCall>
<?xml version=\"1.0\"?>
<methodCall>
<methodName>ipredirect.unregisterPhone</methodName>
<params>
<param><value><string>".$self->content_params->{mac_old}."</string></value></param>
</params>
</methodCall>";
return $self->{unregister_content};
}

Loading…
Cancel
Save