+ems_picture & ems_animation splitting as even C55 doesn't support IEI 0x14
authorshort <>
Wed, 16 Oct 2002 23:09:16 +0000 (23:09 +0000)
committershort <>
Wed, 16 Oct 2002 23:09:16 +0000 (23:09 +0000)
--ems-{picture,animation,melody}-send: Specifyable multiple times now

GSM/examples/commandline/gsmcmd

index 0c2c220..f53ccf4 100755 (executable)
@@ -15,6 +15,9 @@ require GSM::SMS::NBS::Alcatel;
 $|=1;     # No output buffering
 
 
+my $EMStext="";
+my @EMSudh;
+
 #
 # Arguments
 my $opt_verbose;
@@ -35,9 +38,9 @@ GetOptions(
        "ring-send:s"                     => \$opt_ring_send,
        "logo-group-send:s"               => \$opt_logo_group_send,
        "ems-force-variable"              => \$opt_ems_force_variable,
-       "ems-picture-send:s"              => \$opt_ems_picture_send,
-       "ems-animation-send:s"            => \$opt_ems_animation_send,
-       "ems-melody-file-send:s"          => \$opt_ems_melody_file_send,
+       "ems-picture-send:s"              => \&ems_picture_send,
+       "ems-animation-send:s"            => \&ems_animation_send,
+       "ems-melody-file-send:s"          => \&ems_melody_file_send,
        "alcatel-name:s"                  => \$opt_alcatel_name,
        "alcatel-picture-send:s"          => \$opt_alcatel_picture_send,
        "alcatel-animation-send:s"        => \$opt_alcatel_animation_send,
@@ -88,39 +91,8 @@ for $msisdn (@ARGV) {
                $nbs->sendGroupGraphic_file($msisdn, $opt_logo_group_send);
        }
 
-       if ($opt_ems_picture_send) {
-               my $bitmap = GSM::SMS::Bitmap->new($opt_ems_picture_send);
-               $nbs->sendsms($msisdn, "", udh=>[ {
-                               "type"=>"ems_picture",
-                               TEXT_POSITION=>0,
-                               "bitmap"=>$bitmap,
-                               "force_variable"=>$opt_ems_force_variable,
-               } ]);
-       }
-
-       if ($opt_ems_animation_send) {
-               my @names=split /:/,$opt_ems_animation_send;
-               die "Required exactly 4 colon (':') delimited filenames for --ems-animation-send" if 4 != @names;
-               my @bitmaps=map { GSM::SMS::Bitmap->new($_); } @names;
-               $nbs->sendsms($msisdn, "", udh=>[ {
-                               "type"=>"ems_animation",
-                               TEXT_POSITION=>0,
-                               "bitmaps"=>\@bitmaps,
-               } ]);
-       }
-
-       if ($opt_ems_melody_file_send) {
-               local (*F);
-               open F, $opt_ems_melody_file_send;
-               my $ems_melody_file_data = <F>;
-               close F;
-               warn "EMS iMelody file format not recognized, wrapping anyway"
-                               if $ems_melody_file_data!~/^BEGIN:IMELODY\r\n.*END:IMELODY\r\n$/s;
-               $nbs->sendsms($msisdn, "", udh=>[ {
-                               "type"=>"ems_melody",
-                               TEXT_POSITION=>0,
-                               "textdata"=>$ems_melody_file_data,
-               } ]);
+       if (@EMSudh || $EMStext ne "") {
+               $nbs->sendsms($msisdn, $EMStext, udh=>[ @EMSudh ]);
        }
 
        if ($opt_alcatel_picture_send) {
@@ -161,3 +133,65 @@ for $msisdn (@ARGV) {
 }
 
 exit(0);
+
+sub ems_picture_send
+{
+my($keyword,$arg)=@_;
+
+       my $bitmap = GSM::SMS::Bitmap->new($arg);
+       push @EMSudh,{
+                       "type"=>"ems_picture",
+                       TEXT_POSITION=>length($EMStext),
+                       "bitmap"=>$bitmap,
+                       "force_variable"=>$opt_ems_force_variable,
+                       };
+}
+
+sub ems_animation_send
+{
+my($keyword,$arg)=@_;
+
+       my @names=split /:/,$arg;
+       die "Required exactly 4 colon (':') delimited filenames for --ems-animation-send" if 4 != @names;
+       my @bitmaps=map { GSM::SMS::Bitmap->new($_); } @names;
+       my($width,$height)=GSM::SMS::NBS::Message::ems_animation_maxsize(\@bitmaps);
+       # Will we need some newlines?
+       if ($height>16) {
+               my $height_now;
+               for (my $y=0;$y<$height;$y+=$height_now) {
+                       $height_now=($y+8>=$height ? 8 : 16);
+                       # we don't do horizontal split here
+                       push @EMSudh,{
+                                       "type"=>"ems_animation",
+                                       TEXT_POSITION=>length($EMStext),
+                                       "bitmaps"=>[ map({
+                                                       GSM::SMS::Bitmap->new($_,0,$y,$width,$height_now);
+                                                       } @bitmaps) ],
+                                       };
+                       $EMStext.="\n" if $y+$height_now<$height;
+                       }
+               return;
+               }
+       push @EMSudh,{
+                       "type"=>"ems_animation",
+                       TEXT_POSITION=>length($EMStext),
+                       "bitmaps"=>\@bitmaps,
+                       };
+}
+
+sub ems_melody_file_send
+{
+my($keyword,$arg)=@_;
+
+       local (*F);
+       open F, $opt_ems_melody_file_send;
+       my $ems_melody_file_data = <F>;
+       close F;
+       warn "EMS iMelody file format not recognized, wrapping anyway"
+                       if $ems_melody_file_data!~/^BEGIN:IMELODY\r\n.*END:IMELODY\r\n$/s;
+       push @EMSudh,{
+                       "type"=>"ems_melody",
+                       TEXT_POSITION=>length($EMStext),
+                       "textdata"=>$ems_melody_file_data,
+                       };
+}