Webqq/Client/Method/_get_discuss_info.pm

filter: Statementstmt 18.5% 10 / 54 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 3 / 4 Podpod n/a totaltotal 15.6% 13 / 83 CC 16 SCAR 54.3
CC
16
Cov
13%
_get_discuss_info
272.0
BEGIN
1.0
BEGIN
1.0
CRAP 229.2
« Webqq/Client/Plugin/Perldoc.pm ↑ Summary Webqq/Client/Plugin/ShowMsg.pm »
1 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use Webqq::Client::Util qw(code2client);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 0 ▶sub Webqq::Client::_get_discuss_info {
Subroutine _get_discuss_info: not called CC=16 SCAR=56.1
5 0 my $self = shift;
6 0 my $ua = $self->{ua};
7 0 my $did = shift;
8 0 ▶ return undef if $self->{type} ne 'smartqq';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"type"} ne "smartqq" 0 0 0
9 0 my $api_url = 'http://d.web2.qq.com/channel/get_discu_info';
10 my @query_string = (
11 did => $did,
12 vfwebqq => $self->{qq_param}{vfwebqq},
13 clientid => $self->{qq_param}{clientid},
14 psessionid => $self->{qq_param}{psessionid},
15 0 t => time(),
16 );
17 0 my @headers = (
18 Referer => 'http://d.web2.qq.com/proxy.html?v=20130916001&callback=1&id=2',
19 );
20  
21 0 my @query_string_pairs;
22 0 ▶ push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string);
Branch: 1 branch
BranchTrueFalseTotal
@query_string and do { push @query_string_pairs, shift(@query_string) . '=' . shift(@query_string) } 0 0 0
23 0 my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers);
24  
25 0 ▶ if($response->is_success){
Branch: 1 branch
BranchTrueFalseTotal
if ($response->is_success) { } 0 0 0
26 0 ▶ print $response->content,"\n" if $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
27 0 my $json;
28 0 eval{
29 #my $d = $response->content();
30 #$d=~s/\\u([a-zA-Z0-9]{4})/encode("utf8",eval qq#"\\x{$1}"#)/eg;
31 #print $d,"\n" if $self->{debug};
32 0 $json = JSON->new->utf8->decode($response->content());
33 };
34 0 ▶ print $@ if $@ and $self->{debug};
Branch: 1 branch
BranchTrueFalseTotal
if $@ and $self->{"debug"} 0 0 0
Condition0%0/3
$@ and $self->{"debug"}
!ll&&!rl&&r
000
MC/DC0%0/2
$@ and $self->{"debug"}
$@ $self->{"debug"}
Truth table0%0/3
A and B
A= $@B= $self->{"debug"}
ABresult
0X0
100
111
35 0 ▶ $json = {} unless defined $json;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $json 0 0 0
36 0 ▶ return undef if $json->{retcode}!=0;
Branch: 1 branch
BranchTrueFalseTotal
if $json->{"retcode"} != 0 0 0 0
37 0 ▶ return undef unless exists $json->{result}{info};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $json->{"result"}{"info"} 0 0 0
38
39 0 my %mem_list;
40 my %mem_status;
41 0 my %mem_info;
42 0 my $minfo = [];
43  
44 0 for(@{ $json->{result}{info}{mem_list} }){
45 0 $mem_list{$_->{mem_uin}}{ruin} = $_->{ruin};
46 }
47  
48 0 for(@{ $json->{result}{mem_status} }){
49 0 $mem_status{$_->{uin}}{status} = $_->{status};
50 0 $mem_status{$_->{uin}}{client_type} = $_->{client_type};
51 }
52  
53 0 for(@{ $json->{result}{mem_info} }){
54 0 $mem_info{$_->{uin}}{nick} = encode("utf8",$_->{nick});
55 }
56  
57 0 for(keys %mem_list){
58 my $m = {
59 uin => $_,
60 nick => $mem_info{$_}{nick},
61 ruin => $mem_list{$_}{ruin},
62 0 };
63 0 ▶ if(exists $mem_status{$_}){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $mem_status{$_}) { } 0 0 0
64 0 $m->{state} = $mem_status{$_}{status};
65 0 $m->{client_type} = code2client($mem_status{$_}{client_type});
66 }
67 else{
68 0 $m->{state} = 'offline';
69 0 $m->{client_type} = 'unknown';
70 }
71 0 push @{$minfo},$m;
72 }
73  
74 my $discuss_info = {
75 dinfo => {
76 did => $json->{result}{info}{did},
77 owner => $json->{result}{info}{discu_owner},
78 name => encode("utf8",$json->{result}{info}{discu_name}),
79 info_seq => $json->{result}{info}{info_seq},
80 },
81 0 ▶ minfo => (@$minfo>0?$minfo:undef),
Branch: 1 branch
BranchTrueFalseTotal
@$minfo > 0 ? : 0 0 0
82 } ;
83 0 return $discuss_info;
84 }
85 0 else{return undef;}
86  
87 }
88 1 1;
« Webqq/Client/Plugin/Perldoc.pm ↑ Summary Webqq/Client/Plugin/ShowMsg.pm »