cc_rcs_t sub_send_msg (cprBuffer_t buf, uint32_t cmd, uint16_t len, cc_srcs_t dst_id) { cpr_status_e rc; CC_DEBUG_MSG sub_print_msg((char *)buf, len); switch (dst_id) { case CC_SRC_GSM: rc = gsm_send_msg(cmd, buf, len); if (rc == CPR_FAILURE) { cprReleaseBuffer(buf); } break; case CC_SRC_SIP: rc = SIPTaskSendMsg(cmd, buf, len, NULL); if (rc == CPR_FAILURE) { cprReleaseBuffer(buf); } break; case CC_SRC_MISC_APP: rc = MiscAppTaskSendMsg(cmd, buf, len); if (rc == CPR_FAILURE) { cprReleaseBuffer(buf); } break; default: rc = CPR_FAILURE; break; } return (rc == CPR_SUCCESS) ? CC_RC_SUCCESS : CC_RC_ERROR; }
/** * This function will post an event - SUB_MSG_PRESENCE_UNSOLICITED_NOTIFY - to Misc task. * This is invoked by sip task. * * @param[in] msg_data - pointer to ccsip_sub_not_data_t * * @return none * * @pre (msg_data != NULL) */ void pres_unsolicited_notify_ind (ccsip_sub_not_data_t *msg_data) { static const char fname[] = "pres_unsolicited_notify_ind"; ccsip_sub_not_data_t *pmsg; cpr_status_e rc; pmsg = (ccsip_sub_not_data_t *) cc_get_msg_buf(sizeof(*pmsg)); if (!pmsg) { BLF_ERROR(MISC_F_PREFIX"malloc failed", fname); return; } memcpy(pmsg, msg_data, sizeof(*pmsg)); rc = MiscAppTaskSendMsg(SUB_MSG_PRESENCE_UNSOLICITED_NOTIFY, pmsg, sizeof(*pmsg)); if (rc == CPR_FAILURE) { cpr_free(pmsg); } }
cc_rcs_t sub_send_msg (cprBuffer_t buf, uint32_t cmd, uint16_t len, cc_srcs_t dst_id) { cpr_status_e rc; /* This buffer is assumed to be at least of size int */ MOZ_ASSERT(len >= sizeof(int)); if (len < sizeof(int)) { return CC_RC_ERROR; } CC_DEBUG_MSG sub_print_msg((char *)buf, len); switch (dst_id) { case CC_SRC_GSM: rc = gsm_send_msg(cmd, buf, len); if (rc == CPR_FAILURE) { cpr_free(buf); } break; case CC_SRC_SIP: rc = SIPTaskSendMsg(cmd, buf, len, NULL); if (rc == CPR_FAILURE) { cpr_free(buf); } break; case CC_SRC_MISC_APP: rc = MiscAppTaskSendMsg(cmd, buf, len); if (rc == CPR_FAILURE) { cpr_free(buf); } break; default: rc = CPR_FAILURE; break; } return (rc == CPR_SUCCESS) ? CC_RC_SUCCESS : CC_RC_ERROR; }
/* * 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; } }