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

Connection::Connection ( Capi capi,
_cdword  controller,
string  call_from,
bool  clir,
string  call_to,
service_t  service,
string  faxStationID,
string  faxHeadline 
) throw (CapiExternalError, CapiMsgError)

Constructor. Create an object to initiate an outgoing call.

This constructor is used when the application creates a Connection object manually to initiate an outgoing connection.

It constructs the necessary information elements (B channel protocol settings, Number elements) and calls Capi::connect_req to initiate a call.

Parameters:
capi pointer to the Capi Object
controller number of the controller which should initiate the call
call_from our number
clir set to TRUE to hide our number (so that the called party can't see it)
call_to the number which we want to call
service service to use (currently only VOICE and FAXG3 are supported), see service_t
faxStationID fax station ID, only used with service faxG3
faxHeadline fax headline (written on each fax page), only used with service faxG3, encoded in ISO8859-1
Exceptions:
CapiExternalError thrown when parameters are missing or wrong
CapiMsgError thrown by Capi::connect_req, see there

Definition at line 68 of file connection.cpp.

References buildBconfiguration(), call_from, call_to, capi, Capi::connect_req(), debug, debug_level, FAXG3, P01, plci_state, prefix(), receive_mutex, send_mutex, service, and VOICE.

      :call_if(NULL),capi(capi),plci_state(P01),ncci_state(N0),plci(0),service(service),  
      buffer_start(0), buffers_used(0), file_for_reception(NULL), file_to_send(NULL), 
      call_from(call_from), call_to(call_to), connect_ind_msg_nr(0), disconnect_cause(0), 
      debug(capi->debug), debug_level(capi->debug_level), error(capi->error), keepPhysicalConnection(false),
      our_call(true), disconnect_cause_b3(0), fax_info(NULL), DDILength(0), DDIBaseLength(0) 
{
      pthread_mutex_init(&send_mutex, NULL);
      pthread_mutex_init(&receive_mutex, NULL);

      if (debug_level >= 1) {
            debug << prefix() << "Connection object created for outgoing call from " << call_from << " to " << call_to
              << " service " << dec << service << endl;
      }
      if (debug_level >= 2) {
            debug << prefix() << "using faxStationID " << faxStationID << " faxHeadline " << faxHeadline << " CLIR " << clir << endl;
      }
      _cstruct B1config=NULL, B2config=NULL, B3config=NULL, calledPartyNumber=NULL, callingPartyNumber=NULL;
      _cword B1proto,B2proto,B3proto;

      try {
            _cword CIPvalue;
            switch (service) {
                  case VOICE:
                        CIPvalue=16;
                  break;
                  case FAXG3:
                        CIPvalue=17;
                  break;
                  default:
                        throw CapiExternalError("unsupported service given","Connection::Connection()");
                  break;
            }

            buildBconfiguration(controller, service, faxStationID, faxHeadline, B1proto, B2proto, B3proto, B1config, B2config, B3config);

            if (!call_to.size())
                  throw CapiExternalError("calledPartyNumber is required","Connection::Connection()");

            calledPartyNumber=new unsigned char [1+1+call_to.size()]; //struct length, number type/number plan, number
            calledPartyNumber[0]=1+call_to.size(); // length
            calledPartyNumber[1]=0x80;  // as suggested by CAPI spec (unknown number type, unknown number plan, see ETS 300 102-1)
            for (unsigned j=0;j<call_to.size();j++)
                  calledPartyNumber[j+2]=call_to[j];

            callingPartyNumber=new unsigned char [1+2+call_from.size()];
            callingPartyNumber[0]=2+call_from.size(); // length
            callingPartyNumber[1]=0x00; // as suggested by CAPI spec (unknown number type, unknown number plan, see ETS 300 102-1)
            if (clir)
                  callingPartyNumber[2]=0xA0; // suppress calling id presentation (CLIR)
            else
                  callingPartyNumber[2]=0x80; // allow calling id presentation (CLIP)
            for (unsigned j=0;j<call_from.size();j++)  // TODO: does this really work when no number is given?!
                  callingPartyNumber[j+3]=call_from[j];

            plci_state=P01;
            capi->connect_req(this,controller,CIPvalue, calledPartyNumber, callingPartyNumber,B1proto,B2proto,B3proto,B1config, B2config, B3config);
      } catch (...) {
            if (B1config)
                  delete[] B1config;
            if (B2config)
                  delete[] B2config;
            if (B3config)
                  delete[] B3config;
            if (calledPartyNumber)
                  delete[] calledPartyNumber;
            if (callingPartyNumber)
                  delete[] callingPartyNumber;
            throw;
      }
      if (B1config)
            delete[] B1config;
      if (B2config)
            delete[] B2config;
      if (B3config)
            delete[] B3config;
      if (calledPartyNumber)
            delete[] calledPartyNumber;
      if (callingPartyNumber)
            delete[] callingPartyNumber;
}


Generated by  Doxygen 1.6.0   Back to index