| 1 | #=============================================================================== | ||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||
| 3 | # FILE: SMS.pm | ||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||
| 5 | # DESCRIPTION: Routines for SMS data. | ||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||
| 7 | # NOTES: --- | ||||||||||||||||||||||||||||||||
| 8 | # AUTHOR: Michael Bochkaryov (Rattler), <misha@rattler.kiev.ua> | ||||||||||||||||||||||||||||||||
| 9 | # COMPANY: Net.Style | ||||||||||||||||||||||||||||||||
| 10 | # CREATED: 25.08.2009 14:12:44 EEST | ||||||||||||||||||||||||||||||||
| 11 | #=============================================================================== | ||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | NetSDS::Util::SMS - routines for SMS data processing | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | use NetSDS::Util::SMS; | ||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | # Prepare 400 characters string | ||||||||||||||||||||||||||||||||
| 22 | my $long_line = "zuka"x100; | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | # Split string to SMS parts | ||||||||||||||||||||||||||||||||
| 25 | my @sms = split_text($long_line, COD_7BIT); | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | C<NetSDS> module contains superclass all other classes should be inherited from. | ||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | I hope you can understand what these routines doing. | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | Few basics: | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | EMS | ||||||||||||||||||||||||||||||||
| 39 | $hex_sms = ie_melody($iMelody,''); | ||||||||||||||||||||||||||||||||
| 40 | $hex_sms = ie_bmp($BMP,''); | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | EMS Message is composed of several Information Elements | ||||||||||||||||||||||||||||||||
| 43 | preceded by the User Data Header Length (1 byte). | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | So I used 'non-object' standard: different subroutines | ||||||||||||||||||||||||||||||||
| 46 | producing different IE-Chunks. We can simply concantenate | ||||||||||||||||||||||||||||||||
| 47 | these chunks in one message and precede it with UDHL (and | ||||||||||||||||||||||||||||||||
| 48 | message-splitting elements if our EMS/IE stream don't fit | ||||||||||||||||||||||||||||||||
| 49 | standard 140 bytes. | ||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||
| 51 | Resulting stream filled with plain HEX-coded octets. | ||||||||||||||||||||||||||||||||
| 52 | Hexcodes are handy to use and can be easy converted to | ||||||||||||||||||||||||||||||||
| 53 | binary or base64 formats. | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | There is no something-to-imelody converter. Look for it | ||||||||||||||||||||||||||||||||
| 56 | in my ringtone.pm. | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | Pictures used as 1-bit Windows BMPs. I said 1-bit, ok? | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | =cut | ||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | package NetSDS::Util::SMS; | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | 2 | ▶ | use 5.8.0; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 65 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 66 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | 2 | ▶ | use version; our $VERSION = '0.021'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | 2 | ▶ | use base qw( | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 71 | Exporter | ||||||||||||||||||||||||||||||||
| 72 | NetSDS::Class::Abstract | ||||||||||||||||||||||||||||||||
| 73 | 2 | ); | |||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 2 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||
| 76 | ems_essage | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | ie_melody | ||||||||||||||||||||||||||||||||
| 79 | ie_icon16 | ||||||||||||||||||||||||||||||||
| 80 | ie_icon32 | ||||||||||||||||||||||||||||||||
| 81 | ie_picture | ||||||||||||||||||||||||||||||||
| 82 | ie_bmp | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | smart_message | ||||||||||||||||||||||||||||||||
| 85 | smart_bmp | ||||||||||||||||||||||||||||||||
| 86 | smart_logo | ||||||||||||||||||||||||||||||||
| 87 | smart_card | ||||||||||||||||||||||||||||||||
| 88 | smart_cli | ||||||||||||||||||||||||||||||||
| 89 | smart_ringtone | ||||||||||||||||||||||||||||||||
| 90 | smart_clear | ||||||||||||||||||||||||||||||||
| 91 | smart_push_wap | ||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | siemens_header | ||||||||||||||||||||||||||||||||
| 94 | siemens_message | ||||||||||||||||||||||||||||||||
| 95 | siemens | ||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||
| 97 | split_text | ||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||
| 100 | 2 | ▶ | use POSIX; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 101 | 2 | ▶ | use NetSDS::Const; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 102 | 2 | ▶ | use NetSDS::Const::Message; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 103 | 2 | ▶ | use NetSDS::Util::Convert; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 104 | 2 | ▶ | use NetSDS::Util::String; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | # File Format Signatures => SEO Types: | ||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | 2 | my %SIGN = ( | |||||||||||||||||||||||||||||||
| 109 | 'MT' => 'mid', | ||||||||||||||||||||||||||||||||
| 110 | 'BM' => 'bmp' | ||||||||||||||||||||||||||||||||
| 111 | ); | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 114 | # EMS | ||||||||||||||||||||||||||||||||
| 115 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 116 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | =head1 EXPORTS | ||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | =over | ||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | =item B<ems_essage(...)> | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | $message_str = ems_essage ( ie_stream, text_data ) | ||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | Produce a EMS message. | ||||||||||||||||||||||||||||||||
| 127 | Sure that ie data + text can not exceed 139 bytes. | ||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||
| 129 | =cut | ||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||
| 131 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | sub ems_essage { | ||||||||||||||||||||||||||||||
|
Subroutine
ems_essage: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 133 | 0 | my ( $ie_stream, $text, $encoding, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | unless ( defined($text) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 136 | 0 | $text = ''; | |||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||
| 139 | 0 | my $coding = COD_7BIT; | |||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ( $text =~ m/[^\x00-\x7f]/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | $text = str_recode( $text, defined($encoding) ? $encoding : DEFAULT_ENCODING, to_enc => ENC_UNICODE ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 142 | 0 | $coding = COD_UNICODE; | |||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | unless ( defined($transport) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 146 | 0 | $transport = TRANSPORT_ANY; | |||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | my $udhl = defined($ie_stream) ? bytes::length($ie_stream) : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if ($udhl) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 151 | # EMS Information Elements present... | ||||||||||||||||||||||||||||||||
| 152 | 0 | return [ { udh => pack( 'C', $udhl ) . $ie_stream, ud => $text, coding => $coding, transport => $transport } ]; | |||||||||||||||||||||||||||||||
| 153 | } else { | ||||||||||||||||||||||||||||||||
| 154 | # Plain text message. What a mess?.. | ||||||||||||||||||||||||||||||||
| 155 | 0 | return [ { udh => '', ud => $text, coding => $coding, transport => $transport } ]; | |||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||
| 157 | } ## end sub ems_essage | ||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | =item B<ie_melody(...)> | ||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||
| 163 | $ie_str = ie_melody ( melody ) | ||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||
| 165 | Produce an iMelody Information Element. | ||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | WARNING: Melodies larger than 128 bytes will be CROPPED! | ||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||
| 169 | =cut | ||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||
| 171 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | sub ie_melody { | ||||||||||||||||||||||||||||||
|
Subroutine
ie_melody: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 173 | 0 | my ( $raw, $text, $encoding, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||
| 175 | 0 | my $l = length($raw); | |||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if ( $l > 128 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 177 | 0 | $raw = substr( $raw, 0, 128 ); | |||||||||||||||||||||||||||||||
| 178 | 0 | $l = 128; | |||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||
| 181 | 0 | return ems_essage( IEC_MELODY . pack( 'C*', ++$l, 0 ) . $raw, $text, $encoding, $transport ); | |||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||
| 184 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||
| 186 | =item B<ie_icon32(...)> | ||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||
| 188 | =cut | ||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||
| 190 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | sub ie_icon32 { | ||||||||||||||||||||||||||||||
|
Subroutine
ie_icon32: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 192 | 0 | my ( $raw, $text, $encoding, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||
| 194 | 0 | my $l = length $raw; | |||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if ( $l > 128 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 196 | 0 | $raw = substr( $raw, 0, 128 ); | |||||||||||||||||||||||||||||||
| 197 | 0 | $l = 128; | |||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||
| 200 | 0 | return ems_essage( IEC_ICON32 . pack( 'C*', ++$l, 0 ) . $raw, $text, $encoding, $transport ); | |||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||
| 203 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||
| 205 | =item B<ie_icon16(...)> | ||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||
| 207 | =cut | ||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||
| 209 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | sub ie_icon16 { | ||||||||||||||||||||||||||||||
|
Subroutine
ie_icon16: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 211 | 0 | my ( $raw, $text, $encoding, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||
| 213 | 0 | my $l = length $raw; | |||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if ( $l > 32 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 215 | 0 | $raw = substr( $raw, 0, 32 ); | |||||||||||||||||||||||||||||||
| 216 | 0 | $l = 32; | |||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||
| 219 | 0 | return ems_essage( IEC_ICON16 . pack( 'C*', ++$l, 0 ) . $raw, $text, $encoding, $transport ); | |||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||
| 222 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||
| 224 | =item B<ie_picture(...)> | ||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||
| 226 | =cut | ||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||
| 228 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub ie_picture { | ||||||||||||||||||||||||||||||
|
Subroutine
ie_picture: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 230 | 0 | my ( $raw, $width, $height, $text, $encoding, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if ( $width % 8 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 233 | 0 | return __PACKAGE__->error("Non-8x width"); | |||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||
| 236 | 0 | my $squa = $width * $height / 8; | |||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if ( $squa > 128 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 238 | 0 | $height = int( 128 * 8 / $width ); | |||||||||||||||||||||||||||||||
| 239 | 0 | $squa = $width * $height / 8; | |||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||
| 242 | 0 | my $l = length($raw); | |||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if ( $l > $squa ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 244 | 0 | $raw = substr( $raw, 0, $squa ); | |||||||||||||||||||||||||||||||
| 245 | 0 | $l = $squa; | |||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||
| 248 | 0 | return ems_essage( IEC_PICTURE . pack( 'C*', $l + 3, 0, $width / 8, $height + 0 ) . $raw, $text, $encoding, $transport ); | |||||||||||||||||||||||||||||||
| 249 | } ## end sub ie_picture | ||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||
| 251 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||
| 253 | =item B<ie_bmp(...)> | ||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||
| 255 | =cut | ||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||
| 257 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | sub ie_bmp { | ||||||||||||||||||||||||||||||
|
Subroutine
ie_bmp: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 259 | 0 | my ( $bmp, $text, $encoding, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if ( substr( $bmp, 0, 2 ) ne 'BM' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 262 | 0 | return __PACKAGE__->error("Not a BMP"); | |||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | if ( unpack( 'L', substr( $bmp, 30, 4 ) ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 266 | 0 | return __PACKAGE__->error("Compressed BMP"); | |||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | unless ( unpack( 'S', substr( $bmp, 28, 2 ) ) == 1 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 270 | 0 | return __PACKAGE__->error("Need 1bpp monochrome BMP"); | |||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||
| 273 | 0 | my $w = unpack( 'L', substr( $bmp, 18, 4 ) ); | |||||||||||||||||||||||||||||||
| 274 | 0 | my $h = unpack( 'L', substr( $bmp, 22, 4 ) ); | |||||||||||||||||||||||||||||||
| 275 | 0 | my $ofs = unpack( 'L', substr( $bmp, 10, 4 ) ); | |||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||
| 277 | 0 | my @bitmap = split( //, substr( $bmp, $ofs, length($bmp) ) ); | |||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||
| 279 | # Line Width in bytes | ||||||||||||||||||||||||||||||||
| 280 | 0 | my $line = int( $w / 8 ); | |||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | $line++ if ( $w % 8 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||
| 283 | # Pad to 4x bytes | ||||||||||||||||||||||||||||||||
| 284 | 0 | my $padding = 0; | |||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | $padding = 4 - $line % 4 if ( $line % 4 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||
| 287 | 0 | my $raw = ''; | |||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | for ( my $y = 0 ; $y < $h ; $y++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 289 | 0 | my $ll = ''; | |||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | for ( my $x = 0 ; $x < $line ; $x++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 291 | 0 | $ll .= ~$bitmap[ $y * ( $line + $padding ) + $x ]; | |||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||
| 293 | 0 | $raw = $ll . $raw; | |||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if ( ( $w == 16 ) && ( $h == 16 ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$w == 16 and $h == 16
MC/DC0%0/2
$w == 16 and $h == 16
$w == 16
$h == 16
Truth table0%0/3
A and B
A= $w == 16B= $h == 16
| |||||||||||||||||||||||||||||||||
| 297 | 0 | return ie_icon16( $raw, $text, $encoding, $transport ); | |||||||||||||||||||||||||||||||
| 298 | ▶ | } elsif ( ( $w == 32 ) && ( $h == 32 ) ) { | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$w == 32 and $h == 32
MC/DC0%0/2
$w == 32 and $h == 32
$w == 32
$h == 32
Truth table0%0/3
A and B
A= $w == 32B= $h == 32
| |||||||||||||||||||||||||||||||||
| 299 | 0 | return ie_icon32( $raw, $text, $encoding, $transport ); | |||||||||||||||||||||||||||||||
| 300 | } else { | ||||||||||||||||||||||||||||||||
| 301 | 0 | return ie_picture( $raw, $w, $h, $text, $encoding, $transport ); | |||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||
| 303 | } # end sub ie_bmp | ||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||
| 305 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 306 | # NOKIA | ||||||||||||||||||||||||||||||||
| 307 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 308 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||
| 310 | =item B<smart_message(...)> | ||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||
| 312 | @messages = smart_message ( destination_port, user_data ) | ||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||
| 314 | Produce a Nokia Smart Messages with application port addressing scheme. | ||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||
| 316 | =cut | ||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||
| 318 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | sub smart_message { | ||||||||||||||||||||||||||||||
|
Subroutine
smart_message: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 320 | 0 | my ( $port, $data, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | unless ( defined($data) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 323 | 0 | $data = ''; | |||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | unless ( defined($transport) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 327 | 0 | $transport = TRANSPORT_ANY; | |||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if ( length($data) + 7 <= 140 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 331 | # Fit in single message & Short UDH | ||||||||||||||||||||||||||||||||
| 332 | 0 | return [ { udh => "\x06\x05\x04" . $port . "\x00\x00", ud => $data, coding => COD_8BIT, transport => $transport } ]; | |||||||||||||||||||||||||||||||
| 333 | } else { | ||||||||||||||||||||||||||||||||
| 334 | # Messages Chain | ||||||||||||||||||||||||||||||||
| 335 | 0 | my $udh = "\x0B\x05\x04" . $port . "\x00\x00\x00\x03"; # UDH with concatenation | |||||||||||||||||||||||||||||||
| 336 | 0 | my $refnum = int( rand(256) ); # Chain Reference Number | |||||||||||||||||||||||||||||||
| 337 | 0 | my $qty = int( length($data) / 128 ); # Messages in Chain | |||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | $qty++ if ( length($data) % 128 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if ( $qty > 255 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 342 | 0 | return __PACKAGE__->error("This doesn't fit anyway"); | |||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||
| 345 | 0 | $udh .= pack( 'C*', $refnum, $qty ); | |||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||
| 347 | # Making Messages | ||||||||||||||||||||||||||||||||
| 348 | 0 | my $result = []; | |||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | for ( my $i = 1 ; $i <= $qty ; $i++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 350 | 0 | push( @{$result}, { udh => $udh . pack( 'C', $i ), ud => substr( $data, 128 * ( $i - 1 ), 128 ), coding => COD_8BIT, transport => $transport } ); | |||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||
| 353 | 0 | return $result; | |||||||||||||||||||||||||||||||
| 354 | } ## end else [ if ( length($data) + 7... | ||||||||||||||||||||||||||||||||
| 355 | } # end sub smart_message | ||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||
| 357 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||
| 359 | =item B<smart_push_wap(...)> | ||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||
| 361 | http://www.devx.com/xml/Article/16754/1954?pf=true | ||||||||||||||||||||||||||||||||
| 362 | http://www.w3.org/TR/wbxml/ | ||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||
| 364 | =cut | ||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||
| 366 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | sub smart_push_wap { | ||||||||||||||||||||||||||||||
|
Subroutine
smart_push_wap: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 368 | 0 | my ( $url, $title, $encoding, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | unless ( defined($title) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 371 | 0 | $title = ''; | |||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | if ( defined($encoding) and ( $title =~ m/[^\x00-\x7f]/ ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $encoding and $title =~ /[^\x00-\x7f]/
MC/DC0%0/2
defined $encoding and $title =~ /[^\x00-\x7f]/
defined $encoding
$title =~ /[^\x00-\x7f]/
Truth table0%0/3
A and B
A= defined $encodingB= $title =~ /[^\x00-\x7f]/
| |||||||||||||||||||||||||||||||||
| 375 | 0 | $title = str_recode( $title, $encoding, to_enc => XML_ENCODING ); | |||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||
| 378 | 0 | $url =~ s/^\w+:\/\///; | |||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||
| 380 | 0 | my $data = "\xDC" . # Push ID | |||||||||||||||||||||||||||||||
| 381 | "\x06" . # Push PDU | ||||||||||||||||||||||||||||||||
| 382 | "\x01\xAE" . # Content-Type: application/vnd.wap.sic | ||||||||||||||||||||||||||||||||
| 383 | "\x02\x05\x6A" . # version / si / utf-8 | ||||||||||||||||||||||||||||||||
| 384 | "\x00\x45\xC6" . # string / si / indication | ||||||||||||||||||||||||||||||||
| 385 | "\x0C\x03" . $url . "\x00" . # http:// zstring <url> \0 | ||||||||||||||||||||||||||||||||
| 386 | "\x01" . # Indication | ||||||||||||||||||||||||||||||||
| 387 | "\x03" . $title . "\x00" . # zstring <title> \0 | ||||||||||||||||||||||||||||||||
| 388 | "\x01\x01"; # Indication / SI | ||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||
| 390 | 0 | return smart_message( PORT_PUSHWAP, $data, $transport ); | |||||||||||||||||||||||||||||||
| 391 | } ## end sub smart_push_wap | ||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||
| 393 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||
| 395 | =item B<smart_bmp(...)> | ||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||
| 397 | =cut | ||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||
| 399 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | sub smart_bmp { | ||||||||||||||||||||||||||||||
|
Subroutine
smart_bmp: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 401 | 0 | my ($bmp) = @_; | |||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if ( substr( $bmp, 0, 2 ) ne 'BM' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 404 | 0 | return __PACKAGE__->error("Not a BMP"); | |||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if ( unpack( 'L', substr( $bmp, 30, 4 ) ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 408 | 0 | return __PACKAGE__->error("Compressed BMP"); | |||||||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | unless ( unpack( 'S', substr( $bmp, 28, 2 ) ) == 1 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 412 | 0 | return __PACKAGE__->error("Need 1bpp monochrome BMP"); | |||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||
| 415 | 0 | my $w = unpack( 'L', substr( $bmp, 18, 4 ) ); | |||||||||||||||||||||||||||||||
| 416 | 0 | my $h = unpack( 'L', substr( $bmp, 22, 4 ) ); | |||||||||||||||||||||||||||||||
| 417 | 0 | my $ofs = unpack( 'L', substr( $bmp, 10, 4 ) ); | |||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||
| 419 | 0 | my @bitmap = split( //, substr( $bmp, $ofs, length $bmp ) ); | |||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||
| 421 | 0 | my $line = int( $w / 8 ); | |||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | $line++ if ( $w % 8 ); # Line Width in bytes | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||
| 424 | 0 | my $padding = 0; | |||||||||||||||||||||||||||||||
| 425 | 0 | ▶ | $padding = 4 - $line % 4 if ( $line % 4 ); # Pad to 4x bytes | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||
| 427 | 0 | my $hdr = "\x00" . pack( 'C*', $w, $h ) . "\x01"; # OTA Bitmap Header | |||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||
| 429 | 0 | my $raw = ''; | |||||||||||||||||||||||||||||||
| 430 | 0 | ▶ | for ( my $y = 0 ; $y < $h ; $y++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 431 | 0 | my $ll = ''; | |||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | for ( my $x = 0 ; $x < $line ; $x++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 433 | 0 | $ll .= ~$bitmap[ $y * ( $line + $padding ) + $x ]; | |||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||
| 435 | 0 | $raw = $ll . $raw; | |||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||
| 438 | 0 | return $hdr . $raw; | |||||||||||||||||||||||||||||||
| 439 | } # end sub smart_bmp | ||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||
| 441 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||
| 443 | =item B<smart_logo(...)> | ||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||
| 445 | http://www.cisco.com/univercd/cc/td/doc/product/software/ios124/124cg/hmwg_c/mwgfmcc.htm | ||||||||||||||||||||||||||||||||
| 446 | http://users.zipworld.com.au/~rmills/MCCandMNCValues.htm | ||||||||||||||||||||||||||||||||
| 447 | http://www.surfio.de/info/mcc_mnc/mcc_mnc_liste_5.html | ||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||
| 449 | MCC MNC Land ISO Vorwahl Netzbetreiber | ||||||||||||||||||||||||||||||||
| 450 | 255 01 Ukraine UA 380 Ukrainian Mobile Comms (UMC) | ||||||||||||||||||||||||||||||||
| 451 | 255 02 Ukraine UA 380 Ukrainian Radio Systems (WellCOM) | ||||||||||||||||||||||||||||||||
| 452 | 255 03 Ukraine UA 380 Kyivstar GSM | ||||||||||||||||||||||||||||||||
| 453 | 255 05 Ukraine UA 380 Golden Telecom LLC | ||||||||||||||||||||||||||||||||
| 454 | 255 06 Ukraine UA 380 Astelit (life:)) | ||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||
| 456 | =cut | ||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||
| 458 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | sub smart_logo { | ||||||||||||||||||||||||||||||
|
Subroutine
smart_logo: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 460 | 0 | my ( $bmp, $mcc, $mnc, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||
| 462 | 0 | my $data = smart_bmp($bmp); | |||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | unless ($data) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 464 | 0 | return $data; | |||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||
| 467 | 0 | $data = "\x30" . str2bcd($mcc) . str2bcd($mnc) . "\x0A" . $data; | |||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||
| 469 | 0 | return smart_message( PORT_LOGO, $data, $transport ); | |||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||
| 472 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||
| 474 | =item B<smart_card(...)> | ||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||
| 476 | =cut | ||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||
| 478 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | sub smart_card { | ||||||||||||||||||||||||||||||
|
Subroutine
smart_card: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 480 | 0 | my ( $bmp, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||
| 482 | 0 | my $bitmap = smart_bmp($bmp); | |||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | unless ($bitmap) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 484 | 0 | return $bitmap; | |||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||
| 487 | 0 | my $size = int( length($bitmap) ); | |||||||||||||||||||||||||||||||
| 488 | 0 | my $data = "\x30\x02" . pack( 'C*', int( $size / 256 ), $size % 256 ) . $bitmap; | |||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||
| 490 | 0 | return smart_message( PORT_ITEMS, $data, $transport ); | |||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||
| 493 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||
| 495 | =item B<smart_cli(...)> | ||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||
| 497 | =cut | ||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||
| 499 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | sub smart_cli { | ||||||||||||||||||||||||||||||
|
Subroutine
smart_cli: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 501 | 0 | my ( $bmp, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||
| 503 | 0 | my $data = smart_bmp($bmp); | |||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | unless ($data) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 505 | 0 | return $data; | |||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||
| 508 | 0 | return smart_message( PORT_CLI, "\x30" . $data, $transport ); | |||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||
| 511 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||
| 513 | =item B<smart_ringtone(...)> | ||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||
| 515 | =cut | ||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||
| 517 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | sub smart_ringtone { | ||||||||||||||||||||||||||||||
|
Subroutine
smart_ringtone: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 519 | 0 | my ( $ringtone, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||
| 521 | 0 | return smart_message( PORT_RINGTONE, $ringtone, $transport ); | |||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||
| 524 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||
| 526 | =item B<smart_clear(...)> | ||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||
| 528 | Pure shamanism | ||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||
| 530 | =cut | ||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||
| 532 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | sub smart_clear { | ||||||||||||||||||||||||||||||
|
Subroutine
smart_clear: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 534 | 0 | my ($transport) = @_; | |||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | return [ { udh => "\x06\x05\x04\x15\x82\x00\x00", ud => "\x30\x00\x00\x00\x0A\x00\x00\x00\x01", coding => COD_8BIT, transport => defined($transport) ? $transport : TRANSPORT_ANY } ]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||
| 539 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 540 | # SIEMENS | ||||||||||||||||||||||||||||||||
| 541 | ######################################################################## | ||||||||||||||||||||||||||||||||
| 542 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||
| 544 | =item B<siemens_header(...)> | ||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||
| 546 | =cut | ||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||
| 548 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | sub siemens_header { | ||||||||||||||||||||||||||||||
|
Subroutine
siemens_header: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 550 | 0 | my ( $data_size, $reference_id, $packet_number, $number_of_packets, $object_size, $object_type, $object_name ) = @_; | |||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||
| 552 | 0 | my $result = '//SEO'; # "//Siemens Exchange Object" | |||||||||||||||||||||||||||||||
| 553 | 0 | $result .= pack( "C", SEO_VER ); # SEO Version, uchar | |||||||||||||||||||||||||||||||
| 554 | 0 | $result .= pack( "S", $data_size ); # Data Block Size, uint(2) | |||||||||||||||||||||||||||||||
| 555 | 0 | $result .= pack( "L", $reference_id ); # Reference ID, ulong(4) | |||||||||||||||||||||||||||||||
| 556 | 0 | $result .= pack( "S", $packet_number ); # This Packet Number, uint(2) | |||||||||||||||||||||||||||||||
| 557 | 0 | $result .= pack( "S", $number_of_packets ); # Total Packets, uint(2) | |||||||||||||||||||||||||||||||
| 558 | 0 | $result .= pack( "L", $object_size ); # ObjectSize, ulong(4) | |||||||||||||||||||||||||||||||
| 559 | 0 | $result .= pack( "C", length($object_type) ); # Pascal-string length, uchar | |||||||||||||||||||||||||||||||
| 560 | 0 | $result .= $object_type; # Object Type identifier ('bmp' or 'mid') | |||||||||||||||||||||||||||||||
| 561 | 0 | $result .= pack( "C", length($object_name) ); # Pascal-string length, uchar | |||||||||||||||||||||||||||||||
| 562 | 0 | $result .= $object_name; # Object Name | |||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||
| 564 | 0 | return $result; | |||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||
| 567 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||
| 569 | =item B<siemens_message(...)> | ||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||
| 571 | =cut | ||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||
| 573 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | sub siemens_message { | ||||||||||||||||||||||||||||||
|
Subroutine
siemens_message: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 575 | 0 | my ( $object, $object_type, $object_name, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||
| 577 | # Calculating Maximum DataSize | ||||||||||||||||||||||||||||||||
| 578 | 0 | my $data_size = SMS_SIZE - SEO_LEN - length($object_type) - length($object_name); | |||||||||||||||||||||||||||||||
| 579 | 0 | my $object_size = length($object); | |||||||||||||||||||||||||||||||
| 580 | 0 | my $full_size = $object_size; | |||||||||||||||||||||||||||||||
| 581 | 0 | my $number_of_packets = 1; | |||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | if ( $object_size > $data_size ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 584 | # [Zero]-Padding | ||||||||||||||||||||||||||||||||
| 585 | 0 | my $padding = ''; | |||||||||||||||||||||||||||||||
| 586 | 0 | my $padl = $data_size - ( $object_size % $data_size ); | |||||||||||||||||||||||||||||||
| 587 | 0 | $padding .= SEO_FILL x $padl; | |||||||||||||||||||||||||||||||
| 588 | 0 | $object = $object . $padding; | |||||||||||||||||||||||||||||||
| 589 | 0 | $full_size = length($object); | |||||||||||||||||||||||||||||||
| 590 | # Number of Chunks in Stream | ||||||||||||||||||||||||||||||||
| 591 | 0 | $number_of_packets = $full_size / $data_size; | |||||||||||||||||||||||||||||||
| 592 | } else { | ||||||||||||||||||||||||||||||||
| 593 | 0 | $data_size = length($object); | |||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||
| 596 | # Unique Reference ID | ||||||||||||||||||||||||||||||||
| 597 | 0 | my $reference_id = rand(0xFFFFFFFF); | |||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | unless ( defined($transport) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 600 | 0 | $transport = TRANSPORT_ANY; | |||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||
| 603 | # Make SMSes | ||||||||||||||||||||||||||||||||
| 604 | 0 | my $stream = []; | |||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | for ( my $packet_number = 1 ; $packet_number <= $number_of_packets ; $packet_number++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 606 | 0 | my $sms = ''; | |||||||||||||||||||||||||||||||
| 607 | 0 | $sms .= siemens_header( $data_size, $reference_id, $packet_number, $number_of_packets, $object_size, $object_type, $object_name ); | |||||||||||||||||||||||||||||||
| 608 | 0 | $sms .= substr( $object, ( $packet_number - 1 ) * $data_size, $data_size ); | |||||||||||||||||||||||||||||||
| 609 | 0 | push( @{$stream}, { udh => '', ud => $sms, coding => COD_8BIT, transport => $transport } ); | |||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||
| 612 | 0 | return $stream; | |||||||||||||||||||||||||||||||
| 613 | } # end sub siemens_message | ||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||
| 615 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||
| 617 | =item B<siemens(...)> | ||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||
| 619 | @smses = siemens ( $data [, $name] ) | ||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||
| 621 | Produce a SEO messages stream. $data can contain MIDI or BMP data. | ||||||||||||||||||||||||||||||||
| 622 | $name looks like old plain filename. Can be omitted. | ||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||
| 624 | =cut | ||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||
| 626 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 627 | 0 | ▶ | sub siemens { | ||||||||||||||||||||||||||||||
|
Subroutine
siemens: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 628 | 0 | my ( $object, $o_name, $transport ) = @_; | |||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | unless ($object) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 631 | 0 | return $object; | |||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||
| 634 | 0 | my $sig = substr( $object, 0, 2 ); | |||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||
| 636 | 0 | my $o_type = $SIGN{$sig}; | |||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | unless ($o_type) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 638 | 0 | return $o_type; | |||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||
| 641 | 0 | ▶ | unless ( defined($o_name) and ( $o_name ne '' ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $o_name and $o_name ne ""
MC/DC0%0/2
defined $o_name and $o_name ne ""
defined $o_name
$o_name ne ""
Truth table0%0/3
A and B
A= defined $o_nameB= $o_name ne ""
| |||||||||||||||||||||||||||||||||
| 642 | 0 | $o_name = 'Nib' . rand(1000) . '.' . $o_type; | |||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||
| 645 | 0 | return siemens_message( $object, $o_type, $o_name, $transport ); | |||||||||||||||||||||||||||||||
| 646 | } ## end sub siemens | ||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||
| 648 | #*********************************************************************** | ||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||
| 650 | =item B<split_text()> - ???????? | ||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||
| 652 | Paramters: text string (utf-8), SMS coding | ||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||
| 654 | Returns: array of SMS hashrefs | ||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||
| 656 | This method implements text SMS splitting to send concatenated messages. | ||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||
| 658 | =cut | ||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||
| 660 | #----------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | sub split_text { | ||||||||||||||||||||||||||||||
|
Subroutine
split_text: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||
| 664 | 0 | my ( $text, $coding ) = @_; | |||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||
| 666 | 0 | $text = str_decode($text); | |||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||
| 668 | 0 | my @ret = (); | |||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | if ( $coding eq COD_7BIT ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | if ( length($text) <= 160 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 673 | 0 | push @ret, { udh => undef, ud => $text, coding => COD_7BIT }; | |||||||||||||||||||||||||||||||
| 674 | } else { | ||||||||||||||||||||||||||||||||
| 675 | 0 | my $udh = "\x05\x00\x03"; | |||||||||||||||||||||||||||||||
| 676 | 0 | my $refnum = int( rand(256) ); | |||||||||||||||||||||||||||||||
| 677 | 0 | my $qty = ceil( length($text) / 153 ); | |||||||||||||||||||||||||||||||
| 678 | 0 | $udh .= pack( 'C*', $refnum, $qty ); | |||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||
| 680 | 0 | ▶ | for ( my $i = 1 ; $i <= $qty ; $i++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 681 | 0 | push @ret, { udh => $udh . pack( 'C', $i ), ud => substr( $text, 153 * ( $i - 1 ), 153 ), coding => COD_7BIT }; | |||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||
| 685 | } elsif ( $coding eq COD_UNICODE ) { | ||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||
| 687 | 0 | $text = str_encode($text); | |||||||||||||||||||||||||||||||
| 688 | 0 | $text = str_decode( $text, "UTF-16BE" ); | |||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||
| 690 | 0 | ▶ | if ( length($text) <= 140 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 691 | 0 | push @ret, ( { udh => undef, ud => $text, coding => COD_UNICODE } ); | |||||||||||||||||||||||||||||||
| 692 | } else { | ||||||||||||||||||||||||||||||||
| 693 | 0 | my $udh = "\x05\x00\x03"; | |||||||||||||||||||||||||||||||
| 694 | 0 | my $refnum = int( rand(256) ); | |||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||
| 696 | 0 | my $qty = ceil( length($text) / 134 ); | |||||||||||||||||||||||||||||||
| 697 | 0 | $udh .= pack( 'C*', $refnum, $qty ); | |||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | for ( my $i = 1 ; $i <= $qty ; $i++ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 700 | 0 | my $part = substr( $text, 134 * ( $i - 1 ), 134 ); | |||||||||||||||||||||||||||||||
| 701 | 0 | $part = str_encode( $part, "UTF-16BE" ); | |||||||||||||||||||||||||||||||
| 702 | 0 | $part = str_decode( $part, "UTF-16BE" ); | |||||||||||||||||||||||||||||||
| 703 | 0 | push @ret, { udh => $udh . pack( 'C', $i ), ud => $part, coding => COD_UNICODE }; | |||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||
| 707 | } ## end elsif ( $coding eq COD_UNICODE) | ||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||
| 709 | 0 | return @ret; | |||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||
| 711 | } # end sub smart_message | ||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||
| 713 | #************************************************************************** | ||||||||||||||||||||||||||||||||
| 714 | 2 | 1; | |||||||||||||||||||||||||||||||
| 715 | __END__ | ||||||||||||||||||||||||||||||||