Permalink
Browse files

Applied my current perltidy style

  • Loading branch information...
Cosimo Streppone
Cosimo Streppone committed Mar 8, 2012
1 parent 1928e89 commit a5d045d54120a6713c1a63dc18efaa7c64300f69
@@ -22,16 +22,16 @@ use Device::Gsm::Sms::Token;
# returns success/failure of decoding
# if all ok, removes token from message
sub decode {
- my($self, $rMessage) = @_;
- my $ok = 0;
+ my ($self, $rMessage) = @_;
+ my $ok = 0;
- $self->data( hex substr($$rMessage, 0, 2) );
- $self->state( Sms::Token::DECODED );
+ $self->data(hex substr($$rMessage, 0, 2));
+ $self->state(Sms::Token::DECODED);
- # Remove DCS from message
- $$rMessage = substr( $$rMessage, 2 );
+ # Remove DCS from message
+ $$rMessage = substr($$rMessage, 2);
- return 1;
+ return 1;
}
#
@@ -41,16 +41,16 @@ sub decode {
# or undef value in case of errors
#
sub encode {
- my $self = shift;
+ my $self = shift;
- # Take supplied data (optional) or object internal data
- my $data = shift;
- if( ! defined $data || $data eq '' ) {
- $data = $self->data();
- $data ||= '00';
- }
+ # Take supplied data (optional) or object internal data
+ my $data = shift;
+ if (!defined $data || $data eq '') {
+ $data = $self->data();
+ $data ||= '00';
+ }
- return $data;
+ return $data;
}
1;
@@ -25,33 +25,39 @@ use Device::Gsm::Sms::Token;
# returns success/failure of decoding
# if all ok, removes DT from message
sub decode {
- my($self, $rMessage) = @_;
- my $ok = 0;
+ my ($self, $rMessage) = @_;
+ my $ok = 0;
- my @ts = split //, substr( $$rMessage, 0, 14 );
+ my @ts = split //, substr($$rMessage, 0, 14);
- $self->set( year => $ts [1] . $ts [0] );
- $self->set( month => $ts [3] . $ts [2] );
- $self->set( day => $ts [5] . $ts [4] );
- $self->set( hour => $ts [7] . $ts [6] );
- $self->set( minute => $ts [9] . $ts [8] );
- $self->set( second => $ts[11] . $ts[10] );
- $self->set( timezone => $ts[13] . $ts[12] );
+ $self->set(year => $ts[1] . $ts[0]);
+ $self->set(month => $ts[3] . $ts[2]);
+ $self->set(day => $ts[5] . $ts[4]);
+ $self->set(hour => $ts[7] . $ts[6]);
+ $self->set(minute => $ts[9] . $ts[8]);
+ $self->set(second => $ts[11] . $ts[10]);
+ $self->set(timezone => $ts[13] . $ts[12]);
- # Store also timestamp as convenient format
- $self->set( 'date' => $self->get('day').'/'.$self->get('month').'/'.$self->get('year') );
- $self->set( 'time' => $self->get('hour').':'.$self->get('minute').':'.$self->get('second') );
+ # Store also timestamp as convenient format
+ $self->set('date' => $self->get('day') . '/'
+ . $self->get('month') . '/'
+ . $self->get('year'));
+ $self->set('time' => $self->get('hour') . ':'
+ . $self->get('minute') . ':'
+ . $self->get('second'));
- # TODO: add timezone decoding ...
- $self->data( $self->get('date').' '.$self->get('time').' '.$self->get('timezone') );
+ # TODO: add timezone decoding ...
+ $self->data($self->get('date') . ' '
+ . $self->get('time') . ' '
+ . $self->get('timezone'));
- # Signal token as correctly decoded (?)
- $self->state( Sms::Token::DECODED );
+ # Signal token as correctly decoded (?)
+ $self->state(Sms::Token::DECODED);
- # Remove DT info from message
- $$rMessage = substr( $$rMessage, 14 );
+ # Remove DT info from message
+ $$rMessage = substr($$rMessage, 14);
- return 1;
+ return 1;
}
#
@@ -61,7 +67,7 @@ sub decode {
# or undef value in case of errors
#
sub encode {
- return '99211332959500';
+ return '99211332959500';
}
1;
@@ -22,16 +22,16 @@ use Device::Gsm::Sms::Token;
# returns success/failure of decoding
# if all ok, removes token from message
sub decode {
- my($self, $rMessage) = @_;
- my $ok = 0;
+ my ($self, $rMessage) = @_;
+ my $ok = 0;
- $self->data( hex substr($$rMessage, 0, 2) );
- $self->state( Sms::Token::DECODED );
+ $self->data(hex substr($$rMessage, 0, 2));
+ $self->state(Sms::Token::DECODED);
- # Remove MR from message
- $$rMessage = substr( $$rMessage, 2 );
+ # Remove MR from message
+ $$rMessage = substr($$rMessage, 2);
- return 1;
+ return 1;
}
#
@@ -41,16 +41,16 @@ sub decode {
# or undef value in case of errors
#
sub encode {
- my $self = shift;
+ my $self = shift;
- # Take supplied data (optional) or object internal data
- my $data = shift;
- if( ! defined $data || $data eq '' ) {
- $data = $self->data();
- $data ||= '00';
- }
+ # Take supplied data (optional) or object internal data
+ my $data = shift;
+ if (!defined $data || $data eq '') {
+ $data = $self->data();
+ $data ||= '00';
+ }
- return $data;
+ return $data;
}
1;
@@ -22,33 +22,32 @@ use Device::Gsm::Sms::Token;
# returns success/failure of decoding
# if all ok, removes OA from message
sub decode {
- my($self, $rMessage) = @_;
- my $ok = 0;
+ my ($self, $rMessage) = @_;
+ my $ok = 0;
- # Detect originating address length
- my $oa_len = hex( substr $$rMessage, 0, 2 );
+ # Detect originating address length
+ my $oa_len = hex(substr $$rMessage, 0, 2);
- # Get number type (0x91=international, 0x81=local)
- my $oa_type = substr( $$rMessage, 2, 2 );
+ # Get number type (0x91=international, 0x81=local)
+ my $oa_type = substr($$rMessage, 2, 2);
# Number of octets to remove from message
- my $oa_octets = (($oa_len + 1) >> 1) << 1;
+ my $oa_octets = (($oa_len + 1) >> 1) << 1;
- # Get address
+ # Get address
my $addr = Device::Gsm::Pdu::decode_address(
- substr($$rMessage, 0, 4 + $oa_octets)
- );
+ substr($$rMessage, 0, 4 + $oa_octets));
- $self->set('length' => $oa_len);
- $self->set('type' => $oa_type);
- $self->set('address' => $addr);
- $self->data( $oa_len, $oa_type, $addr );
- $self->state( Sms::Token::DECODED );
+ $self->set('length' => $oa_len);
+ $self->set('type' => $oa_type);
+ $self->set('address' => $addr);
+ $self->data($oa_len, $oa_type, $addr);
+ $self->state(Sms::Token::DECODED);
- # Remove OA from message
- $$rMessage = substr( $$rMessage, 4 + $oa_octets );
+ # Remove OA from message
+ $$rMessage = substr($$rMessage, 4 + $oa_octets);
- return 1;
+ return 1;
}
#
@@ -57,23 +56,23 @@ sub decode {
# encodes originating address (OA)
#
sub encode {
- my $self = shift;
- my $oa_len = $self->get('length');
+ my $self = shift;
+ my $oa_len = $self->get('length');
- # XXX TO BE COMPLETED...
- return $oa_len;
+ # XXX TO BE COMPLETED...
+ return $oa_len;
}
sub toString {
- my $self = shift;
- my $str = $self->get('address');
+ my $self = shift;
+ my $str = $self->get('address');
+
# Prepend + to number if international
- if( $str !~ /^\s*\+/ && $self->get('type') eq '91' )
- {
+ if ($str !~ /^\s*\+/ && $self->get('type') eq '91') {
$str = '+' . $str;
}
- return $str;
+ return $str;
}
1;
@@ -22,26 +22,26 @@ use Device::Gsm::Sms::Token;
# returns success/failure of decoding
# if all ok, removes PDUTYPE from message
sub decode {
- my($self, $rMessage) = @_;
- my $ok = 0;
-
- $self->data( substr($$rMessage, 0, 2) );
-
- # Update PDU type flags into token object
- $self->set( 'pdutype', hex(substr($$rMessage,0,2)) );
- $self->set( 'MTI', $self->MTI() );
- $self->set( 'MMS', $self->MMS() );
- $self->set( 'RD', $self->RD() );
- $self->set( 'VPF', $self->VPF() );
- $self->set( 'SRR', $self->SRR() );
- $self->set( 'SRI', $self->SRI() );
- $self->set( 'UDHI',$self->UDHI());
- $self->set( 'RP', $self->RP() );
-
- # Remove PDU TYPE from message
- $$rMessage = substr($$rMessage, 2);
-
- return 1;
+ my ($self, $rMessage) = @_;
+ my $ok = 0;
+
+ $self->data(substr($$rMessage, 0, 2));
+
+ # Update PDU type flags into token object
+ $self->set('pdutype', hex(substr($$rMessage, 0, 2)));
+ $self->set('MTI', $self->MTI());
+ $self->set('MMS', $self->MMS());
+ $self->set('RD', $self->RD());
+ $self->set('VPF', $self->VPF());
+ $self->set('SRR', $self->SRR());
+ $self->set('SRI', $self->SRI());
+ $self->set('UDHI', $self->UDHI());
+ $self->set('RP', $self->RP());
+
+ # Remove PDU TYPE from message
+ $$rMessage = substr($$rMessage, 2);
+
+ return 1;
}
#
@@ -51,58 +51,60 @@ sub decode {
# or undef value in case of errors
#
sub encode {
- my $self = shift;
+ my $self = shift;
- # Take supplied data (optional) or object internal data
- my $data = shift;
- if( ! defined $data || $data eq '' ) {
- $data = $self->data();
- }
+ # Take supplied data (optional) or object internal data
+ my $data = shift;
+ if (!defined $data || $data eq '') {
+ $data = $self->data();
+ }
- return $data;
+ return $data;
}
#--------------------------------------------
# Bit component flags
-sub RP { # REPLY PATH PARAMETER SET
- my $self = shift;
- ( $self->get('pdutype') & 0x80 ) >> 7;
+sub RP { # REPLY PATH PARAMETER SET
+ my $self = shift;
+ ($self->get('pdutype') & 0x80) >> 7;
}
-sub UDHI { # USER DATA HEADER PRESENT
- my $self = shift;
- ( $self->get('pdutype') & 0x40 ) >> 6;
+sub UDHI { # USER DATA HEADER PRESENT
+ my $self = shift;
+ ($self->get('pdutype') & 0x40) >> 6;
}
-sub SRR { # STATUS REPORT REQUESTED
- my $self = shift;
- ( $self->get('pdutype') & 0x20 ) >> 5;
+sub SRR { # STATUS REPORT REQUESTED
+ my $self = shift;
+ ($self->get('pdutype') & 0x20) >> 5;
}
-sub SRI { # STATUS REPORT WILL BE RETURNED
- my $self = shift;
- ( $self->get('pdutype') & 0x20 ) >> 5;
+sub SRI { # STATUS REPORT WILL BE RETURNED
+ my $self = shift;
+ ($self->get('pdutype') & 0x20) >> 5;
}
-sub VPF { # VALIDITY PERIOD FLAG 0=not present, 1=reserved, 2=integer, 3=semioctet
- my $self = shift;
- ( $self->get('pdutype') & 0x18 ) >> 3;
+sub VPF
+{ # VALIDITY PERIOD FLAG 0=not present, 1=reserved, 2=integer, 3=semioctet
+ my $self = shift;
+ ($self->get('pdutype') & 0x18) >> 3;
}
-sub MMS { # MORE MESSAGES WAITING AT SMS-C
- my $self = shift;
- ( $self->get('pdutype') & 0x04 ) >> 2;
+sub MMS { # MORE MESSAGES WAITING AT SMS-C
+ my $self = shift;
+ ($self->get('pdutype') & 0x04) >> 2;
}
-sub RD { # ... allow repeated sending (REJECT DUPLICATES)
- my $self = shift;
- ( $self->get('pdutype') & 0x04 ) >> 2;
+sub RD { # ... allow repeated sending (REJECT DUPLICATES)
+ my $self = shift;
+ ($self->get('pdutype') & 0x04) >> 2;
}
-sub MTI { # TYPE OF SMS (0x00=SMS-DELIVER, 0x01=SMS-SUBMIT, 0x10=SMS-STATUS/COMMAND, 0x11=RESERVED
- my $self = shift;
- $self->get('pdutype') & 0x03;
+sub MTI
+{ # TYPE OF SMS (0x00=SMS-DELIVER, 0x01=SMS-SUBMIT, 0x10=SMS-STATUS/COMMAND, 0x11=RESERVED
+ my $self = shift;
+ $self->get('pdutype') & 0x03;
}
1;
Oops, something went wrong.

0 comments on commit a5d045d

Please sign in to comment.