⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vxitel.cpp

📁 openvxi3.4是一个voicexml对话脚本语言的解释器源码.可用VC6.0编译.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  if (val != NULL && VXIValueGetType(val) == VALUE_STRING) {
    const VXIchar* strval = VXIStringCStr(reinterpret_cast<const VXIString*>(val));
    if( strval ) {
      if( wcscmp(strval, L"VXItel_RESULT_CONNECTION_NO_AUTHORIZATION") == 0 ) {
        retcode = VXItel_RESULT_CONNECTION_NO_AUTHORIZATION;
        return true;  
      }        
      else if( wcscmp(strval, L"VXItel_RESULT_CONNECTION_BAD_DESTINATION") == 0 ) {
        retcode = VXItel_RESULT_CONNECTION_BAD_DESTINATION;
        return true;  
      }        
      else if( wcscmp(strval, L"VXItel_RESULT_CONNECTION_NO_ROUTE") == 0 ) {
        retcode = VXItel_RESULT_CONNECTION_NO_ROUTE;
        return true;  
      }        
      else if( wcscmp(strval, L"VXItel_RESULT_CONNECTION_NO_RESOURCE") == 0 ) {
        retcode = VXItel_RESULT_CONNECTION_NO_RESOURCE;
        return true;  
      }        
      else if( wcscmp(strval, L"VXItel_RESULT_UNSUPPORTED_URI") == 0 ) {
        retcode = VXItel_RESULT_UNSUPPORTED_URI;
        return true;  
      }        
      else if( wcscmp(strval, L"VXItel_RESULT_UNSUPPORTED") == 0 ) {
        retcode = VXItel_RESULT_UNSUPPORTED;
        return true;  
      }        
    }   
  }
  return false;
}

/**
 * Blind Transfer.
 */
static
VXItelResult VXItelTransferBlind(VXItelInterface * vxip, 
                                 const VXIMap * prop,
                                 const VXIchar * transferDestination,
                                 VXIMap **resp)
{
  VXItelImpl *impl = ToVXItelImpl(vxip);
  Diag(impl, DIAG_TAG_SIGNALING, NULL, L"TransferBlind: %s", 
       transferDestination);

  *resp = VXIMapCreate();

  VXItelTransferStatus xferStatus = VXItel_TRANSFER_UNKNOWN;

  const VXIValue* dval = VXIMapGetProperty(prop, L"TransferStatus");
  if( dval && VXIValueGetType(dval) == VALUE_STRING ){
    const wchar_t* hid = VXIStringCStr(reinterpret_cast<const VXIString *>(dval));
    xferStatus = GetXferStatus(hid);
  }

  VXIMapSetProperty(*resp, TEL_TRANSFER_STATUS, 
                    (VXIValue *) VXIIntegerCreate(xferStatus));

  return VXItel_RESULT_SUCCESS;
}

/**
 * Consultation Transfer.
 */
static
VXItelResult VXItelTransferConsultation(VXItelInterface * vxip, 
                                 const VXIMap * prop,
                                 const VXIchar * transferDestination,
                                 VXIMap **resp)
{
  VXItelImpl *impl = ToVXItelImpl(vxip);
  Diag(impl, DIAG_TAG_SIGNALING, NULL, L"TransferConsultation: %s", 
       transferDestination);

  *resp = VXIMapCreate();

  VXItelTransferStatus xferStatus = VXItel_TRANSFER_CONNECTED;

  const VXIValue* dval = VXIMapGetProperty(prop, L"AnswerDelay");
  if( dval && VXIValueGetType(dval) == VALUE_STRING ){
    const wchar_t* hid = VXIStringCStr(reinterpret_cast<const VXIString *>(dval));
    int answerDelay = SWIwtoi(hid);

    const VXIValue* ct = VXIMapGetProperty(prop, TEL_CONNECTTIMEOUT);
    if (answerDelay > VXIIntegerValue(reinterpret_cast<const VXIInteger*>(ct)))
      xferStatus = VXItel_TRANSFER_NOANSWER;
  }
  else {
    dval = VXIMapGetProperty(prop, L"TransferStatus");
    if( dval && VXIValueGetType(dval) == VALUE_STRING ){
      const wchar_t* hid = VXIStringCStr(reinterpret_cast<const VXIString *>(dval));
      xferStatus = GetXferStatus(hid);
      // ignore maxtime_disconnect since it can't happen on consultation
      if (xferStatus == VXItel_TRANSFER_MAXTIME_DISCONNECT)
         xferStatus = VXItel_TRANSFER_CONNECTED;
    }
  }

  VXIMapSetProperty(*resp, TEL_TRANSFER_STATUS, 
                    (VXIValue *) VXIIntegerCreate(xferStatus));

  return VXItel_RESULT_SUCCESS;
}

/**
 * Bridging Transfer.
 *
 */
static
VXItelResult VXItelTransferBridge(VXItelInterface * vxip, 
                                  const VXIMap * prop,
                                  const VXIchar * transferDestination,
                                  VXIMap **resp)
{
  VXItelImpl *impl = ToVXItelImpl(vxip);
  Diag(impl, DIAG_TAG_SIGNALING, NULL, L"TransferBridge: %s", 
       transferDestination);

  *resp = VXIMapCreate();

  // check for return code
  VXItelResult rc = VXItel_RESULT_SUCCESS;
  if( GetReturnCode(prop, rc) ) return rc;

  VXItelTransferStatus xferStatus = VXItel_TRANSFER_FAR_END_DISCONNECT;
  
  const VXIValue* dval = VXIMapGetProperty(prop, L"AnswerDelay");
  if( dval && VXIValueGetType(dval) == VALUE_STRING ){
    const wchar_t* hid = VXIStringCStr(reinterpret_cast<const VXIString *>(dval));
	int answerDelay = SWIwtoi(hid);

	const VXIValue* ct = VXIMapGetProperty(prop, TEL_CONNECTTIMEOUT);
	if (answerDelay > VXIIntegerValue(reinterpret_cast<const VXIInteger*>(ct)))
	  xferStatus = VXItel_TRANSFER_NOANSWER;
  }
  else {
    dval = VXIMapGetProperty(prop, L"TransferStatus");
    if( dval && VXIValueGetType(dval) == VALUE_STRING ){
      const wchar_t* hid = VXIStringCStr(reinterpret_cast<const VXIString *>(dval));
      xferStatus = GetXferStatus(hid);
    }
  }

  VXIMapSetProperty(*resp, TEL_TRANSFER_STATUS, 
                    (VXIValue *) VXIIntegerCreate(xferStatus));
  VXIMapSetProperty(*resp, TEL_TRANSFER_DURATION, (VXIValue *) VXIIntegerCreate(12000));
  return VXItel_RESULT_SUCCESS;
}


/**
 * Enable calls on the channel
 *
 */
static VXItelResult
VXItelEnableCall(struct VXItelInterfaceEx  *pThis)
{
  if (! pThis) return VXItel_RESULT_INVALID_ARGUMENT;

  return VXItel_RESULT_SUCCESS;
}


/**
 * Wait for and answer a call on the channel
 *
 */
static VXItelResult
VXItelWaitForCall(struct VXItelInterfaceEx  *vxip,
                  VXIMap                 **telephonyProps)
{
  if ((! vxip) || (! telephonyProps))
    return VXItel_RESULT_INVALID_ARGUMENT;

  VXItelImpl *impl = ToVXItelImpl(vxip);
  Diag(impl, DIAG_TAG_SIGNALING, NULL, L"New call");

  *telephonyProps = VXIMapCreate();
  if (! *telephonyProps) return VXItel_RESULT_OUT_OF_MEMORY;

  VXIMapSetProperty(*telephonyProps, L"dnis",
                    (VXIValue *)VXIStringCreate(L"6174284444"));
  VXIMapSetProperty(*telephonyProps, L"ani", 
                    (VXIValue *)VXIStringCreate(L"6508470000"));

  return VXItel_RESULT_SUCCESS;
}


/*******************************************************
 * Factory and init routines
 *******************************************************/ 

/**
 * Global initialization of Telephony platform.
 */
VXITEL_API VXItelResult VXItelInit (VXIlogInterface  *log,
                                    VXIunsigned       diagLogBase,
                                    VXIMap            *args)
{
  if (! log) return VXItel_RESULT_INVALID_ARGUMENT;

  gblDiagLogBase = diagLogBase;
  return VXItel_RESULT_SUCCESS;
}


/**
 * Global shutdown of Telephony platform.
 */
VXITEL_API VXItelResult VXItelShutDown (VXIlogInterface  *log)
{
  if (! log) return VXItel_RESULT_INVALID_ARGUMENT;

  return VXItel_RESULT_SUCCESS;
}


/**
 * Creates an VXItel implementation of the VXItel interface
 */
VXITEL_API VXItelResult VXItelCreateResource(VXIlogInterface *log,
                                             VXItelInterface **tel)
{
  if (! log) return VXItel_RESULT_INVALID_ARGUMENT;
  VXItelImpl* pp = new VXItelImpl();
  if (pp == NULL) return VXItel_RESULT_OUT_OF_MEMORY;

  pp->log = log;
  pp->telIntf.vxitel.GetVersion     = VXItelGetVersion;
  pp->telIntf.vxitel.GetImplementationName = VXItelGetImplementationName;
  pp->telIntf.vxitel.BeginSession   = VXItelBeginSession;
  pp->telIntf.vxitel.EndSession     = VXItelEndSession;
  pp->telIntf.vxitel.GetStatus      = VXItelGetStatus;
  pp->telIntf.vxitel.Disconnect     = VXItelDisconnect;
  pp->telIntf.vxitel.TransferBlind  = VXItelTransferBlind;
  pp->telIntf.vxitel.TransferBridge = VXItelTransferBridge;
  pp->telIntf.vxitel.TransferConsultation = VXItelTransferConsultation;
  pp->telIntf.EnableCall          = VXItelEnableCall;
  pp->telIntf.WaitForCall         = VXItelWaitForCall;

  *tel = &pp->telIntf.vxitel;
  return VXItel_RESULT_SUCCESS;
}

/**
 * Destroys the specified VXItel implementation
 */
VXITEL_API VXItelResult VXItelDestroyResource(VXItelInterface **tel)
{
  if (tel == NULL || *tel == NULL) return VXItel_RESULT_INVALID_ARGUMENT;
  VXItelImpl* telImpl = reinterpret_cast<VXItelImpl*>(*tel);

  delete telImpl;
  *tel = NULL;

  return VXItel_RESULT_SUCCESS;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -