line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::FindMyiPhone::Device; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
49
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
33
|
use 5.010_001; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
60
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
566
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# use Data::Dumper; # TODO: remove |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
0
|
|
|
0
|
0
|
|
my ( $class, $parent, $data ) = @_; |
15
|
0
|
|
|
|
|
|
my $self = { _parent => $parent, %$data }; |
16
|
0
|
|
|
|
|
|
return bless $self, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _update_self { |
20
|
0
|
|
|
0
|
|
|
my ( $self, $new_data ) = @_; |
21
|
0
|
|
|
|
|
|
$self->{$_} = $new_data->{$_} for keys %$new_data; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub send_message { |
25
|
0
|
|
|
0
|
1
|
|
my ( $self, $sound, $message, $subject ) = @_; |
26
|
0
|
0
|
|
|
|
|
$sound = $sound ? 'true' : 'false'; |
27
|
0
|
|
0
|
|
|
|
$subject ||= 'Important Message'; |
28
|
0
|
|
|
|
|
|
my $post |
29
|
|
|
|
|
|
|
= sprintf( |
30
|
|
|
|
|
|
|
'{"clientContext":{"appName":"FindMyiPhone","appVersion":"1.4","buildVersion":"145","deviceUDID":"0000000000000000000000000000000000000000","inactiveTime":5911,"osVersion":"3.2","productType":"iPad1,1","selectedDevice":"%s","shouldLocate":false},"device":"%s","serverContext":{"callbackIntervalInMS":3000,"clientId":"0000000000000000000000000000000000000000","deviceLoadStatus":"203","hasDevices":true,"lastSessionExtensionTime":null,"maxDeviceLoadTime":60000,"maxLocatingTime":90000,"preferredLanguage":"en","prefsUpdateTime":1276872996660,"sessionLifespan":900000,"timezone":{"currentOffset":-25200000,"previousOffset":-28800000,"previousTransition":1268560799999,"tzCurrentName":"Pacific Daylight Time","tzName":"America/Los_Angeles"},"validRegion":true},"sound":%s,"subject":"%s","text":"%s","userText":true}', |
31
|
|
|
|
|
|
|
$self->{id}, $self->{id}, $sound, $subject, $message ); |
32
|
0
|
|
|
|
|
|
return $self->{_parent}->_post( '/sendMessage', $post )->json; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub remote_lock { |
36
|
0
|
|
|
0
|
1
|
|
my ( $self, $passcode ) = @_; |
37
|
0
|
|
|
|
|
|
my $post |
38
|
|
|
|
|
|
|
= sprintf( |
39
|
|
|
|
|
|
|
'{"clientContext":{"appName":"FindMyiPhone","appVersion":"1.4","buildVersion":"145","deviceUDID":"0000000000000000000000000000000000000000","inactiveTime":5911,"osVersion":"3.2","productType":"iPad1,1","selectedDevice":"%s","shouldLocate":false},"device":"%s","oldPasscode":"","passcode":"%s","serverContext":{"callbackIntervalInMS":3000,"clientId":"0000000000000000000000000000000000000000","deviceLoadStatus":"203","hasDevices":true,"lastSessionExtensionTime":null,"maxDeviceLoadTime":60000,"maxLocatingTime":90000,"preferredLanguage":"en","prefsUpdateTime":1276872996660,"sessionLifespan":900000,"timezone":{"currentOffset":-25200000,"previousOffset":-28800000,"previousTransition":1268560799999,"tzCurrentName":"Pacific Daylight Time","tzName":"America/Los_Angeles"},"validRegion":true}}', |
40
|
|
|
|
|
|
|
$self->{id}, $self->{id}, $passcode ); |
41
|
0
|
|
|
|
|
|
return $self->{_parent}->_post( '/remoteLock', $post ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub location { |
45
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
46
|
0
|
|
|
|
|
|
my $count = 0; |
47
|
0
|
|
|
|
|
|
while ( !$self->{location}{locationFinished} ) { |
48
|
|
|
|
|
|
|
# print Dumper( $self->{location} ); |
49
|
0
|
|
|
|
|
|
sleep 2; |
50
|
0
|
|
|
|
|
|
$self->{_parent}->update_devices; |
51
|
0
|
0
|
|
|
|
|
last if ++$count >= 3; |
52
|
|
|
|
|
|
|
# warn "Sleeping and checking again"; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
return $self->{location}; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
__END__ |