Webqq/Client/Method/_relink.pm

filter: Statementstmt 19.4% 7 / 36 Branchbran 0.0% 0 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod n/a totaltotal 14.7% 9 / 61 CC 12 SCAR 49.0
CC
12
Cov
12%
_relink
156.0
BEGIN
1.0
BEGIN
1.0
CRAP 133.9
« Webqq/Client/Plugin/Msgstat.pm ↑ Summary Webqq/Message.pm »
1 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use Webqq::Client::Util qw(console);
Subroutine BEGIN: called CC=1 SCAR=0.0
3 0 ▶sub Webqq::Client::_relink{
Subroutine _relink: not called CC=12 SCAR=50.5
4 0 my $self = shift;
5 0 $self->{login_state} = 'relink';
6 0 console "正在进行重新连接...\n";
7 0 my $ua = $self->{ua};
8 0 my $api_url = 'http://d.web2.qq.com/channel/login2';
9 0 ▶ my @headers = $self->{type} eq 'webqq'? (Referer=>'http://d.web2.qq.com/proxy.html?v=20110331002&callback=1&id=3')
Branch: 1 branch
BranchTrueFalseTotal
$self->{'type'} eq 'webqq' ? : 0 0 0
10 : (Referer=>'http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2')
11 ;
12 my %r = (
13 status => $self->{qq_param}{status},
14 key => "",
15 ptwebqq => $self->{qq_param}{ptwebqq},
16 clientid => $self->{qq_param}{clientid},
17 psessionid => $self->{qq_param}{psessionid},
18 0 );
19
20 0 ▶ if($self->{type} eq 'webqq'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"type"} eq "webqq") 0 0 0
21 0 $r{passwd_sig} = $self->{qq_param}{passwd_sig};
22 }
23  
24 0 ▶ for(my $i=0;$i<=$self->{ua_retry_times};$i++){
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $self->{"ua_retry_times"}) 0 0 0
25 0 my $response = $ua->post($api_url,[r=>JSON->new->utf8->encode(\%r)], @headers);
26 0 ▶ if($response->is_success){
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_success) 0 0 0
27 0 ▶ print $response->content() if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
28 0 my $content = $response->content();
29 0 my $data = JSON->new->utf8->decode($content);
30 0 ▶ if($data->{retcode} ==0){
Branch: 1 branch
BranchTrueFalseTotal
if ($data->{'retcode'} == 0) { } 0 0 0
31 0 ▶ $self->{qq_param}{psessionid} = $data->{result}{psessionid} if $data->{result}{psessionid};
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"result"}{"psessionid"} 0 0 0
32 0 ▶ $self->{qq_param}{vfwebqq} = $data->{result}{vfwebqq} if $data->{result}{vfwebqq};
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"result"}{"vfwebqq"} 0 0 0
33 0 ▶ $self->{qq_param}{clientid} = $data->{result}{clientid} if $data->{result}{clientid};
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"result"}{"clientid"} 0 0 0
34 0 ▶ $self->{qq_param}{ptwebqq} = $data->{result}{ptwebqq} if $data->{result}{ptwebqq};
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"result"}{"ptwebqq"} 0 0 0
35 0 ▶ $self->{qq_param}{skey} = $data->{result}{skey} if $data->{result}{skey};
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"result"}{"skey"} 0 0 0
36 0 $self->{cookie_jar}->set_cookie(0,"ptwebqq",$data->{result}{ptwebqq},"/","qq.com");
37 0 $self->_cookie_proxy();
38 0 $self->{login_state} = 'success';
39 0 return 1;
40 }
41 else{
42 0 $self->relogin();
43 0 return 0;
44 }
45 }
46 }
47 0 $self->relogin();
48 0 return 0;
49 }
50 1 1;
« Webqq/Client/Plugin/Msgstat.pm ↑ Summary Webqq/Message.pm »