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

string Connection::getNumber ( _cstruct  capi_input,
bool  isCallingNr 
) [protected]

format the CallingPartyNr or CalledPartyNr to readable string

Parameters:
capi_input the CallingPartyNumber resp. CalledPartyNumber struct
isCallingNr true = CallingPartyNr / false = CalledPartyNr
Returns:
the number formatted as string

Definition at line 1013 of file connection.cpp.

Referenced by Connection(), and info_ind_called_party_nr().

{
// CallingNr: byte 0: length (w/o byte 0), Byte 1+2 see ETS 300 102-1, Chapter 4.5, byte 3-end: number (w/o leading "0" or "00")
// CalledNr:  byte 0: length (w/o byte 0), Byte 1 see ETS 300 102-1, Chapter 4, byte 2-end: number w/o leading "0" or "00"
      int length=capi_input[0];

      if (!length) // no info element given
            return "-";

      char *nr=new char[length];
      memcpy (nr,&capi_input[2],length-1); // copy only number
      nr[length-1]='\0';                   // add \0
      string a(nr);
      if (isCallingNr)
            a=a.substr(1);

      // if we are looking at a CallingPartyNumber and it is an international number or a national number
      // (see ETS 300 102-1, chapter 4.5), we'll add the prefix "0" or "+"

      if (a.empty()) {
            a="-";
      } else if (isCallingNr && ((capi_input[1] & 0x70) == 0x20)) {  // national number
            a='0'+a;
      } else if (isCallingNr && ((capi_input[1] & 0x70) == 0x10)) { // international number
            a='+'+a;
      }
      return a;
}


Generated by  Doxygen 1.6.0   Back to index