コード例 #1
0
int sal_notify_close(SalOp *op){
	osip_message_t *msg=NULL;
	eXosip_lock();
	eXosip_insubscription_build_notify(op->did,EXOSIP_SUBCRSTATE_TERMINATED,DEACTIVATED,&msg);
	if (msg!=NULL){
		const char *identity=sal_op_get_contact(op);
		if (identity==NULL) identity=sal_op_get_to(op);
		osip_message_set_contact(msg,identity);
		add_presence_body(msg,SalPresenceOffline);
		eXosip_insubscription_send_request(op->did,msg);
	}else ms_error("sal_notify_close(): could not create notify for incoming subscription"
	    " did=%i, nid=%i",op->did,op->nid);
	eXosip_unlock();
	return 0;
}
コード例 #2
0
int sal_notify_presence(SalOp *op, SalPresenceStatus status, const char *status_message){
	osip_message_t *msg=NULL;
	eXosip_ss_t ss=EXOSIP_SUBCRSTATE_ACTIVE;
	if (op->nid==-1){
		ms_warning("Cannot notify, subscription was closed.");
		return -1;
	}
	
	eXosip_lock();
	eXosip_insubscription_build_notify(op->did,ss,DEACTIVATED,&msg);
	if (msg!=NULL){
		const char *identity=sal_op_get_contact(op);
		if (identity==NULL) identity=sal_op_get_to(op);
		_osip_list_set_empty(&msg->contacts,(void (*)(void*))osip_contact_free);
		osip_message_set_contact(msg,identity);
		add_presence_body(msg,status);
		eXosip_insubscription_send_request(op->did,msg);
	}else ms_error("could not create notify for incoming subscription.");
	eXosip_unlock();
	return 0;
}
コード例 #3
0
int
_eXosip_insubscription_auto_send_notify (int did,
                                         int subscription_status,
                                         int subscription_reason)
{
  osip_message_t *notify;
  int i;
  char xml[4096];
  char *entity;
  eXosip_call_t *jc;
  eXosip_dialog_t *jd;

  if (did <= 0)
    return OSIP_BADPARAMETER;

  i = eXosip_insubscription_build_notify (did, subscription_status,
                                          subscription_reason, &notify);
  if (i != 0)
    {
      return i;
    }

  /* build dialog xml state */
  memset (xml, 0, sizeof (xml));

  i = osip_uri_to_str (notify->from->url, &entity);
  if (i != 0 || entity == NULL)
    {
      osip_message_free (notify);
      return i;
    }
  snprintf (xml, sizeof (xml),
            "<?xml version=\"1.0\"?>" "\r\n"
            "<dialog-info xmlns=\"urn:ietf:params:xml:ns:dialog-info\"" "\r\n"
            "	version=\"2\" state=\"full\"" "\r\n"
            "	entity=\"%s\">" "\r\n", entity);
  osip_free (entity);

  /* loop over all jc/jd */
  for (jc = eXosip.j_calls; jc != NULL; jc = jc->next)
    {
      for (jd = jc->c_dialogs; jd != NULL; jd = jd->next)
        {
          if (jd->d_dialog == NULL)     /* finished call */
            {
          } else
            {
              char tmp_dialog[2048];
              char direction[20];
              char dlg_state[20];
              char *remote_uri = NULL;

              if (jd->d_dialog->type == CALLER)
                strcpy (direction, "initiator");
              else
                strcpy (direction, "recipient");
              if (jd->d_dialog->state == DIALOG_CONFIRMED)
                strcpy (dlg_state, "confirmed");
              else
                strcpy (dlg_state, "early");

              if (jd->d_dialog->remote_uri != NULL
                  && jd->d_dialog->remote_uri->url != NULL)
                {
                  osip_uri_to_str (jd->d_dialog->remote_uri->url, &remote_uri);
                }
              if (remote_uri != NULL)
                {
                  /* add dialog info */
                  snprintf (tmp_dialog, sizeof (tmp_dialog),
                            "	<dialog id=\"%s\" call-id=\"%s\"" "\r\n"
                            "		local-tag=\"%s\" remote-tag=\"%s\""
                            "\r\n" "		direction=\"%s\">"
                            "\r\n"
                            "		<state>%s</state>"
                            "\r\n"
                            "		<remote>"
                            "\r\n"
                            "			<identity>%s</identity>"
                            "\r\n"
                            "		</remote>"
                            "\r\n"
                            "	</dialog>"
                            "\r\n",
                            jd->
                            d_dialog->
                            call_id,
                            jd->
                            d_dialog->
                            call_id,
                            jd->
                            d_dialog->
                            local_tag,
                            jd->
                            d_dialog->
                            remote_tag, direction, dlg_state, remote_uri);
                  strcat (xml, tmp_dialog);
                }
            }
        }
    }
  strcat (xml, "</dialog-info>" "\r\n");
  osip_message_set_content_type (notify, "application/dialog-info+xml");
  osip_message_set_body (notify, xml, strlen (xml));

  return eXosip_insubscription_send_request (did, notify);
}