SIMPLE test with FWD, and added more info in UI

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@201 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/src/pjsua/main.c b/pjsip/src/pjsua/main.c
index 4a40d32..66d4de4 100644
--- a/pjsip/src/pjsua/main.c
+++ b/pjsip/src/pjsua/main.c
@@ -98,8 +98,31 @@
  */
 static void keystroke_help(void)
 {
+    char reg_status[128];
 
-    printf(">>>>\nOnline status: %s\n", 
+    if (pjsua.regc == NULL) {
+	pj_ansi_strcpy(reg_status, " -not registered to server-");
+    } else if (pjsua.regc_last_err != PJ_SUCCESS) {
+	pj_strerror(pjsua.regc_last_err, reg_status, sizeof(reg_status));
+    } else if (pjsua.regc_last_code>=200 && pjsua.regc_last_code<=699) {
+
+	pjsip_regc_info info;
+
+	pjsip_regc_get_info(pjsua.regc, &info);
+
+	pj_snprintf(reg_status, sizeof(reg_status),
+		    "%s (%.*s;expires=%d)",
+		    pjsip_get_status_text(pjsua.regc_last_code)->ptr,
+		    (int)info.server_uri.slen,
+		    info.server_uri.ptr,
+		    info.next_reg);
+
+    } else {
+	pj_sprintf(reg_status, "in progress (%d)", pjsua.regc_last_code);
+    }
+
+    printf(">>>>\nRegistration status: %s\n", reg_status);
+    printf("Online status: %s\n", 
 	   (pjsua.online_status ? "Online" : "Invisible"));
     print_buddy_list();
     
@@ -108,9 +131,9 @@
     puts("|       Call Commands:         |      IM & Presence:      |   Misc:           |");
     puts("|                              |                          |                   |");
     puts("|  m  Make new call            |  i  Send IM              |  o  Send OPTIONS  |");
-    puts("|  a  Answer call              |  s  Subscribe presence   |  d  Dump status   |");
-    puts("|  h  Hangup call              |  u  Unsubscribe presence |  d1 Dump detailed |");
-    puts("|  ]  Select next dialog       |  t  Toggle Online status |                   |");
+    puts("|  a  Answer call              |  s  Subscribe presence   |  R  (Re-)register |");
+    puts("|  h  Hangup call              |  u  Unsubscribe presence |  r  Unregister    |");
+    puts("|  ]  Select next dialog       |  t  Toggle Online status |  d  Dump status   |");
     puts("|  [  Select previous dialog   |                          |                   |");
     puts("+-----------------------------------------------------------------------------+");
     puts("|  q  QUIT                                                                    |");
@@ -223,7 +246,7 @@
 	pj_status_t status;
 
 	if ((status=pjsua_verify_sip_url(buf)) != PJ_SUCCESS) {
-	    pjsua_perror("Invalid URL", status);
+	    pjsua_perror(THIS_FILE, "Invalid URL", status);
 	    return;
 	}
 
@@ -290,7 +313,8 @@
 		    status = pjsip_inv_send_msg(inv_session->inv, tdata, NULL);
 
 		if (status != PJ_SUCCESS)
-		    pjsua_perror("Unable to create/send response", status);
+		    pjsua_perror(THIS_FILE, "Unable to create/send response", 
+				 status);
 	    }
 
 	    break;
@@ -310,13 +334,17 @@
 		status = pjsip_inv_end_session(inv_session->inv, 
 					       PJSIP_SC_DECLINE, NULL, &tdata);
 		if (status != PJ_SUCCESS) {
-		    pjsua_perror("Failed to create end session message", status);
+		    pjsua_perror(THIS_FILE, 
+				 "Failed to create end session message", 
+				 status);
 		    continue;
 		}
 
 		status = pjsip_inv_send_msg(inv_session->inv, tdata, NULL);
 		if (status != PJ_SUCCESS) {
-		    pjsua_perror("Failed to send end session message", status);
+		    pjsua_perror(THIS_FILE, 
+				 "Failed to send end session message", 
+				 status);
 		    continue;
 		}
 	    }
@@ -354,6 +382,14 @@
 
 	    break;
 
+	case 'R':
+	    pjsua_regc_update(PJ_TRUE);
+	    break;
+	    
+	case 'r':
+	    pjsua_regc_update(PJ_FALSE);
+	    break;
+
 	case 't':
 	    pjsua.online_status = !pjsua.online_status;
 	    pjsua_pres_refresh();
@@ -500,13 +536,14 @@
 /*
  * Display error message for the specified error code.
  */
-void pjsua_perror(const char *title, pj_status_t status)
+void pjsua_perror(const char *sender, const char *title, 
+		  pj_status_t status)
 {
     char errmsg[PJ_ERR_MSG_SIZE];
 
     pj_strerror(status, errmsg, sizeof(errmsg));
 
-    PJ_LOG(1,(THIS_FILE, "%s: %s [code=%d]", title, errmsg, status));
+    PJ_LOG(1,(sender, "%s: %s [code=%d]", title, errmsg, status));
 }
 
 
diff --git a/pjsip/src/pjsua/pjsua.h b/pjsip/src/pjsua/pjsua.h
index 202c284..6bd19d5 100644
--- a/pjsip/src/pjsua/pjsua.h
+++ b/pjsip/src/pjsua/pjsua.h
@@ -127,6 +127,7 @@
     pjsip_regc	    *regc;
     pj_int32_t	     reg_timeout;
     pj_timer_entry   regc_timer;
+    pj_status_t	     regc_last_err; /**< Last registration error.	*/
     int		     regc_last_code;/**< Last status last register.	*/
 
 
@@ -199,7 +200,8 @@
 /**
  * Display error message for the specified error code.
  */
-void pjsua_perror(const char *title, pj_status_t status);
+void pjsua_perror(const char *sender, const char *title, 
+		  pj_status_t status);
 
 
 /**
diff --git a/pjsip/src/pjsua/pjsua_core.c b/pjsip/src/pjsua/pjsua_core.c
index 2d059d9..7556020 100644
--- a/pjsip/src/pjsua/pjsua_core.c
+++ b/pjsip/src/pjsua/pjsua_core.c
@@ -72,6 +72,10 @@
 
     pjsua.local_uri = pj_str(PJSUA_LOCAL_URI);
 
+    /* Default registration timeout: */
+
+    pjsua.reg_timeout = 55;
+
     /* Init route set list: */
 
     pj_list_init(&pjsua.route_set);
@@ -155,13 +159,13 @@
     /* Create and bind SIP UDP socket. */
     status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock[SIP_SOCK]);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("socket() error", status);
+	pjsua_perror(THIS_FILE, "socket() error", status);
 	goto on_error;
     }
     
     status = pj_sock_bind_in(sock[SIP_SOCK], 0, pjsua.sip_port);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("bind() error", status);
+	pjsua_perror(THIS_FILE, "bind() error", status);
 	goto on_error;
     }
 
@@ -174,7 +178,7 @@
 	/* Create and bind RTP socket. */
 	status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock[RTP_SOCK]);
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror("socket() error", status);
+	    pjsua_perror(THIS_FILE, "socket() error", status);
 	    goto on_error;
 	}
 
@@ -188,7 +192,7 @@
 	/* Create and bind RTCP socket. */
 	status = pj_sock_socket(PJ_AF_INET, PJ_SOCK_DGRAM, 0, &sock[RTCP_SOCK]);
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror("socket() error", status);
+	    pjsua_perror(THIS_FILE, "socket() error", status);
 	    goto on_error;
 	}
 
@@ -217,7 +221,8 @@
 	    addr.sin_family = PJ_AF_INET;
 	    status = pj_sockaddr_in_set_str_addr( &addr, hostname);
 	    if (status != PJ_SUCCESS) {
-		pjsua_perror("Unresolvable local hostname", status);
+		pjsua_perror(THIS_FILE, "Unresolvable local hostname", 
+			     status);
 		goto on_error;
 	    }
 
@@ -234,7 +239,7 @@
 					      &pjsua.stun_srv2, pjsua.stun_port2,
 					      mapped_addr);
 	    if (status != PJ_SUCCESS) {
-		pjsua_perror("STUN error", status);
+		pjsua_perror(THIS_FILE, "STUN error", status);
 		goto on_error;
 	    }
 
@@ -310,7 +315,7 @@
 	status = pjsip_endpt_create(&pjsua.cp.factory, endpt_name, 
 				    &pjsua.endpt);
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror("Unable to create SIP endpoint", status);
+	    pjsua_perror(THIS_FILE, "Unable to create SIP endpoint", status);
 	    return status;
 	}
     }
@@ -320,7 +325,8 @@
 
     status = pjsip_tsx_layer_init(pjsua.endpt);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("Transaction layer initialization error", status);
+	pjsua_perror(THIS_FILE, "Transaction layer initialization error", 
+		     status);
 	goto on_error;
     }
 
@@ -328,7 +334,7 @@
 
     status = pjsip_ua_init( pjsua.endpt, NULL );
     if (status != PJ_SUCCESS) {
-	pjsua_perror("UA layer initialization error", status);
+	pjsua_perror(THIS_FILE, "UA layer initialization error", status);
 	goto on_error;
     }
 
@@ -357,7 +363,8 @@
 
 	status = pjsip_endpt_register_module(pjsua.endpt, &pjsua.mod);
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror("Unable to register pjsua module", status);
+	    pjsua_perror(THIS_FILE, "Unable to register pjsua module", 
+			 status);
 	    goto on_error;
 	}
     }
@@ -377,7 +384,8 @@
 	/* Initialize invite session module: */
 	status = pjsip_inv_usage_init(pjsua.endpt, &pjsua.mod, &inv_cb);
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror("Invite usage initialization error", status);
+	    pjsua_perror(THIS_FILE, "Invite usage initialization error", 
+			 status);
 	    goto on_error;
 	}
 
@@ -427,7 +435,7 @@
 
     status = pj_init();
     if (status != PJ_SUCCESS) {
-	pjsua_perror("pj_init() error", status);
+	pjsua_perror(THIS_FILE, "pj_init() error", status);
 	return status;
     }
 
@@ -445,7 +453,8 @@
     status = init_stack();
     if (status != PJ_SUCCESS) {
 	pj_caching_pool_destroy(&pjsua.cp);
-	pjsua_perror("Stack initialization has returned error", status);
+	pjsua_perror(THIS_FILE, "Stack initialization has returned error", 
+		     status);
 	return status;
     }
 
@@ -469,7 +478,9 @@
     status = pjmedia_endpt_create(&pjsua.cp.factory, &pjsua.med_endpt);
     if (status != PJ_SUCCESS) {
 	pj_caching_pool_destroy(&pjsua.cp);
-	pjsua_perror("Media stack initialization has returned error", status);
+	pjsua_perror(THIS_FILE, 
+		     "Media stack initialization has returned error", 
+		     status);
 	return status;
     }
 
@@ -478,7 +489,9 @@
     status = pjmedia_codec_init(pjsua.med_endpt);
     if (status != PJ_SUCCESS) {
 	pj_caching_pool_destroy(&pjsua.cp);
-	pjsua_perror("Media codec initialization has returned error", status);
+	pjsua_perror(THIS_FILE, 
+		     "Media codec initialization has returned error", 
+		     status);
 	return status;
     }
 
@@ -503,7 +516,8 @@
 
     status = init_sockets();
     if (status != PJ_SUCCESS) {
-	pjsua_perror("init_sockets() has returned error", status);
+	pjsua_perror(THIS_FILE, "init_sockets() has returned error", 
+		     status);
 	return status;
     }
 
@@ -527,7 +541,8 @@
 					     &addr_name, 1, 
 					     &udp_transport);
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror("Unable to start UDP transport", status);
+	    pjsua_perror(THIS_FILE, "Unable to start UDP transport", 
+			 status);
 	    return status;
 	}
     }
@@ -552,7 +567,8 @@
 	uri = pjsip_parse_uri(pjsua.pool, pjsua.local_uri.ptr, 
 			      pjsua.local_uri.slen, 0);
 	if (uri == NULL) {
-	    pjsua_perror("Invalid local URI", PJSIP_EINVALIDURI);
+	    pjsua_perror(THIS_FILE, "Invalid local URI", 
+			 PJSIP_EINVALIDURI);
 	    return PJSIP_EINVALIDURI;
 	}
 
@@ -560,7 +576,8 @@
 	/* Local URI MUST be a SIP or SIPS: */
 
 	if (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri)) {
-	    pjsua_perror("Invalid local URI", PJSIP_EINVALIDSCHEME);
+	    pjsua_perror(THIS_FILE, "Invalid local URI", 
+			 PJSIP_EINVALIDSCHEME);
 	    return PJSIP_EINVALIDSCHEME;
 	}
 
@@ -594,7 +611,7 @@
 	}
 
 	if (len < 1 || len >= sizeof(contact)) {
-	    pjsua_perror("Invalid Contact", PJSIP_EURITOOLONG);
+	    pjsua_perror(THIS_FILE, "Invalid Contact", PJSIP_EURITOOLONG);
 	    return PJSIP_EURITOOLONG;
 	}
 
@@ -617,7 +634,8 @@
 				 pjsua.outbound_proxy.slen,
 				   &parsed_len);
 	if (route == NULL) {
-	    pjsua_perror("Invalid outbound proxy URL", PJSIP_EINVALIDURI);
+	    pjsua_perror(THIS_FILE, "Invalid outbound proxy URL", 
+			 PJSIP_EINVALIDURI);
 	    return PJSIP_EINVALIDURI;
 	}
 
diff --git a/pjsip/src/pjsua/pjsua_inv.c b/pjsip/src/pjsua/pjsua_inv.c
index 6f9607b..bfd714b 100644
--- a/pjsip/src/pjsua/pjsua_inv.c
+++ b/pjsip/src/pjsua/pjsua_inv.c
@@ -53,7 +53,7 @@
 				   &pjsua.contact_uri, &dest_uri, &dest_uri,
 				   &dlg);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("Dialog creation failed", status);
+	pjsua_perror(THIS_FILE, "Dialog creation failed", status);
 	return status;
     }
 
@@ -62,7 +62,7 @@
     status = pjmedia_endpt_create_sdp( pjsua.med_endpt, dlg->pool,
 				       1, &pjsua.med_skinfo, &offer);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("pjmedia unable to create SDP", status);
+	pjsua_perror(THIS_FILE, "pjmedia unable to create SDP", status);
 	goto on_error;
     }
 
@@ -70,7 +70,7 @@
 
     status = pjsip_inv_create_uac( dlg, offer, 0, &inv);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("Invite session creation failed", status);
+	pjsua_perror(THIS_FILE, "Invite session creation failed", status);
 	goto on_error;
     }
 
@@ -99,7 +99,8 @@
 
     status = pjsip_inv_invite(inv, &tdata);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("Unable to create initial INVITE request", status);
+	pjsua_perror(THIS_FILE, "Unable to create initial INVITE request", 
+		     status);
 	goto on_error;
     }
 
@@ -108,7 +109,8 @@
 
     status = pjsip_inv_send_msg(inv, tdata, NULL);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("Unable to send initial INVITE request", status);
+	pjsua_perror(THIS_FILE, "Unable to send initial INVITE request", 
+		     status);
 	goto on_error;
     }
 
@@ -301,7 +303,7 @@
 
     if (status != PJ_SUCCESS) {
 
-	pjsua_perror("SDP negotiation has failed", status);
+	pjsua_perror(THIS_FILE, "SDP negotiation has failed", status);
 	return;
 
     }
@@ -318,14 +320,18 @@
 
     status = pjmedia_sdp_neg_get_active_local(inv->neg, &local_sdp);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("Unable to retrieve currently active local SDP", status);
+	pjsua_perror(THIS_FILE, 
+		     "Unable to retrieve currently active local SDP", 
+		     status);
 	return;
     }
 
 
     status = pjmedia_sdp_neg_get_active_remote(inv->neg, &remote_sdp);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("Unable to retrieve currently active remote SDP", status);
+	pjsua_perror(THIS_FILE, 
+		     "Unable to retrieve currently active remote SDP", 
+		     status);
 	return;
     }
 
@@ -340,7 +346,8 @@
 					 local_sdp, remote_sdp, 
 					 &inv_data->session );
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror("Unable to create media session", status);
+	    pjsua_perror(THIS_FILE, "Unable to create media session", 
+			 status);
 	    return;
 	}
 
diff --git a/pjsip/src/pjsua/pjsua_pres.c b/pjsip/src/pjsua/pjsua_pres.c
index db009ee..8129a82 100644
--- a/pjsip/src/pjsua/pjsua_pres.c
+++ b/pjsip/src/pjsua/pjsua_pres.c
@@ -98,7 +98,9 @@
     status = pjsip_dlg_create_uas( pjsip_ua_instance(), rdata, 
 				   &pjsua.contact_uri, &dlg);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("Unable to create UAS dialog for subscription", status);
+	pjsua_perror(THIS_FILE, 
+		     "Unable to create UAS dialog for subscription", 
+		     status);
 	return PJ_FALSE;
     }
 
@@ -110,7 +112,8 @@
     status = pjsip_pres_create_uas( dlg, &pres_cb, rdata, &sub);
     if (status != PJ_SUCCESS) {
 	PJ_TODO(DESTROY_DIALOG);
-	pjsua_perror("Unable to create server subscription", status);
+	pjsua_perror(THIS_FILE, "Unable to create server subscription", 
+		     status);
 	return PJ_FALSE;
     }
 
@@ -134,7 +137,8 @@
     /* Create and send 200 (OK) to the SUBSCRIBE request: */
     status = pjsip_pres_accept(sub, rdata, 200, NULL);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("Unable to accept presence subscription", status);
+	pjsua_perror(THIS_FILE, "Unable to accept presence subscription", 
+		     status);
 	pj_list_erase(uapres);
 	return PJ_FALSE;
     }
@@ -157,7 +161,8 @@
 	status = pjsip_pres_send_request( sub, tdata);
 
     if (status != PJ_SUCCESS) {
-	pjsua_perror("Unable to create/send NOTIFY", status);
+	pjsua_perror(THIS_FILE, "Unable to create/send NOTIFY", 
+		     status);
 	pj_list_erase(uapres);
 	return PJ_FALSE;
     }
@@ -304,7 +309,8 @@
 				   &pjsua.buddies[index].uri,
 				   NULL, &dlg);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("Unable to create dialog", status);
+	pjsua_perror(THIS_FILE, "Unable to create dialog", 
+		     status);
 	return;
     }
 
@@ -312,7 +318,8 @@
 				    &pjsua.buddies[index].sub);
     if (status != PJ_SUCCESS) {
 	pjsua.buddies[index].sub = NULL;
-	pjsua_perror("Unable to create presence client", status);
+	pjsua_perror(THIS_FILE, "Unable to create presence client", 
+		     status);
 	return;
     }
 
@@ -322,14 +329,16 @@
     status = pjsip_pres_initiate(pjsua.buddies[index].sub, 60, &tdata);
     if (status != PJ_SUCCESS) {
 	pjsua.buddies[index].sub = NULL;
-	pjsua_perror("Unable to create initial SUBSCRIBE", status);
+	pjsua_perror(THIS_FILE, "Unable to create initial SUBSCRIBE", 
+		     status);
 	return;
     }
 
     status = pjsip_pres_send_request(pjsua.buddies[index].sub, tdata);
     if (status != PJ_SUCCESS) {
 	pjsua.buddies[index].sub = NULL;
-	pjsua_perror("Unable to send initial SUBSCRIBE", status);
+	pjsua_perror(THIS_FILE, "Unable to send initial SUBSCRIBE", 
+		     status);
 	return;
     }
 
@@ -364,7 +373,8 @@
 	//pjsua.buddies[index].sub = NULL;
 
     } else {
-	pjsua_perror("Unable to unsubscribe presence", status);
+	pjsua_perror(THIS_FILE, "Unable to unsubscribe presence", 
+		     status);
     }
 }
 
@@ -396,7 +406,8 @@
 
     status = pjsip_endpt_register_module( pjsua.endpt, &mod_pjsua_pres);
     if (status != PJ_SUCCESS) {
-	pjsua_perror("Unable to register pjsua presence module", status);
+	pjsua_perror(THIS_FILE, "Unable to register pjsua presence module", 
+		     status);
     }
 
     return status;
diff --git a/pjsip/src/pjsua/pjsua_reg.c b/pjsip/src/pjsua/pjsua_reg.c
index 972791b..f11ff3f 100644
--- a/pjsip/src/pjsua/pjsua_reg.c
+++ b/pjsip/src/pjsua/pjsua_reg.c
@@ -37,9 +37,15 @@
     /*
      * Print registration status.
      */
-    if (param->code < 0 || param->code >= 300) {
+    if (param->status!=PJ_SUCCESS) {
+	pjsua_perror(THIS_FILE, "SIP registration error", 
+		     param->status);
+	pjsua.regc = NULL;
+	
+    } else if (param->code < 0 || param->code >= 300) {
 	PJ_LOG(2, (THIS_FILE, "SIP registration failed, status=%d (%s)", 
-		   param->code, pjsip_get_status_text(param->code)->ptr));
+		   param->code, 
+		   pjsip_get_status_text(param->code)->ptr));
 	pjsua.regc = NULL;
 
     } else if (PJSIP_IS_STATUS_IN_CLASS(param->code, 200)) {
@@ -53,6 +59,7 @@
 	PJ_LOG(4, (THIS_FILE, "SIP registration updated status=%d", param->code));
     }
 
+    pjsua.regc_last_err = param->status;
     pjsua.regc_last_code = param->code;
 
     pjsua_ui_regc_on_state_changed(pjsua.regc_last_code);
@@ -68,19 +75,33 @@
     pjsip_tx_data *tdata;
 
     if (renew) {
-	PJ_LOG(3,(THIS_FILE, "Performing SIP registration..."));
+	if (pjsua.regc == NULL) {
+	    status = pjsua_regc_init();
+	    if (status != PJ_SUCCESS) {
+		pjsua_perror(THIS_FILE, "Unable to create registration", 
+			     status);
+		return;
+	    }
+	}
 	status = pjsip_regc_register(pjsua.regc, 1, &tdata);
     } else {
-	PJ_LOG(3,(THIS_FILE, "Performing SIP unregistration..."));
+	if (pjsua.regc == NULL) {
+	    PJ_LOG(3,(THIS_FILE, "Currently not registered"));
+	    return;
+	}
 	status = pjsip_regc_unregister(pjsua.regc, &tdata);
     }
 
-    if (status != PJ_SUCCESS) {
-	pjsua_perror("Unable to create REGISTER request", status);
-	return;
-    }
+    if (status == PJ_SUCCESS)
+	status = pjsip_regc_send( pjsua.regc, tdata );
 
-    pjsip_regc_send( pjsua.regc, tdata );
+    if (status != PJ_SUCCESS) {
+	pjsua_perror(THIS_FILE, "Unable to create/send REGISTER", 
+		     status);
+    } else {
+	PJ_LOG(3,(THIS_FILE, "%s sent",
+	         (renew? "Registration" : "Unregistration")));
+    }
 }
 
 /*
@@ -96,7 +117,8 @@
 	status = pjsip_regc_create( pjsua.endpt, NULL, &regc_cb, &pjsua.regc);
 
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror("Unable to create client registration", status);
+	    pjsua_perror(THIS_FILE, "Unable to create client registration", 
+			 status);
 	    return status;
 	}
 
@@ -107,7 +129,9 @@
 				  1, &pjsua.contact_uri, 
 				  pjsua.reg_timeout);
 	if (status != PJ_SUCCESS) {
-	    pjsua_perror("Client registration initialization error", status);
+	    pjsua_perror(THIS_FILE, 
+			 "Client registration initialization error", 
+			 status);
 	    return status;
 	}