Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Revision:
135:2f4290590e51
Parent:
132:05cd37f7e007
--- a/call_box.cpp	Tue Sep 01 19:34:34 2015 +0000
+++ b/call_box.cpp	Thu Sep 10 20:11:35 2015 +0000
@@ -2,8 +2,8 @@
 
 Call_Box::Call_Box( const int ext, const int port )
 {
-    this->ext = ext;
-    this->port = port;
+    this -> ext = ext;
+    this -> port = port;
     
     t.start ();
     msg_id = 0x10;
@@ -30,6 +30,8 @@
     overflow = false;
     overflow_times = 0;
     invite_counter = 0;
+    
+    pair = NULL;
 }
 
 int Call_Box::get_status ( void ) { return this->status; }
@@ -157,24 +159,6 @@
     }
 }
 
-void Call_Box::reset_sip ( void )
-{
-    vz_debug ("[%d] reset_sip", this->ext );
-    
-    if ( this->sip not_eq NULL )
-    {
-         delete ( this->sip );
-         vz_debug ("[%d] deletei", this->ext );
-    }
-    
-    this->sip = new Sip ( ext, ext + shift_port );
-    vz_debug ( "[%d ]sobrescrevi", this->ext );
-    
-    deleted_sip++;
-    
-    if ( sip == NULL ) memory_is_over = true;
-}
-
 void Call_Box::set_sip_status ( const uint8_t new_sip_status )
 {
     if ( this->sip not_eq NULL )
@@ -206,18 +190,13 @@
 
 void Call_Box::set_bye_response_ok ( void ) { this->bye_response = true; }
 
-void Call_Box::set_bye_response_pending ( void ) { this->bye_response = false; }
-
-bool Call_Box::get_bye_response( void ) { return( this->bye_response ); }
-
-
 int Call_Box::get_sip_socket_fd ( void ) { return ( sip_socket_fd ); }
 
 int Call_Box::sip_udp_incomming_pkg ( void ) {
     return sip -> udp_incomming_pkg ();
 }
 
-void Call_Box::reset_cb_status ( void ) { if ( sip not_eq 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 (); }
 
@@ -281,8 +260,6 @@
     return ( rtp_timer.read () > RTP_REQUEST_PORT_TIMEOUT ) ? true : false;  
 }
 
-int Call_Box::get_rtp_timer ( void ) { return ( rtp_timer.read () ); }
-
 int Call_Box::print_yourself ( void )
 {   
     vz_printf ("\r\n");
@@ -335,9 +312,9 @@
  
     invite_timer.start ();
     
-    this->timeslice = timeslice;
+    this -> timeslice = timeslice;
     
-    this->status = cb_ringing;
+    this -> status = cb_ringing;
     
     set_invite_response_pending ();            
     
@@ -348,7 +325,8 @@
     return 0;    
 }
 
-int Call_Box::call_end ( const bool send_bye_to_ast )
+int 
+Call_Box::call_end ( const bool send_bye_to_ast )
 {
     uint8_t timeslice = this -> timeslice;
     
@@ -359,7 +337,7 @@
     if ( sip not_eq NULL ) {
         sip -> sip_set_status ( sip_idle );
     } else {
-        if( debug_cb ) vz_debug ("[%d] Sip equals NULL o.O", this -> ext );
+        if( debug_cb ) vz_debug ( "[%d] Sip equals NULL o.O", this -> ext );
     }
     
     set_rtp_port ( 0 );
@@ -381,9 +359,34 @@
     
     msg_id_update ();
     
+    reset_elapsed_time ();
+    
+    if ( pair not_eq NULL ) pair -> reset_elapsed_time ();
+    
     return timeslice;
 }
 
+Call_Box * Call_Box::get_pair_cbx ( void ) { return ( this -> pair ); }
+
+int 
+Call_Box::set_pair_cbx ( Call_Box * new_cbx )
+{
+    int ret = 0;
+    
+    if ( new_cbx not_eq NULL )
+    {
+        if ( pair not_eq NULL ) ret = -3;
+    
+        else ret = 0;
+        
+        pair = new_cbx;
+    } else { 
+        ret = -1; 
+    }
+    
+    return ( ret );
+}
+
 int Call_Box::call_confirmed ( void )
 {
     set_invite_response_pending ();
@@ -399,9 +402,9 @@
 {
     uint8_t update = ( msg_id + 1 ) bitand ( uint8_t ) compl BIT7;
     
-    this->msg_id = ( update > 0x10 ) ? update : 0x11;
+    this -> msg_id = ( update > 0x10 ) ? update : 0x11;
     
-    return this->msg_id;
+    return this -> msg_id;
 }
 
 void Call_Box::call_config ( void )