Пример #1
0
/**
 * Gracefully unload the Sipcc stack
 * @return
 */
cc_return_t CCAPI_Service_destroy() {
    CCAPP_ERROR("CCAPI_Service_destroy - calling CC_Service_destroy \n");

    if (is_action_to_be_deferred(STOP_ACTION) == TRUE) {
        return CC_SUCCESS;
    }
    // initialize the config to empty
    init_empty_str(g_cfg_p);
    isServiceStartRequestPending = FALSE;
    registration_processEvent(EV_CC_DESTROY);
    return (CC_SUCCESS);
}
Пример #2
0
void ccsnap_set_line_label(int btn, cc_string_t label) {
   
   CCAPP_ERROR(DEB_F_PREFIX"btn=%d label=%s\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "ccsnap_set_line_label"), btn, label);
   if ( btn > 0 && btn <= MAX_CONFIG_LINES+1 ) {
       if ( label == NULL ) {
         label = strlib_empty();
       }
       if ( lineLabels[btn] == NULL ) {
         lineLabels[btn] = strlib_empty();
       }
       lineLabels[btn] = strlib_update(lineLabels[btn], label);
   }
}
Пример #3
0
/**
 * 
 * @content: the content of the document
 * @length: the length in bytes
 *
 * Parse the in memory document and free the resulting tree
 */
void
decodeInfoXML(const char *content, int length, cc_call_conference_Info_t *info) {
    xmlDocPtr doc; /* the resulting document tree */
    xmlNode *root_element = NULL;

    doc = xmlReadMemory(content, length, "noname.xml", NULL, 0);
    if (doc == NULL) {
        CCAPP_ERROR(DEB_F_PREFIX" Failed to parse document\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONFPARSE"));
        return;
    }

    /* Get the root element node */
    root_element = xmlDocGetRootElement(doc);
    if (root_element == NULL) {
        CCAPP_ERROR(DEB_F_PREFIX" Failed to get the root element\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONFPARSE"));
        return;
    }

    if (xmlStrcmp(root_element->name, (const xmlChar *)"conference-info") == 0) {
        parse_conference_info_node(root_element, doc, info);
    }                

    xmlFreeDoc(doc);
}
Пример #4
0
/**
 *
 * 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);
    }
}
Пример #5
0
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;
}
Пример #6
0
cc_participant_ref_t CCAPI_CallInfo_getConfSelfParticipant (cc_callinfo_ref_t handle)
{  
   cc_call_conference_ref_t callConference;    // conference reference (from call info)

   // get conference reference from the call info
   callConference = getCallConferenceRef(handle);
   if (callConference == NULL)
   {
      // unexpected error
      CCAPP_ERROR(DEB_F_PREFIX"Unable to get conference reference\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONF"));
      return strlib_empty();
   }
   
   return (callConference->myParticipantId);
}
Пример #7
0
cc_boolean CCAPI_CallInfo_isConfSelfParticipant (cc_callinfo_ref_t handle, cc_participant_ref_t participantHandle)
{ 
   cc_call_conference_ref_t callConference;    // conference reference (from call info)

   // get conference reference from the call info
   callConference = getCallConferenceRef(handle);
   if (callConference == NULL)
   {
      // error - log 
      CCAPP_ERROR(DEB_F_PREFIX"Unable to get conference reference\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONF"));
      return (FALSE);
   }
   
   return (strcmp((callConference->myParticipantId), participantHandle) == 0);
}
Пример #8
0
/**
 * 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);
    }
}
Пример #9
0
/**
 * Stop Sipcc stack service
 * @return
 */
cc_return_t CCAPI_Service_stop() {

	int  sdpmode = 0;

    CCAPP_ERROR("CCAPI_Service_stop - calling registration stop");

    config_get_value(CFGID_SDPMODE, &sdpmode, sizeof(sdpmode));
    if (!sdpmode) {
        if (is_action_to_be_deferred(STOP_ACTION) == TRUE) {
            return CC_SUCCESS;
        }
    }
    sendResetUpdates  = 0;         // reset to default is not to send updates
    isServiceStartRequestPending = FALSE;
    registration_processEvent(EV_CC_STOP);
    return CC_SUCCESS;
}
Пример #10
0
/**
 * Get the call conference reference
 * @param [in] handle - call info handle
 * @return cc_call_conference_Info_t
 */
cc_call_conference_ref_t  getCallConferenceRef(cc_callinfo_ref_t handle)
{
  session_data_t *data = (session_data_t *)handle;

  if (!CCAPI_CallInfo_getIsConference(handle))
  {
      CCAPP_ERROR(DEB_F_PREFIX"Conference API Invoked, but Not In Conference Call\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONF"));
      return (NULL);
  };

  if (data == NULL)
  {
      return (NULL);
  }
  
  return (&data->call_conference);
}
Пример #11
0
/**
 * 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);
    }
}
Пример #12
0
/**
* Get Maximum Number of Conference Participants ( in case gui wants to show %full conference info )
* @param [in] handle - call handle
* @return maximum number of conference participants
*/
cc_uint16_t CCAPI_CallInfo_getConfParticipantMax (cc_callinfo_ref_t handle)
{  // 
   cc_call_conference_ref_t callConference;    // conference reference (from call info)

   CCAPP_DEBUG(DEB_F_PREFIX"Entering:  CCAPI_CallInfo_getConfParticipantMax\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONF"));

   // get conference reference from the call info
   callConference = getCallConferenceRef(handle);
   if (callConference == NULL)
   {
      // no conference reference available
      CCAPP_ERROR(DEB_F_PREFIX"Unable to get conference reference\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONF"));
      return (0);
   }

   // return the max
   return (callConference->participantMax);
}
Пример #13
0
void CCAPI_Start_response(int device_handle, const char *device_name, const char *sipUser, const char *sipPassword, const char *sipDomain) {
    static const char fname[] = "CCAPI_Start_response";

    if (is_empty_str((char*)sipUser) || is_empty_str((char*)sipDomain)) {
        CCAPP_ERROR(DEB_F_PREFIX" invalid registration details user=%s, domain=%s", DEB_F_PREFIX_ARGS(CC_API, fname), sipUser, sipDomain);
        return;
    }

    g_dev_hdl = device_handle;
    sstrncpy(g_dev_name, device_name, sizeof(g_dev_name));

    if (is_phone_registered() == FALSE) {

        if (parse_setup_properties(device_handle, device_name, sipUser, sipPassword, sipDomain)) {
            registration_processEvent(EV_CC_CONFIG_RECEIVED);
        }
        return;
    }

 }
Пример #14
0
cpr_status_e ccappTaskPostMsg(unsigned int msgId, void * data, uint16_t len, int appId)
{
    cprBuffer_t *msg;
    static const char fname[] = "ccappPostMsg";
    cpr_status_e retval = CPR_SUCCESS;

    msg = (cprBuffer_t *) cpr_malloc(len);
    if (msg == NULL) {
        CCAPP_ERROR(DEB_F_PREFIX"failed to allocate message.\n",
                    DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname));
        return CPR_FAILURE;
    }

    memcpy(msg, data, len);

    if ((retval=ccappTaskSendMsg(msgId, msg, len, appId)) == CPR_FAILURE) {
        cpr_free(msg);
    }

    return retval;
}
Пример #15
0
/*
 * parse_conference_description_node
 *
 * Do conference-description specific parsing.
 *
 * Assumes a_node, info are not null.
 */ 
static void 
parse_conference_description_node (xmlNode * a_node, cc_call_conference_Info_t *info) 
{
    xmlNode *cur_node;
    xmlChar *data;

    for (cur_node = a_node->children; cur_node != NULL; cur_node = cur_node->next) {
        if (cur_node->type == XML_ELEMENT_NODE) {
            if (xmlStrcmp(cur_node->name, (const xmlChar *) "maximum-user-count") == 0) {
                data = xmlNodeGetContent(cur_node); 
                if (data != NULL) {
                    info->participantMax = atoi((const char*)data); 
                    xmlFree(data);
                } else {
                    //No max-user-count - continue parsing other elements -
                    CCAPP_ERROR(DEB_F_PREFIX" Error while trying to get the max-user-count\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONFPARSE"));
                } 
            }
        }
    }
}
Пример #16
0
/*
 *  Function: ParseDialVersion()
 *
 *  Parameters: parseptr - pointer to bytes to be parsed
 *
 *  Description: Parse the contents of a versionStamp tag and store it
 *  The format of the versionStamp is as follows:
 *  <versionStamp>value up to 64 chars</versionStamp>
 *
 *  Returns: 0 - if the version stamp is successfully parsed.
 *           1 - if the version stamp  parsing fails.
 */
static int
ParseDialVersion (char **parseptr)
{
    ParseDialState state = STATE_ANY;
    char version_stamp[MAX_DP_VERSION_STAMP_LEN] = { 0 };
    int len;

    for (;;) {
        char buffer[MAX_DP_VERSION_STAMP_LEN];
        XMLToken tok;

        tok = parse_xml_tokens(parseptr, buffer, sizeof(buffer));
        switch (tok) {
        case TOK_KEYWORD:
            switch (state) {
            case STATE_START_TAG_COMPLETED:
                /*
                 * the keyword is version stamp value here. copy it temporarily.
                 */
                memcpy(version_stamp, buffer, MAX_DP_VERSION_STAMP_LEN);
                break;
            case STATE_END_TAG_STARTED:
                if (cpr_strcasecmp(buffer, "versionStamp") != 0) {
                    return 1;
                }
                state = STATE_END_TAG_FOUND;
                break;

            default:
                break;
            }
            break;

        case TOK_RBRACKET:     /* ">" */
            if (state == STATE_ANY) {
                state = STATE_START_TAG_COMPLETED;
            } else if (state == STATE_END_TAG_FOUND) {
                /* strip of the warping curly braces if they exist */
                len = strlen(version_stamp);
                if (len <= 2)
                {
                    CCAPP_ERROR("ParseDialVersion(): Version length [%d] is way too small", len);
                    return (1);
                }

                memset(g_dp_version_stamp, 0, MAX_DP_VERSION_STAMP_LEN);
                if ((version_stamp[0] == '{')
                    && (version_stamp[len - 1] == '}')) {
                    memcpy(g_dp_version_stamp, (version_stamp + 1), (len - 2));
                } else {
                    memcpy(g_dp_version_stamp, version_stamp, len);
                }
                return 0;
            } else {
                return 1;
            }
            break;

        case TOK_ENDLBRACKET:  /* "</" */
            if (state == STATE_START_TAG_COMPLETED) {
                state = STATE_END_TAG_STARTED;
            } else {
                return 1;
            }
            break;

        default:
            /*
             * Problem parsing. Let them know
             */
            return 1;
        }
    }
}
Пример #17
0
/*
 * parse_user_node
 *
 * Do user node specific parsing.
 *
 * Assumes a_node, info are not null.
 */
static void 
parse_user_node (xmlNode * a_node, cc_call_conference_Info_t *info) 
{
    xmlChar *data;
    xmlNode *cur_node;
    cc_call_conferenceParticipant_Info_t *participant;
    sll_lite_return_e sll_ret_val;

    //allocate a new participant
    participant = cpr_malloc(sizeof(cc_call_conferenceParticipant_Info_t)); 
    if (participant == NULL) {
        CCAPP_ERROR(DEB_F_PREFIX" Malloc failure for participant\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONFPARSE"));
        return;
    } else {
        participant->participantName            = strlib_empty();
        participant->endpointUri                = strlib_empty();
        participant->callid                     = strlib_empty();
        participant->participantNumber          = strlib_empty();
        participant->participantSecurity        = CC_SECURITY_NONE; 
        participant->participantStatus          = CCAPI_CONFPARTICIPANT_UNKNOWN; 
        participant->canRemoveOtherParticipants = FALSE;
    }

    sll_ret_val = sll_lite_link_tail(&info->currentParticipantsList, (sll_lite_node_t *)participant);
    if (sll_ret_val != SLL_LITE_RET_SUCCESS) {
        CCAPP_ERROR(DEB_F_PREFIX" Error while trying to insert in the linked list\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONFPARSE"));
        cpr_free(participant);
        return;
    }

    data = xmlGetProp(a_node, (const xmlChar *) "entity");
    if (data != NULL) {
    	char *tmp2;
    	char *tmp1;
        participant->endpointUri = strlib_update(participant->endpointUri, (const char*)data);

        // Parse the endpoint URI, to get the Participant number

        tmp1 = (char *) strstr((const char*)data, "sip:");
        if (tmp1) {
            tmp1 += 4;
            tmp2 = (char *) strchr(tmp1, '@');
            if (tmp2) {
                *tmp2 = 0;
                participant->participantNumber = strlib_update(participant->participantNumber, (const char*)tmp1);
            }
        }
        xmlFree(data);
    } else {
        //continue parsing other elements
        CCAPP_ERROR(DEB_F_PREFIX" Error while trying to find the endpoint URI\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONFPARSE"));
    }

    for (cur_node = a_node->children; cur_node != NULL; cur_node = cur_node->next) {
        if (cur_node->type == XML_ELEMENT_NODE) {
            if (xmlStrcmp(cur_node->name, (const xmlChar *) "endpoint") == 0) {
                parse_user_endpoint_node(cur_node, participant, info);
            } else if (xmlStrcmp(cur_node->name, (const xmlChar *) "display-text") == 0) { 
                data = xmlNodeGetContent(cur_node); 
                if (data != NULL) {
                    participant->participantName = strlib_update(participant->participantName, (const char*)data);
                    xmlFree(data);
                } else {
                    //No display text - continue parsing other elements -
                    CCAPP_ERROR(DEB_F_PREFIX" Error while trying to get the display text\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, "CCAPI-CONFPARSE"));
                }
            }
        }
    }
}
Пример #18
0
/**
 * Inserts localized strings into existing strings with escape characters.
 * @param destination the return phrase holder
 * @param source the phrase with escape characters.
 * @param len the input length to cap the maximum value
 * @return pointer to the new string
 */
cc_string_t ccsnap_EscapeStrToLocaleStr(cc_string_t destination, cc_string_t source, int len)
{
	static const char *fname="ccsnap_EscapeStrToLocaleStr";
	char phrase_collector[MAX_LOCALE_STRING_LEN] = { '\0' };
	char* phrase_collector_ptr = phrase_collector;
	char* esc_string_itr = (char*)source;
	int remaining_length = 0;
	cc_string_t ret_str = strlib_empty();

	if(destination == NULL){
		CCAPP_DEBUG(DEB_F_PREFIX"Error: destination is NULL\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname));
		return NULL;
	}

	if(source == NULL){
		CCAPP_DEBUG(DEB_F_PREFIX"Error: source is NULL\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname));
		strlib_free(destination);
		return strlib_empty();
	}

	if(source[0] == '\0'){
		strlib_free(destination);
		return strlib_empty();
	}

	if (len == LEN_UNKNOWN) {
		len = strlen(source) + MAX_LOCALE_PHRASE_LEN;
	}

	if (len <= 0){
		CCAPP_DEBUG(DEB_F_PREFIX"Error: cannot write string of length <= 0\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname));
		strlib_free(destination);
		return strlib_empty();
	}

	if (len > MAX_LOCALE_STRING_LEN){
		len = MAX_LOCALE_STRING_LEN;
	}

	remaining_length = len;
	while(  *esc_string_itr != NUL    &&
			remaining_length > 0     &&
			strlen(phrase_collector_ptr) < (size_t)(len-1))
	{
		int rtn = CC_SUCCESS;
		int phrase_index = 0;
                char* phrase_bucket_ptr = (char*)cpr_malloc(remaining_length * sizeof(char));

                if (phrase_bucket_ptr == NULL) {
                    CCAPP_ERROR(DEB_F_PREFIX"Error: phrase_bucket_ptr is NULL\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname));
                    strlib_free(destination);
                    return NULL;
                }
                phrase_bucket_ptr[0] = '\0';
		switch(*esc_string_itr){
		case OLD_CUCM_DICTIONARY_ESCAPE_TAG:
			phrase_index += CALL_CONTROL_PHRASE_OFFSET;
			// Do not set break to combine common code
		case NEW_CUCM_DICTIONARY_ESCAPE_TAG:
			esc_string_itr++;
			phrase_index += (int)(*esc_string_itr);
			rtn = platGetPhraseText(phrase_index, phrase_bucket_ptr, remaining_length-1);
			if(rtn == CC_FAILURE) break;
			sstrncat(phrase_collector_ptr, (cc_string_t)phrase_bucket_ptr, remaining_length);
			remaining_length--;
			break;
		default:
			// We need length 2 to concat 1 char and a terminating char
			sstrncat(phrase_collector_ptr, esc_string_itr, 1 + sizeof(char));
			remaining_length--;
			break;
		}
		esc_string_itr++;
                cpr_free(phrase_bucket_ptr);
	}

    ret_str = strlib_malloc(phrase_collector_ptr, len);

    if (!ret_str) {
        /*
         * If a malloc error occurred, give them back what they had.
         * It's not right, but it's better than nothing.
         */
        ret_str = destination;
    } else {
        strlib_free(destination);
    }

    CCAPP_DEBUG(DEB_F_PREFIX"Localization String returning %s\n", DEB_F_PREFIX_ARGS(SIP_CC_PROV, fname), ret_str);
    return (ret_str);
}