Index: /pjproject/branches/projects/ice-turn07/pjsip/src/pjsua-lib/pjsua_acc.c
===================================================================
--- /pjproject/branches/projects/ice-turn07/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 1929)
+++ /pjproject/branches/projects/ice-turn07/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 1930)
@@ -566,4 +566,5 @@
 	pjsip_regc_destroy(acc->regc);
 	acc->regc = NULL;
+	acc->contact.slen = 0;
     }
 
@@ -854,4 +855,5 @@
 	pjsip_regc_destroy(acc->regc);
 	acc->regc = NULL;
+	acc->contact.slen = 0;
 	
 	/* Stop keep-alive timer if any. */
@@ -864,4 +866,5 @@
 	pjsip_regc_destroy(acc->regc);
 	acc->regc = NULL;
+	acc->contact.slen = 0;
 
 	/* Stop keep-alive timer if any. */
@@ -873,4 +876,5 @@
 	    pjsip_regc_destroy(acc->regc);
 	    acc->regc = NULL;
+	    acc->contact.slen = 0;
 
 	    /* Stop keep-alive timer if any. */
@@ -941,4 +945,5 @@
 	pjsip_regc_destroy(acc->regc);
 	acc->regc = NULL;
+	acc->contact.slen = 0;
     }
 
@@ -987,4 +992,5 @@
 	pj_pool_release(pool);
 	acc->regc = NULL;
+	acc->contact.slen = 0;
 	return status;
     }
Index: /pjproject/branches/projects/ice-turn07/pjsip/src/pjsua-lib/pjsua_call.c
===================================================================
--- /pjproject/branches/projects/ice-turn07/pjsip/src/pjsua-lib/pjsua_call.c	(revision 1929)
+++ /pjproject/branches/projects/ice-turn07/pjsip/src/pjsua-lib/pjsua_call.c	(revision 1930)
@@ -406,11 +406,18 @@
     call->res_time.sec = 0;
 
-    /* Create suitable Contact header */
-    status = pjsua_acc_create_uac_contact(pjsua_var.pool, &contact,
-					  acc_id, dest_uri);
-    if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Unable to generate Contact header", status);
-	PJSUA_UNLOCK();
-	return status;
+    /* Create suitable Contact header unless a Contact header has been
+     * set in the account.
+     */
+    if (acc->contact.slen) {
+	contact = acc->contact;
+    } else {
+	status = pjsua_acc_create_uac_contact(pjsua_var.pool, &contact,
+					      acc_id, dest_uri);
+	if (status != PJ_SUCCESS) {
+	    pjsua_perror(THIS_FILE, "Unable to generate Contact header", 
+			 status);
+	    PJSUA_UNLOCK();
+	    return status;
+	}
     }
 
@@ -788,13 +795,18 @@
 
     /* Get suitable Contact header */
-    status = pjsua_acc_create_uas_contact(rdata->tp_info.pool, &contact,
-					  acc_id, rdata);
-    if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Unable to generate Contact header", status);
-	pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL,
-				      NULL, NULL);
-	pjsua_media_channel_deinit(call->index);
-	PJSUA_UNLOCK();
-	return PJ_TRUE;
+    if (pjsua_var.acc[acc_id].contact.slen) {
+	contact = pjsua_var.acc[acc_id].contact;
+    } else {
+	status = pjsua_acc_create_uas_contact(rdata->tp_info.pool, &contact,
+					      acc_id, rdata);
+	if (status != PJ_SUCCESS) {
+	    pjsua_perror(THIS_FILE, "Unable to generate Contact header", 
+			 status);
+	    pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL,
+					  NULL, NULL);
+	    pjsua_media_channel_deinit(call->index);
+	    PJSUA_UNLOCK();
+	    return PJ_TRUE;
+	}
     }
 
Index: /pjproject/branches/projects/ice-turn07/pjsip/src/pjsua-lib/pjsua_pres.c
===================================================================
--- /pjproject/branches/projects/ice-turn07/pjsip/src/pjsua-lib/pjsua_pres.c	(revision 1929)
+++ /pjproject/branches/projects/ice-turn07/pjsip/src/pjsua-lib/pjsua_pres.c	(revision 1930)
@@ -553,10 +553,15 @@
     
     /* Create suitable Contact header */
-    status = pjsua_acc_create_uas_contact(rdata->tp_info.pool, &contact,
-					  acc_id, rdata);
-    if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Unable to generate Contact header", status);
-	PJSUA_UNLOCK();
-	return PJ_TRUE;
+    if (acc->contact.slen) {
+	contact = acc->contact;
+    } else {
+	status = pjsua_acc_create_uas_contact(rdata->tp_info.pool, &contact,
+					      acc_id, rdata);
+	if (status != PJ_SUCCESS) {
+	    pjsua_perror(THIS_FILE, "Unable to generate Contact header", 
+			 status);
+	    PJSUA_UNLOCK();
+	    return PJ_TRUE;
+	}
     }
 
@@ -1124,10 +1129,17 @@
 			 acc_id, index));
 
-    /* Generate suitable Contact header */
-    status = pjsua_acc_create_uac_contact(pjsua_var.pool, &contact,
-					  acc_id, &buddy->uri);
-    if (status != PJ_SUCCESS) {
-	pjsua_perror(THIS_FILE, "Unable to generate Contact header", status);
-	return;
+    /* Generate suitable Contact header unless one is already set in
+     * the account
+     */
+    if (acc->contact.slen) {
+	contact = acc->contact;
+    } else {
+	status = pjsua_acc_create_uac_contact(pjsua_var.pool, &contact,
+					      acc_id, &buddy->uri);
+	if (status != PJ_SUCCESS) {
+	    pjsua_perror(THIS_FILE, "Unable to generate Contact header", 
+		         status);
+	    return;
+	}
     }
 
