Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
126:1f90756250fb
Parent:
123:1d395b5a4cad
Child:
132:05cd37f7e007
--- a/call_box.cpp	Wed May 13 21:18:12 2015 +0000
+++ b/call_box.cpp	Wed May 20 19:50:31 2015 +0000
@@ -65,7 +65,7 @@
 }
 
 Call_Box::~Call_Box( void ){
-    if ( sip != NULL ) delete ( sip );
+    if ( sip not_eq NULL ) delete ( sip );
     cb_delete_counter++;
 }
 
@@ -84,34 +84,40 @@
     overflow_times = 0;
 }
 
-void Call_Box::registry ( void )
+int Call_Box::registry ( void )
 {
     if ( drop_registry_pkg )
     {
         send_msg ("[%d] Dropando registry pck", this->ext );
-        return;
+        return -5;
     }    
     
-    if ( this->sip != NULL )
+    if ( this -> sip not_eq NULL )
     {
-        if ( sip -> registry () > 0 ) 
+        int return_value = sip -> registry ();
+        
+        if ( return_value > 0 ) 
         {
             reset_elapsed_time ();
-
+            
+            if ( debug_aging ) send_msg ( "[%d] Registered", this->ext );
+            
+            return ( return_value );
         }
-        if ( debug_aging ) send_msg ( "[%d] Registered", this->ext );
-    
     } else {
         debug_msg ("[%d] Eu definitivamente nao deveria estar aqui!!!", this->ext );
         deleted_sip++;
+        return ( -3 );
     }
+    
+    return ( 0 );
 }
 
 VZ_call * Call_Box::invite ( void )
 {
     VZ_call * call = NULL;
     
-    if ( this->sip != NULL )
+    if ( this->sip not_eq NULL )
     {
         call = sip->invite ();
     } else {   
@@ -142,7 +148,7 @@
         
         return ( -3 );
     } else {
-        if ( status == cb_on_call || status == cb_idle )
+        if ( status == cb_on_call or status == cb_idle )
         {
             return ( sip -> listen_SIP_server () );
         } else return ( 0 );
@@ -176,7 +182,7 @@
 {
     debug_msg ("[%d] reset_sip", this->ext );
     
-    if ( this->sip != NULL )
+    if ( this->sip not_eq NULL )
     {
          delete ( this->sip );
          debug_msg ("[%d] deletei", this->ext );
@@ -192,7 +198,7 @@
 
 void Call_Box::set_sip_status ( const uint8_t new_sip_status )
 {
-    if ( this->sip != NULL )
+    if ( this->sip not_eq NULL )
     {
         this -> sip -> sip_set_status ( new_sip_status );
     } else 
@@ -232,7 +238,7 @@
     return sip -> udp_incomming_pkg ();
 }
 
-void Call_Box::reset_cb_status ( void ) { if( sip != NULL ) sip->reset_call(); }
+void Call_Box::reset_cb_status ( void ) { if ( sip not_eq NULL ) sip->reset_call(); }
 
 int Call_Box::get_sip_ext ( void ) { return this -> sip->get_ext (); }
 
@@ -241,16 +247,14 @@
 int Call_Box::get_timer ( void )
 {
     int now = t.read ();
-    
-    if ( now >= 30 || now < 0 ) 
-    //if ( now >= 1500 || now < 0 ) 
+
+    if ( now >= 1500 or now < 0 ) 
     {        
         this -> t.stop ();
         this -> t.reset ();
         this -> t.start ();
         overflow = true;
-        //if ( overflow_times != 0xff ) overflow_times++;
-        if ( overflow_times != 0x05 ) overflow_times++;
+        if ( overflow_times not_eq 0xfe ) overflow_times++;
     }
     
     return ( now );
@@ -258,7 +262,7 @@
 
 int Call_Box::get_rtp_port ( void )
 {
-    if ( this -> sip != NULL )
+    if ( this -> sip not_eq NULL )
     {
         return this -> sip -> get_sip_rtp_port ();
     } else {
@@ -272,7 +276,7 @@
 
 void Call_Box::set_rtp_port ( const int new_rtp_port )
 {
-    if ( this->sip != NULL )
+    if ( this->sip not_eq NULL )
     {
         this->sip->set_sip_rtp_port( new_rtp_port );
     }else{
@@ -373,7 +377,7 @@
     
     this->status = cb_idle;
     
-    if ( sip != NULL ) {
+    if ( sip not_eq NULL ) {
         sip -> sip_set_status ( sip_idle );
     } else {
         if( debug_cb ) debug_msg("[%d] Sip equals NULL o.O", this->ext );
@@ -385,7 +389,7 @@
     
     if ( send_bye_to_ast )
     {
-        if ( timeslice != 0 ) send_bye ();
+        if ( timeslice not_eq 0 ) send_bye ();
     }
     
     reset_cb_status ();
@@ -414,7 +418,9 @@
 
 uint8_t Call_Box::msg_id_update ( void )
 {
-    this->msg_id = ( ( ( this->msg_id + 1 ) & ~BIT7 ) > 0x10 ) ? ( ( this->msg_id + 1 ) & ~BIT7 )  : 0x11;
+    uint8_t update = ( msg_id + 1 ) bitand ( uint8_t ) compl BIT7;
+    
+    this->msg_id = ( update > 0x10 ) ? update : 0x11;
     
     return this->msg_id;
 }
@@ -441,7 +447,7 @@
 
 int Call_Box::retry_send_invite_pkg_to_ast ( void )
 {   
-    if ( this -> sip != NULL )
+    if ( this -> sip not_eq NULL )
     {
         invite_try_number++;
         return (  sip -> retry_send_last_invite_pkg_to_ast () );
@@ -456,7 +462,7 @@
 
 int Call_Box::sip_print_yourself ( void )
 {
-    if ( this -> sip != NULL )
+    if ( this -> sip not_eq NULL )
     {
         return sip -> print_yourself ();
     } else {