1 package GSM::SMS::NBS::Alcatel;
10 use GSM::SMS::NBS::Lib;
13 use vars qw($VERSION);
16 use constant IEI_ALCATEL_PICTURE => 0b100;
17 use constant IEI_ALCATEL_ANIMATION => 0b101;
18 use constant IEI_ALCATEL_MSEQ_MELODY => 0b010;
21 # returns ($msg, $udh=[...])
23 my ($class, $bitmap) = @_;
25 $bitmap->crop(0xFF,0xFF);
26 my @msglist=($bitmap->{"width"}, $bitmap->{"height"}, $bitmap->pixlist_vert());
27 return (pack("C*", @msglist), [
31 && !($bitmap->{"width"}&0x7) # width%8 == 0
32 && ($bitmap->{"width"}/8 * $bitmap->{"height"} <= 128), # width/8*height <= 128
33 "alcatel_type"=>IEI_ALCATEL_PICTURE,
34 "length"=>scalar(@msglist),
38 # expects list of GSM::SMS::Bitmap instances mixed with numbers (display times)
39 # returns ($msg, $udh=[...])
40 sub alcatel_animation {
41 my ($class, @list) = @_;
46 my $imgmsg=""; # concatenated image bodies (produced by alcatel_picture())
48 my $header_len = 2*(1+@list); # "2*"=words, "1+"=sequence_size, "@list"=items
49 for my $item (@list) {
50 if ("GSM::SMS::Bitmap" eq ref $item) {
51 if (!exists $imgs{$item}) {
52 $imgs{$item}=$header_len+length($imgmsg);
53 my ($msg)=$class->alcatel_picture($item);
55 $sized = ((0 # condition tests whether we have _violated_ EMS compatibility
56 || $item->{"width"} != $item->{"height"}
57 || ($sized && $sized != $item->{"width"})
58 || ($item->{"width"} != 8 && $item->{"width"} != 16)
59 ) ? -1 : $item->{"width"});
61 push(@words,$imgs{$item});
62 } else { # "display time" here:
63 push(@words,min($item & 0x0FFF));
66 unshift(@words,scalar(@words));
67 my $r=pack("v*",@words).$imgmsg;
72 && 4 == keys %imgs # exactly 4 frames
73 && -1 != $sized, # frame sizes valid
74 "alcatel_type"=>IEI_ALCATEL_ANIMATION,
79 # returns ($msg, $udh=[...])
80 sub alcatel_mseq_melody_file {
81 my ($class, $file_data) = @_;
86 "ems_compat"=>!!(0x20 & ord(substr($file_data,4,1))),
87 "alcatel_type"=>IEI_ALCATEL_MSEQ_MELODY,
88 "length"=>length($file_data),