Changed pjsip_inv_send_msg() function

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@324 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/include/pjsip-ua/sip_inv.h b/pjsip/include/pjsip-ua/sip_inv.h
index 4939c9d..c85795a 100644
--- a/pjsip/include/pjsip-ua/sip_inv.h
+++ b/pjsip/include/pjsip-ua/sip_inv.h
@@ -186,13 +186,11 @@
  * occurences of events in invite sessions.
  *
  * @param endpt		The endpoint instance.
- * @param app_module	Application module.
  * @param callback	Callback structure.
  *
  * @return		PJ_SUCCESS on success, or the appropriate error code.
  */
 PJ_DECL(pj_status_t) pjsip_inv_usage_init(pjsip_endpoint *endpt,
-					  pjsip_module *app_module,
 					  const pjsip_inv_callback *cb);
 
 /**
@@ -518,11 +516,6 @@
  *
  * @param inv		The invite session.
  * @param tdata		The message to be sent.
- * @param token		The token is an arbitrary application data that 
- *			will be put in the transaction's mod_data array, 
- *			at application module's index. Application can inspect
- *			this value when the framework reports the completion
- *			of the transaction that sends this message.
  *
  * @return		PJ_SUCCESS if transaction can be initiated 
  *			successfully to send this message. Note that the
@@ -531,8 +524,7 @@
  *			callback.
  */
 PJ_DECL(pj_status_t) pjsip_inv_send_msg(pjsip_inv_session *inv,
-					pjsip_tx_data *tdata,
-					void *token );
+					pjsip_tx_data *tdata);
 
 
 
@@ -558,6 +550,15 @@
 PJ_DECL(pjsip_inv_session*) pjsip_tsx_get_inv_session(pjsip_transaction *tsx);
 
 
+/**
+ * Get state names for INVITE session state.
+ *
+ * @param state		The invite state.
+ *
+ * @return		String describing the state.
+ */
+PJ_DECL(const char *) pjsip_inv_state_name(pjsip_inv_state state);
+
 
 PJ_END_DECL
 
diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c
index c0e241d..54acb0a 100644
--- a/pjsip/src/pjsip-ua/sip_inv.c
+++ b/pjsip/src/pjsip-ua/sip_inv.c
@@ -33,6 +33,18 @@
 
 #define THIS_FILE	"sip_invite_session.c"
 
+static const char *inv_state_names[] =
+{
+    "NULL      ",
+    "CALLING   ",
+    "INCOMING  ",
+    "EARLY     ",
+    "CONNECTING",
+    "CONFIRMED ",
+    "DISCONNCTD",
+    "TERMINATED",
+};
+
 /*
  * Static prototypes.
  */
@@ -66,7 +78,6 @@
     pjsip_module	 mod;
     pjsip_endpoint	*endpt;
     pjsip_inv_callback	 cb;
-    pjsip_module	*app_user;
 } mod_inv = 
 {
     {
@@ -316,13 +327,12 @@
  * Initialize the invite module.
  */
 PJ_DEF(pj_status_t) pjsip_inv_usage_init( pjsip_endpoint *endpt,
-					  pjsip_module *app_module,
 					  const pjsip_inv_callback *cb)
 {
     pj_status_t status;
 
     /* Check arguments. */
-    PJ_ASSERT_RETURN(endpt && app_module && cb, PJ_EINVAL);
+    PJ_ASSERT_RETURN(endpt && cb, PJ_EINVAL);
 
     /* Some callbacks are mandatory */
     PJ_ASSERT_RETURN(cb->on_state_changed && cb->on_new_session, PJ_EINVAL);
@@ -334,7 +344,6 @@
     pj_memcpy(&mod_inv.cb, cb, sizeof(pjsip_inv_callback));
 
     mod_inv.endpt = endpt;
-    mod_inv.app_user = app_module;
 
     /* Register the module. */
     status = pjsip_endpt_register_module(endpt, &mod_inv.mod);
@@ -362,6 +371,18 @@
 
 
 /*
+ * Get INVITE state name.
+ */
+PJ_DEF(const char *) pjsip_inv_state_name(pjsip_inv_state state)
+{
+    PJ_ASSERT_RETURN(state >= PJSIP_INV_STATE_NULL && 
+		     state <= PJSIP_INV_STATE_DISCONNECTED,
+		     "??");
+
+    return inv_state_names[state];
+}
+
+/*
  * Create UAC invite session.
  */
 PJ_DEF(pj_status_t) pjsip_inv_create_uac( pjsip_dialog *dlg,
@@ -1548,8 +1569,7 @@
  * Send a request or response message.
  */
 PJ_DEF(pj_status_t) pjsip_inv_send_msg( pjsip_inv_session *inv,
-					pjsip_tx_data *tdata,
-					void *token )
+					pjsip_tx_data *tdata)
 {
     pj_status_t status;
 
@@ -1571,7 +1591,6 @@
 	tsx_inv_data->inv = inv;
 
 	tsx->mod_data[mod_inv.mod.id] = tsx_inv_data;
-	tsx->mod_data[mod_inv.app_user->id] = token;
 
     } else {
 	pjsip_cseq_hdr *cseq;
@@ -1717,7 +1736,7 @@
 	    
 	} else {
 	    /* Re-send BYE. */
-	    status = pjsip_inv_send_msg(inv, tdata, NULL );
+	    status = pjsip_inv_send_msg(inv, tdata);
 	}
 
     } else {
@@ -1851,7 +1870,7 @@
 		    inv->invite_tsx = NULL;
 
 		    /* Send the request. */
-		    status = pjsip_inv_send_msg(inv, tdata, NULL );
+		    status = pjsip_inv_send_msg(inv, tdata);
 		}
 
 	    } else {
@@ -2271,7 +2290,7 @@
 	    if (status != PJ_SUCCESS)
 		return;
 
-	    status = pjsip_inv_send_msg(inv, tdata, NULL);
+	    status = pjsip_inv_send_msg(inv, tdata);
 
 	}
 
@@ -2310,7 +2329,7 @@
 		return;
 
 	    /* Send re-INVITE */
-	    status = pjsip_inv_send_msg( inv, tdata, NULL);
+	    status = pjsip_inv_send_msg( inv, tdata);
 
 	} else if (tsx->status_code==PJSIP_SC_CALL_TSX_DOES_NOT_EXIST ||
 		   tsx->status_code==PJSIP_SC_REQUEST_TIMEOUT ||
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index 25f6f8a..ea84746 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -190,7 +190,7 @@
 
     /* Send initial INVITE: */
 
-    status = pjsip_inv_send_msg(inv, tdata, NULL);
+    status = pjsip_inv_send_msg(inv, tdata);
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to send initial INVITE request", 
 		     status);
@@ -374,7 +374,7 @@
 	return PJ_TRUE;
 
     } else {
-	status = pjsip_inv_send_msg(inv, response, NULL);
+	status = pjsip_inv_send_msg(inv, response);
 	if (status != PJ_SUCCESS)
 	    pjsua_perror(THIS_FILE, "Unable to send 100 response", status);
     }
@@ -836,7 +836,7 @@
 
     status = pjsip_inv_end_session(inv, st_code, NULL, &tdata);
     if (status == PJ_SUCCESS)
-	status = pjsip_inv_send_msg(inv, tdata, NULL);
+	status = pjsip_inv_send_msg(inv, tdata);
 
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to disconnect call", status);
@@ -870,7 +870,7 @@
 	if (inv->state != PJSIP_INV_STATE_NULL &&
 	    inv->state != PJSIP_INV_STATE_CONFIRMED) 
 	{
-	    call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE);
+	    //call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE);
 	}
 	return;
 
@@ -891,7 +891,7 @@
 	pjsua_perror(THIS_FILE, 
 		     "Unable to retrieve currently active local SDP", 
 		     status);
-	call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE);
+	//call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE);
 	return;
     }
 
@@ -901,7 +901,7 @@
 	pjsua_perror(THIS_FILE, 
 		     "Unable to retrieve currently active remote SDP", 
 		     status);
-	call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE);
+	//call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE);
 	return;
     }
 
@@ -919,7 +919,7 @@
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to create media session", 
 		     status);
-	call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE);
+	//call_disconnect(inv, PJSIP_SC_UNSUPPORTED_MEDIA_TYPE);
 	return;
     }
 
@@ -949,7 +949,7 @@
 		     status);
 	pjmedia_session_destroy(call->session);
 	call->session = NULL;
-	call_disconnect(inv, PJSIP_SC_INTERNAL_SERVER_ERROR);
+	//call_disconnect(inv, PJSIP_SC_INTERNAL_SERVER_ERROR);
 	return;
     }
 
@@ -1079,7 +1079,7 @@
     if (tdata == NULL)
 	return;
 
-    status = pjsip_inv_send_msg(call->inv, tdata, NULL);
+    status = pjsip_inv_send_msg(call->inv, tdata);
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, 
 		     "Failed to send end session message", 
@@ -1122,7 +1122,7 @@
 	return;
     }
 
-    status = pjsip_inv_send_msg( call->inv, tdata, NULL);
+    status = pjsip_inv_send_msg( call->inv, tdata);
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status);
 	return;
@@ -1169,7 +1169,7 @@
 	return;
     }
 
-    status = pjsip_inv_send_msg( call->inv, tdata, NULL);
+    status = pjsip_inv_send_msg( call->inv, tdata);
     if (status != PJ_SUCCESS) {
 	pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status);
 	return;
@@ -1352,7 +1352,7 @@
 
 	if (pjsip_inv_end_session(call->inv, st_code, NULL, &tdata)==0) {
 	    if (tdata)
-		pjsip_inv_send_msg(call->inv, tdata, NULL);
+		pjsip_inv_send_msg(call->inv, tdata);
 	}
     }
 }
@@ -1373,7 +1373,7 @@
 
 
     /* Initialize invite session module: */
-    status = pjsip_inv_usage_init(pjsua.endpt, &pjsua.mod, &inv_cb);
+    status = pjsip_inv_usage_init(pjsua.endpt, &inv_cb);
     
     return status;
 }