Logo Search packages:      
Sourcecode: capisuite version File versions  Download package

void Connection::disconnect_b3_ind ( _cmsg &  message  )  throw (CapiError,CapiWrongState) [protected]

called when we get DISCONNECT_B3_IND from CAPI

This method will also send a response to Capi and stop_file_transmission and stop_file_reception(). It will call CallInterface::callDisconnectedLogical() and initiate termination of physical connection.

Parameters:
message the received DISCONNECT_B3_IND message
Exceptions:
CapiError Thrown when an invalid message is received
CapiWrongState Thrown when the message is received unexpected (i.e. in a wrong ncci_state)

Definition at line 445 of file connection.cpp.

References buffers_used, call_if, CallInterface::callDisconnectedLogical(), capi, debug, debug_level, Capi::disconnect_b3_resp(), disconnect_cause_b3, Capi::disconnect_req(), error, fax_info, FAXG3, Connection::fax_info_t::format, Connection::fax_info_t::hiRes, keepPhysicalConnection, CapiMsgError::message(), N0, N1, N2, N3, N4, N5, NACT, ncci, ncci_state, P5, Connection::fax_info_t::pages, plci, plci_state, prefix(), Connection::fax_info_t::rate, send_mutex, service, Connection::fax_info_t::stationID, stop_file_reception(), and stop_file_transmission().

{
      if (ncci_state!=NACT && ncci_state!=N1 && ncci_state!=N2 && ncci_state!=N3 && ncci_state!=N4) {
            throw CapiWrongState("DISCONNECT_B3_IND received in wrong state","Connection::disconnect_b3_ind()");
      } else {
            if (ncci!=DISCONNECT_B3_IND_NCCI(&message))
                  throw CapiError("DISCONNECT_B3_IND received with wrong NCCI","Connection::disconnect_b3_ind()");

            disconnect_cause_b3=DISCONNECT_B3_IND_REASON_B3(&message);

            if (service==FAXG3 && CONNECT_B3_ACTIVE_IND_NCPI(&message)[0]>=9) {
                  _cstruct ncpi=CONNECT_B3_ACTIVE_IND_NCPI(&message);
                  if (!fax_info)
                        fax_info=new fax_info_t;
                  fax_info->rate=ncpi[1]+(ncpi[2]<<8);
                  fax_info->hiRes=((ncpi[3] & 0x01) == 0x01);
                  fax_info->format=((ncpi[4] & 0x04) == 0x04);
                  fax_info->pages=ncpi[7]+(ncpi[8]<<8);
                  fax_info->stationID.assign(reinterpret_cast<char*>(&ncpi[10]),static_cast<int>(ncpi[9])); // indx 9 helds the length, string starts at 10
                  if (debug_level >= 2) {
                        debug << prefix() << "fax finished with rate " << dec << fax_info->rate
                          << (fax_info->hiRes ? ", hiRes" : ", lowRes") << (fax_info->format ? ", JPEG" : "")
                          << ", ID: " << fax_info->stationID << ", " << fax_info->pages << " pages" << endl;
                  }
            }

            pthread_mutex_lock(&send_mutex);
            buffers_used=0; // we'll get no DATA_B3_CONF's after DISCONNECT_B3_IND, see Capi 2.0 spec, 5.18, note for DATA_B3_CONF
            pthread_mutex_unlock(&send_mutex);

            stop_file_transmission();
            stop_file_reception();

            bool our_disconnect_req= (ncci_state==N4) ? true : false;

            ncci_state=N5;

            if (call_if)
                  call_if->callDisconnectedLogical();

            try {
                  ncci_state=N0;
                  capi->disconnect_b3_resp(message.Messagenumber,ncci);
            }
            catch (CapiMsgError e) {
                  error << prefix() << "WARNING: Can't send disconnect_b3_resp. Message was: " << e << endl;
            }

            if (our_disconnect_req && !keepPhysicalConnection) { // this means *we* initiated disconnect of logical connection with DISCONNECT_B3_REQ before
                  try {
                        plci_state=P5;
                        capi->disconnect_req(plci);  // so we'll continue with the disconnect of physical connection
                  }
                  catch (CapiMsgError e) {
                        // in this application this is fatal. Panic please.
                        throw CapiError("Can't disconnect. Please file a bug report. Error message: "+e.message(),"Connection::disconnect_b3_ind()");
                  }
            } else
                  keepPhysicalConnection=false;
      }
}


Generated by  Doxygen 1.6.0   Back to index