Fixed bug in event subscription when it is challenged/authenticated

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@424 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c
index 9a9b852..7b13d54 100644
--- a/pjsip/src/pjsip-simple/evsub.c
+++ b/pjsip/src/pjsip-simple/evsub.c
@@ -1355,10 +1355,6 @@
 
 	sub->pending_sub = tsx;
 
-    } else if (tsx == sub->pending_sub &&
-	       tsx->state >= PJSIP_TSX_STATE_COMPLETED)
-    {
-	sub->pending_sub = NULL;
     }
 
     return sub;
@@ -1468,6 +1464,10 @@
 	    return;
 	}
 
+	/* Clear pending subscription */
+	if (tsx == sub->pending_sub)
+	    sub->pending_sub = NULL;
+
 	/* Handle authentication. */
 	if (tsx->status_code==401 || tsx->status_code==407) {
 	    pjsip_tx_data *tdata;
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 034262a..3530932 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -683,19 +683,9 @@
 #endif	/* PJMEDIA_HAS_L16_CODEC */
 
 
-    /* If user specifies the exact codec to be used, then disable all codecs
-     * and only enable those specific codecs.
+    /* Enable those codecs that user put with "--add-codec", and move
+     * the priority to top
      */
-    if (pjsua.codec_cnt != 0) {
-	codec_id = pj_str("");
-	pjmedia_codec_mgr_set_codec_priority( 
-	    pjmedia_endpt_get_codec_mgr(pjsua.med_endpt),
-	    &codec_id, 
-	    PJMEDIA_CODEC_PRIO_DISABLED);
-    }
-
-	
-
     for (i=0; i<pjsua.codec_cnt; ++i) {
 	pjmedia_codec_mgr_set_codec_priority( 
 	    pjmedia_endpt_get_codec_mgr(pjsua.med_endpt),
diff --git a/pjsip/src/pjsua-lib/pjsua_pres.c b/pjsip/src/pjsua-lib/pjsua_pres.c
index f0774d5..b77871f 100644
--- a/pjsip/src/pjsua-lib/pjsua_pres.c
+++ b/pjsip/src/pjsua-lib/pjsua_pres.c
@@ -323,6 +323,9 @@
 	return;
     }
 
+    pjsip_auth_clt_set_credentials( &dlg->auth_sess, pjsua.cred_count,
+				    pjsua.cred_info);
+
     status = pjsip_pres_create_uac( dlg, &pres_callback, 
 				    &pjsua.buddies[index].sub);
     if (status != PJ_SUCCESS) {