/** * Ask the platform to sync with versions got from call control * or outside entity. As part of the sync, platform downloads * the files if required. * * @param cfg_ver - version stamp for config file * @param dp_ver - version stamp for the dialplan file * @param softkey_ver - version stamp for the softkey file. * * @return none */ void platform_sync_cfg_vers (char *cfg_ver, char *dp_ver, char *softkey_ver) { static const char fname[] = "platform_sync_cfg_vers"; char empty_string[] = ""; feature_update_t msg; if (cfg_ver == NULL) { cfg_ver = empty_string; } if (dp_ver == NULL) { dp_ver = empty_string; } if (softkey_ver == NULL) { softkey_ver = empty_string; } CCAPP_DEBUG(DEB_F_PREFIX"cfg_ver=%s dp_ver=%s sk_ver=%s\n", DEB_F_PREFIX_ARGS(PLAT_API, fname), cfg_ver, dp_ver, softkey_ver); msg.sessionType = SESSIONTYPE_CALLCONTROL; msg.featureID = DEVICE_SYNC_CONFIG_VERSION; msg.update.ccFeatUpd.data.cfg_ver_data.cfg_ver = strlib_malloc(cfg_ver, strlen(cfg_ver)); msg.update.ccFeatUpd.data.cfg_ver_data.dp_ver = strlib_malloc(dp_ver, strlen(dp_ver)); msg.update.ccFeatUpd.data.cfg_ver_data.softkey_ver = strlib_malloc(softkey_ver, strlen(softkey_ver)); if ( ccappTaskPostMsg(CCAPP_FEATURE_UPDATE, &msg, sizeof(feature_update_t), CCAPP_CCPROVIER) != CPR_SUCCESS ) { CCAPP_DEBUG(DEB_F_PREFIX"failed to send platform_sync_cfg_vers msg \n", DEB_F_PREFIX_ARGS(PLAT_API, fname)); } }
/** * Internal method */ void cc_invokeDeviceFeature(session_feature_t *feature) { if (ccappTaskPostMsg(CCAPP_INVOKEPROVIDER_FEATURE, feature, sizeof(session_feature_t), CCAPP_CCPROVIER) == CPR_FAILURE) { CCAPP_DEBUG(DEB_F_PREFIX"cc_invokeDeviceFeature failed", DEB_F_PREFIX_ARGS("cc_device_feature", "cc_invokeDeviceFeature")); } }
void platform_logout_reset_req(void){ static const char fname[] = "platform_logout_reset_req"; feature_update_t msg; CCAPP_DEBUG(DEB_F_PREFIX"\n", DEB_F_PREFIX_ARGS(PLAT_API, fname)); msg.sessionType = SESSIONTYPE_CALLCONTROL; msg.featureID = CCAPP_LOGOUT_RESET; if ( ccappTaskPostMsg(CCAPP_FALLBACK_IND, &msg, sizeof(feature_update_t), CCAPP_CCPROVIER) != CPR_SUCCESS ) { CCAPP_ERROR(PLT_F_PREFIX"failed to send Logout_Reset(%d) msg \n", fname); } return; }
/*called from configapp.c. This routine will set the kpml value on the java side and trigger it down to c-side. Also, it will reinitialize the dialplan. */ void update_kpmlconfig(int kpmlVal) { static const char fname[] = "update_kpmlconfig"; session_mgmt_t msg; CCAPP_DEBUG(DEB_F_PREFIX "kpml=%d\n", DEB_F_PREFIX_ARGS(PLAT_API, fname), kpmlVal); msg.func_id = SESSION_MGMT_UPDATE_KPMLCONFIG; msg.data.kpmlconfig.kpml_val = kpmlVal; if ( ccappTaskPostMsg(CCAPP_SESSION_MGMT, &msg, sizeof(session_mgmt_t), CCAPP_CCPROVIER) != CPR_SUCCESS ) { CCAPP_DEBUG(DEB_F_PREFIX"failed to send update_kpmlconfig msg\n", DEB_F_PREFIX_ARGS(PLAT_API, fname)); } }
/** * * Notify the platform that call control has shut down. * * @param none * * @return none */ void shutdownCCAck (void) { static const char fname[] = "shutdownCCAck"; feature_update_t msg; CCAPP_DEBUG(DEB_F_PREFIX"\n", DEB_F_PREFIX_ARGS(PLAT_API, fname)); msg.sessionType = SESSIONTYPE_CALLCONTROL; msg.featureID = CCAPP_SHUTDOWN_ACK; if ( ccappTaskPostMsg(CCAPP_SHUTDOWN_ACK, &msg, sizeof(feature_update_t), CCAPP_CCPROVIER) != CPR_SUCCESS ) { CCAPP_ERROR(PLT_F_PREFIX"failed to send shutdownCCAck(%d) msg \n", fname); } }
/** * * Tell platform to adjust the time to the gmt_time received from outside * For sip the "outside" is from the "Date" header coming from a CCM or * any other Server * * @param gmt_time - GMT time in seconds * * @return none */ void platform_set_time (long gmt_time) { static const char fname[] = "platform_set_time"; session_mgmt_t msg; CCAPP_DEBUG(DEB_F_PREFIX"setting time to=%ld", DEB_F_PREFIX_ARGS(PLAT_API, fname), gmt_time); msg.func_id = SESSION_MGMT_SET_TIME; msg.data.time.gmt_time = gmt_time; if ( ccappTaskPostMsg(CCAPP_SESSION_MGMT, &msg, sizeof(session_mgmt_t), CCAPP_CCPROVIER) != CPR_SUCCESS ) { CCAPP_DEBUG(DEB_F_PREFIX"failed to send platform_set_time msg\n", DEB_F_PREFIX_ARGS(PLAT_API, fname)); } }
/** * This function calls the JNI function to sends the information received * in apply-config NOTIFY message to Java side. * * @param configVersionStamp - version stamp for config file * @param dialplanVersionStamp - version stamp for the dialplan file * @param fcpVersionStamp - version stamp for the softkey file (?) * @param cucmResult - CUCM result after applying config by CUCM * @param loadId - loadId to upgrade as requested by CUCM * @param inactiveLoadId - inactive loadId for inactive partition as requested by CUCM * @param loadServer - load server form where to pick loadId * @param logServer - log server for logging output of peer to peer upgrade. * @param ppid - specify whether peer to peer upgrade is enabled/disabled. * * @return none */ void platform_apply_config (char * configVersionStamp, char * dialplanVersionStamp, char * fcpVersionStamp, char * cucmResult, char * loadId, char * inactiveLoadId, char * loadServer, char * logServer, boolean ppid) { static const char fname[] = "platform_apply_config"; session_mgmt_t msg; fcpVersionStamp = (fcpVersionStamp != NULL) ? fcpVersionStamp : ""; /// Print the arguments CCAPP_DEBUG(DEB_F_PREFIX" configVersionStamp=%s \ndialplanVersionStamp=%s" "\nfcpVersionStamp=%s \ncucmResult=%s " "\nloadId=%s \ninactiveLoadId=%s \nloadServer=%s \nlogServer=%s " "\nppid=%s\n", DEB_F_PREFIX_ARGS(PLAT_API, fname), (configVersionStamp != NULL) ? configVersionStamp : "", (dialplanVersionStamp != NULL) ? dialplanVersionStamp:"", fcpVersionStamp, cucmResult != NULL ? cucmResult: "", (loadId != NULL) ? loadId : "", (inactiveLoadId != NULL) ? inactiveLoadId : "", (loadServer != NULL) ? loadServer : "", (logServer != NULL) ? logServer : "", ppid == TRUE? "True": "False"); // following data is freed in function freeSessionMgmtData() msg.func_id = SESSION_MGMT_APPLY_CONFIG; msg.data.config.config_version_stamp = STRLIB_CREATE(configVersionStamp); msg.data.config.dialplan_version_stamp = STRLIB_CREATE(dialplanVersionStamp); msg.data.config.fcp_version_stamp = STRLIB_CREATE(fcpVersionStamp); msg.data.config.cucm_result = STRLIB_CREATE(cucmResult); msg.data.config.load_id = STRLIB_CREATE(loadId); msg.data.config.inactive_load_id = STRLIB_CREATE(inactiveLoadId); msg.data.config.load_server = STRLIB_CREATE(loadServer); msg.data.config.log_server = STRLIB_CREATE(logServer); msg.data.config.ppid = ppid; if ( ccappTaskPostMsg(CCAPP_SESSION_MGMT, &msg, sizeof(session_mgmt_t), CCAPP_CCPROVIER) != CPR_SUCCESS ) { CCAPP_DEBUG(DEB_F_PREFIX"failed to send platform_apply_config msg\n", DEB_F_PREFIX_ARGS(PLAT_API, fname)); } }
/** * Notify the platform about the change in call control mode. * * @param mode - the call control mode. * cip_sipcc_CcMgmtConst_CC_TYPE_CCM * or cip_sipcc_CcMgmtConst_CC_TYPE_OTHER * * @return none */ void platform_cc_mode_notify (int mode) { static const char fname[] = "platform_cc_mode_notify"; feature_update_t msg; CCAPP_DEBUG(DEB_F_PREFIX"mode =%d\n", DEB_F_PREFIX_ARGS(PLAT_API, fname), mode); msg.sessionType = SESSIONTYPE_CALLCONTROL; msg.featureID = CCAPP_MODE_NOTIFY; msg.update.ccFeatUpd.data.line_info.info = mode; if ( ccappTaskPostMsg(CCAPP_MODE_NOTIFY, &msg, sizeof(feature_update_t), CCAPP_CCPROVIER) != CPR_SUCCESS ) { CCAPP_ERROR(PLT_F_PREFIX"failed to send platform_cc_mode_notify(%d) msg \n", fname, mode); } }
/** * Restart pSipcc stack * @return */ cc_return_t CC_Service_restart() { sessionProvider_cmd_t proCmd; CCAPP_DEBUG("CC_Service_restart \n"); memset ( &proCmd, 0, sizeof(sessionProvider_cmd_t)); proCmd.sessionType = SESSIONTYPE_CALLCONTROL; //Not used proCmd.cmd = CMD_RESTART; if (ccappTaskPostMsg(CCAPP_SERVICE_CMD, (cprBuffer_t)&proCmd, sizeof(sessionProvider_cmd_t), CCAPP_CCPROVIER) == CPR_FAILURE) { CCAPP_DEBUG("CC_Service_restart: ccappTaskSendMsg failed\n"); return CC_FAILURE; } return CC_SUCCESS; }
/** * Shutdown pSipcc stack for restarting * @param mgmt_reason the reason to shutdown pSipcc stack * @param reason_string literal string for shutdown * @return */ cc_return_t CC_Service_shutdown(cc_shutdown_reason_t mgmt_reason, string_t reason_string) { sessionProvider_cmd_t proCmd; CCAPP_DEBUG("CC_Service_shutdown \n"); memset ( &proCmd, 0, sizeof(sessionProvider_cmd_t)); proCmd.sessionType = SESSIONTYPE_CALLCONTROL; //Not used proCmd.cmd = CMD_SHUTDOWN; if (ccappTaskPostMsg(CCAPP_SERVICE_CMD, (cprBuffer_t)&proCmd, sizeof(sessionProvider_cmd_t), CCAPP_CCPROVIER) == CPR_FAILURE) { CCAPP_DEBUG("CC_Service_shutdown: ccappTaskSendMsg failed\n"); return CC_FAILURE; } return CC_SUCCESS; }
/** * Send a reset or restart request to the adapter * * @param action - reset or restart * @return none * */ void platform_reset_req (DeviceResetType action) { static const char fname[] = "platform_reset_req"; feature_update_t msg; DEF_DEBUG(DEB_F_PREFIX"***********%s, requested***********\n", DEB_F_PREFIX_ARGS(PLAT_API, fname), (action==1)? "RESET":"RESTART"); msg.sessionType = SESSIONTYPE_CALLCONTROL; msg.featureID = DEVICE_SERVICE_CONTROL_REQ; msg.update.ccFeatUpd.data.reset_type = action; if ( ccappTaskPostMsg(CCAPP_FEATURE_UPDATE, &msg, sizeof(feature_update_t), CCAPP_CCPROVIER) != CPR_SUCCESS ) { CCAPP_DEBUG(DEB_F_PREFIX"failed to send platform_reset_req(%d) msg \n", DEB_F_PREFIX_ARGS(PLAT_API, fname), action); } }
/** * Indicate to the platform that reg manager intends to fallback to * primary CCM. Currently the fallback_to is always to CC_TYPE_CCM. * * @param fallback_to - type of call control, * e.g. cip_sipcc_CcMgmtConst_CC_TYPE_CCM * * @return none */ void platform_reg_fallback_ind (int fallback_to) { static const char fname[] = "platform_reg_fallback_ind"; feature_update_t msg; DEF_DEBUG(DEB_F_PREFIX"***********Fallback to %d CUCM.***********\n", DEB_F_PREFIX_ARGS(PLAT_API, fname), fallback_to); msg.sessionType = SESSIONTYPE_CALLCONTROL; msg.featureID = CCAPP_FALLBACK_IND; msg.update.ccFeatUpd.data.line_info.info = fallback_to; if ( ccappTaskPostMsg(CCAPP_FALLBACK_IND, &msg, sizeof(feature_update_t), CCAPP_CCPROVIER) != CPR_SUCCESS ) { CCAPP_ERROR(PLT_F_PREFIX"failed to send platform_reg_fallback_ind(%d) msg \n", fname, fallback_to); } }
/** * Register all lines for a phone. * @param mgmt_reason the reason of registration * @param reason_string the literal string of the registration * @return */ cc_return_t CC_Service_registerAllLines(cc_shutdown_reason_t mgmt_reason, string_t reason_string) { sessionProvider_cmd_t proCmd; CCAPP_DEBUG("CC_Service_registerAllLines \n"); memset ( &proCmd, 0, sizeof(sessionProvider_cmd_t)); proCmd.sessionType = SESSIONTYPE_CALLCONTROL; //Not used proCmd.cmd = CMD_REGISTER_ALL_LINES; proCmd.cmdData.ccData.reason = mgmt_reason; proCmd.cmdData.ccData.reason_info = reason_string; if (ccappTaskPostMsg(CCAPP_SERVICE_CMD, (cprBuffer_t)&proCmd, sizeof(sessionProvider_cmd_t), CCAPP_CCPROVIER) == CPR_FAILURE) { CCAPP_DEBUG("CC_Service_registerAllLines: ccappTaskSendMsg failed\n"); return CC_FAILURE; } return CC_SUCCESS; }
/* * Function: send_task_unload_msg * * Description: * - send shutdown and thread destroy msg to sip, gsm, ccapp, misc * threads * Parameters: destination thread * * Returns: none * */ void send_task_unload_msg(cc_srcs_t dest_id) { const char *fname = "send_task_unload_msg"; uint16_t len = 4; cprBuffer_t msg = gsm_get_buffer(len); int sdpmode = 0; config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode)); if (msg == NULL) { err_msg("%s: failed to allocate msg cprBuffer_t\n", fname); return; } DEF_DEBUG(DEB_F_PREFIX"send Unload message to %s task ..\n", DEB_F_PREFIX_ARGS(SIP_CC_INIT, fname), dest_id == CC_SRC_SIP ? "SIP" : dest_id == CC_SRC_GSM ? "GSM" : dest_id == CC_SRC_MISC_APP ? "Misc App" : dest_id == CC_SRC_CCAPP ? "CCApp" : "Unknown"); switch(dest_id) { case CC_SRC_SIP: { /* send this msg so phone can send unRegister msg */ SIPTaskPostShutdown(SIP_EXTERNAL, CC_CAUSE_SHUTDOWN, ""); /* allow unRegister msg to sent out and shutdown to complete */ if (!sdpmode) { cprSleep(2000); } /* send a unload message to the SIP Task to kill sip thread*/ msg = SIPTaskGetBuffer(len); if (msg == NULL) { err_msg("%s:%d: failed to allocate sip msg buffer\n", fname); return; } if (SIPTaskSendMsg(THREAD_UNLOAD, (cprBuffer_t)msg, len, NULL) == CPR_FAILURE) { cpr_free(msg); err_msg("%s: Unable to send THREAD_UNLOAD msg to sip thread", fname); } } break; case CC_SRC_GSM: { msg = gsm_get_buffer(len); if (msg == NULL) { err_msg("%s: failed to allocate gsm msg cprBuffer_t\n", fname); return; } if (CPR_FAILURE == gsm_send_msg(THREAD_UNLOAD, msg, len)) { err_msg("%s: Unable to send THREAD_UNLOAD msg to gsm thread", fname); } } break; case CC_SRC_MISC_APP: { msg = cpr_malloc(len); if (msg == NULL) { err_msg("%s: failed to allocate misc msg cprBuffer_t\n", fname); return; } if (CPR_FAILURE == MiscAppTaskSendMsg(THREAD_UNLOAD, msg, len)) { err_msg("%s: Unable to send THREAD_UNLOAD msg to Misc App thread", fname); } } break; case CC_SRC_CCAPP: { msg = cpr_malloc(len); if (msg == NULL) { err_msg("%s: failed to allocate ccapp msg cprBuffer_t\n", fname); return; } if (ccappTaskPostMsg(CCAPP_THREAD_UNLOAD, msg, len, CCAPP_CCPROVIER) == CPR_FAILURE ) { err_msg("%s: Unable to send THREAD_UNLOAD msg to CCapp thread", fname); } err_msg("%s: send UNLOAD msg to CCapp thread good", fname); } break; default: err_msg("%s: Unknown destination task passed=%d.", fname, dest_id); break; } }