Index: pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 487)
+++ pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 492)
@@ -69,4 +69,11 @@
 
 
+typedef int pjsua_acc_id;
+typedef int pjsua_buddy_id;
+typedef int pjsua_player_id;
+typedef int pjsua_recorder_id;
+typedef int pjsua_conf_port_id;
+
+
 /**
  * Account configuration.
@@ -136,4 +143,9 @@
     unsigned	start_rtp_port;
 
+    /**
+     * Enable incoming and outgoing message logging (default: 1).
+     */
+    pj_bool_t	msg_logging;
+
     /** Maximum calls to support (default: 4) */
     unsigned	max_calls;
@@ -223,7 +235,4 @@
     /** Outbound proxy (default: none) */
     pj_str_t	outbound_proxy;
-
-    /** URI to call.			*/
-    pj_str_t	uri_to_call;
 
     /** Number of SIP accounts */
@@ -273,4 +282,10 @@
 
     /**
+     * Notify application on incoming call.
+     */
+    void (*on_incoming_call)(pjsua_acc_id acc_id, int call_index,
+			     pjsip_rx_data *rdata);
+
+    /**
      * Notify application on call being transfered.
      * Application can decide to accept/reject transfer request
@@ -288,5 +303,5 @@
      * registration details.
      */
-    void (*on_reg_state)(int acc_index);
+    void (*on_reg_state)(pjsua_acc_id acc_id);
 
     /**
@@ -294,5 +309,5 @@
      * Application may then query the buddy into to get the details.
      */
-    void (*on_buddy_state)(int buddy_index);
+    void (*on_buddy_state)(pjsua_buddy_id buddy_id);
 
     /**
@@ -330,10 +345,10 @@
     pjsip_inv_state	state;
     pj_str_t		state_text;
+    pjsip_status_code	last_status;
+    pj_str_t		last_status_text;
     pj_time_val		connect_duration;
     pj_time_val		total_duration;
-    pjsip_status_code	cause;
-    pj_str_t		cause_text;
     pj_bool_t		has_media;
-    unsigned		conf_slot;
+    pjsua_conf_port_id	conf_slot;
 };
 
@@ -356,5 +371,5 @@
 struct pjsua_buddy_info
 {
-    unsigned		index;
+    pjsua_buddy_id	index;
     pj_bool_t		is_valid;
     pj_str_t		name;
@@ -366,5 +381,4 @@
     pj_str_t		status_text;
     pj_bool_t		monitor;
-    int			acc_index;
 };
 
@@ -377,5 +391,5 @@
 struct pjsua_acc_info
 {
-    unsigned		index;
+    pjsua_acc_id	index;
     pj_str_t		acc_id;
     pj_bool_t		has_registration;
@@ -390,7 +404,21 @@
 
 
-typedef int pjsua_player_id;
-typedef int pjsua_recorder_id;
-
+/**
+ * Conference port info.
+ */
+struct pjsua_conf_port_info
+{
+    pjsua_conf_port_id	slot_id;
+    pj_str_t		name;
+    unsigned		clock_rate;
+    unsigned		channel_count;
+    unsigned		samples_per_frame;
+    unsigned		bits_per_sample;
+    unsigned		listener_cnt;
+    pjsua_conf_port_id	listeners[256];
+};
+
+
+typedef struct pjsua_conf_port_info pjsua_conf_port_info;
 
 
@@ -479,10 +507,10 @@
  * Get maximum number of calls configured in pjsua.
  */
-PJ_DECL(unsigned) pjsua_get_max_calls(void);
+PJ_DECL(unsigned) pjsua_call_get_max_count(void);
 
 /**
  * Get current number of active calls.
  */
-PJ_DECL(unsigned) pjsua_get_call_count(void);
+PJ_DECL(unsigned) pjsua_call_get_count(void);
 
 /**
@@ -502,5 +530,5 @@
  * Get call info.
  */
-PJ_DECL(pj_status_t) pjsua_get_call_info(unsigned call_index,
+PJ_DECL(pj_status_t) pjsua_call_get_info(unsigned call_index,
 					 pjsua_call_info *info);
 
@@ -509,5 +537,5 @@
  * Duplicate call info.
  */
-PJ_DECL(void) pjsua_dup_call_info(pj_pool_t *pool,
+PJ_DECL(void) pjsua_call_info_dup(pj_pool_t *pool,
 				  pjsua_call_info *dst_info,
 				  const pjsua_call_info *src_info);
@@ -517,7 +545,7 @@
  * Make outgoing call.
  */
-PJ_DECL(pj_status_t) pjsua_make_call(unsigned acc_index,
-				     const pj_str_t *dst_uri,
-				     int *p_call_index);
+PJ_DECL(pj_status_t) pjsua_call_make_call(unsigned acc_id,
+					  const pj_str_t *dst_uri,
+					  int *p_call_index);
 
 
@@ -525,5 +553,5 @@
  * Answer call.
  */
-PJ_DECL(void) pjsua_call_answer(int call_index, int code);
+PJ_DECL(pj_status_t) pjsua_call_answer(int call_index, int code);
 
 /**
@@ -536,5 +564,5 @@
  * Put call on-hold.
  */
-PJ_DECL(void) pjsua_call_set_hold(int call_index);
+PJ_DECL(pj_status_t) pjsua_call_set_hold(int call_index);
 
 
@@ -542,5 +570,5 @@
  * Send re-INVITE (to release hold).
  */
-PJ_DECL(void) pjsua_call_reinvite(int call_index);
+PJ_DECL(pj_status_t) pjsua_call_reinvite(int call_index);
 
 
@@ -548,5 +576,5 @@
  * Transfer call.
  */
-PJ_DECL(void) pjsua_call_xfer(unsigned call_index, const pj_str_t *dest);
+PJ_DECL(pj_status_t) pjsua_call_xfer(unsigned call_index, const pj_str_t *dest);
 
 /**
@@ -560,5 +588,5 @@
  * Send instant messaging inside INVITE session.
  */
-PJ_DECL(void) pjsua_call_send_im(int call_index, const pj_str_t *text);
+PJ_DECL(pj_status_t) pjsua_call_send_im(int call_index, const pj_str_t *text);
 
 
@@ -566,5 +594,6 @@
  * Send IM typing indication inside INVITE session.
  */
-PJ_DECL(void) pjsua_call_typing(int call_index, pj_bool_t is_typing);
+PJ_DECL(pj_status_t) pjsua_call_send_typing_ind(int call_index, 
+						pj_bool_t is_typing);
 
 /**
@@ -577,5 +606,5 @@
  * Dump call and media statistics to string.
  */
-PJ_DECL(void) pjsua_dump_call(int call_index, int with_media, 
+PJ_DECL(void) pjsua_call_dump(int call_index, int with_media, 
 			      char *buffer, unsigned maxlen,
 			      const char *indent);
@@ -595,6 +624,31 @@
  * Get account info.
  */
-PJ_DECL(pj_status_t) pjsua_acc_get_info(unsigned acc_index,
+PJ_DECL(pj_status_t) pjsua_acc_get_info(pjsua_acc_id acc_id,
 					pjsua_acc_info *info);
+
+
+/**
+ * Enum accounts id.
+ */
+PJ_DECL(pj_status_t) pjsua_acc_enum_id( pjsua_acc_id ids[],
+				        unsigned *count );
+
+
+/**
+ * Enum accounts info.
+ */
+PJ_DECL(pj_status_t) pjsua_acc_enum_info( pjsua_acc_info info[],
+					  unsigned *count );
+
+
+/**
+ * Find account for outgoing request.
+ */
+PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_outgoing(const pj_str_t *url);
+
+/**
+ * Find account for incoming request.
+ */
+PJ_DECL(pjsua_acc_id) pjsua_acc_find_for_incoming(pjsip_rx_data *rdata);
 
 /**
@@ -605,12 +659,16 @@
  */
 PJ_DECL(pj_status_t) pjsua_acc_add(const pjsua_acc_config *cfg,
-				   int *acc_index);
+				   pjsua_acc_id *acc_id);
+
+/**
+ * Delete account.
+ */
+PJ_DECL(pj_status_t) pjsua_acc_del(pjsua_acc_id acc_id);
 
 
 /**
  * Set account's presence status.
- * Must call pjsua_pres_refresh() after this.
- */
-PJ_DECL(pj_status_t) pjsua_acc_set_online_status(unsigned acc_index,
+ */
+PJ_DECL(pj_status_t) pjsua_acc_set_online_status(pjsua_acc_id acc_id,
 						 pj_bool_t is_online);
 
@@ -620,5 +678,6 @@
  * this will start unregistration process.
  */
-PJ_DECL(pj_status_t) pjsua_acc_set_registration(unsigned acc_index, pj_bool_t renew);
+PJ_DECL(pj_status_t) pjsua_acc_set_registration(pjsua_acc_id acc_id, 
+						pj_bool_t renew);
 
 
@@ -638,5 +697,5 @@
  * Get buddy info.
  */
-PJ_DECL(pj_status_t) pjsua_buddy_get_info(unsigned buddy_index,
+PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_index,
 					  pjsua_buddy_info *info);
 
@@ -645,19 +704,19 @@
  */
 PJ_DECL(pj_status_t) pjsua_buddy_add(const pj_str_t *uri,
-				     int *buddy_index);
+				     pjsua_buddy_id *buddy_index);
+
+
+/**
+ * Delete buddy.
+ */
+PJ_DECL(pj_status_t) pjsua_buddy_del(pjsua_buddy_id buddy_index);
 
 
 /**
  * Enable/disable buddy's presence monitoring.
- * Must call pjsua_pres_refresh() after this.
- */
-PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(unsigned buddy_index,
+ */
+PJ_DECL(pj_status_t) pjsua_buddy_subscribe_pres(pjsua_buddy_id buddy_index,
 						pj_bool_t monitor);
 
-
-/**
- * Refresh both presence client and server subscriptions.
- */
-PJ_DECL(void) pjsua_pres_refresh(void);
 
 /**
@@ -681,5 +740,5 @@
  * Send IM outside dialog.
  */
-PJ_DECL(pj_status_t) pjsua_im_send(int acc_index, const pj_str_t *dst_uri, 
+PJ_DECL(pj_status_t) pjsua_im_send(int acc_id, const pj_str_t *dst_uri, 
 				   const pj_str_t *text);
 
@@ -688,5 +747,5 @@
  * Send typing indication outside dialog.
  */
-PJ_DECL(pj_status_t) pjsua_im_typing(int acc_index, const pj_str_t *dst_uri, 
+PJ_DECL(pj_status_t) pjsua_im_typing(int acc_id, const pj_str_t *dst_uri, 
 				     pj_bool_t is_typing);
 
@@ -706,6 +765,13 @@
  * Enum all conference ports.
  */
-PJ_DECL(pj_status_t) pjsua_conf_enum_ports(unsigned *count,
-					   pjmedia_conf_port_info info[]);
+PJ_DECL(pj_status_t) pjsua_conf_enum_port_ids(pjsua_conf_port_id id[],
+					      unsigned *count);
+
+
+/**
+ * Get information about the specified conference port
+ */
+PJ_DECL(pj_status_t) pjsua_conf_get_port_info( pjsua_conf_port_id id,
+					       pjsua_conf_port_info *info);
 
 
@@ -713,6 +779,6 @@
  * Connect conference port.
  */
-PJ_DECL(pj_status_t) pjsua_conf_connect(unsigned src_port,
-					unsigned dst_port);
+PJ_DECL(pj_status_t) pjsua_conf_connect(pjsua_conf_port_id src_port,
+					pjsua_conf_port_id dst_port);
 
 
@@ -720,6 +786,6 @@
  * Connect conference port connection.
  */
-PJ_DECL(pj_status_t) pjsua_conf_disconnect(unsigned src_port,
-					   unsigned dst_port);
+PJ_DECL(pj_status_t) pjsua_conf_disconnect(pjsua_conf_port_id src_port,
+					   pjsua_conf_port_id dst_port);
 
 
@@ -734,5 +800,5 @@
  * Get conference port associated with player.
  */
-PJ_DECL(int) pjsua_player_get_conf_port(pjsua_player_id id);
+PJ_DECL(pjsua_conf_port_id) pjsua_player_get_conf_port(pjsua_player_id id);
 
 
@@ -761,5 +827,5 @@
  * Get conference port associated with recorder.
  */
-PJ_DECL(int) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
+PJ_DECL(pjsua_conf_port_id) pjsua_recorder_get_conf_port(pjsua_recorder_id id);
 
 
@@ -798,5 +864,6 @@
  */
 PJ_DECL(pj_status_t) pjsua_parse_args(int argc, char *argv[],
-				      pjsua_config *cfg);
+				      pjsua_config *cfg,
+				      pj_str_t *uri_to_call);
 
 /**
@@ -804,10 +871,12 @@
  */
 PJ_DECL(pj_status_t) pjsua_load_settings(const char *filename,
-					 pjsua_config *cfg);
+					 pjsua_config *cfg,
+					 pj_str_t *uri_to_call);
 
 /**
  * Get pjsua running config.
  */
-PJ_DECL(const pjsua_config*) pjsua_get_config(void);
+PJ_DECL(void) pjsua_get_config(pj_pool_t *pool,
+			       pjsua_config *config);
 
 
