Index: /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 2161)
+++ /pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 2162)
@@ -2001,4 +2001,11 @@
 {
     /**
+     * Arbitrary user data to be associated with the newly created account.
+     * Application may set this later with #pjsua_acc_set_user_data() and
+     * retrieve it with #pjsua_acc_get_user_data().
+     */
+    void	   *user_data;
+
+    /**
      * Account priority, which is used to control the order of matching
      * incoming/outgoing requests. The higher the number means the higher
@@ -2395,4 +2402,27 @@
 					 pj_bool_t is_default,
 					 pjsua_acc_id *p_acc_id);
+
+/**
+ * Set arbitrary data to be associated with the account.
+ *
+ * @param acc_id	The account ID.
+ * @param user_data	User/application data.
+ *
+ * @return		PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
+					     void *user_data);
+
+
+/**
+ * Retrieve arbitrary data associated with the account.
+ *
+ * @param acc_id	The account ID.
+ *
+ * @return		The user data. In the case where the account ID is
+ *			not valid, NULL is returned.
+ */
+PJ_DECL(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id);
+
 
 /**
@@ -3360,4 +3390,10 @@
     pj_bool_t	subscribe;
 
+    /**
+     * Specify arbitrary application data to be associated with with
+     * the buddy object.
+     */
+    void       *user_data;
+
 } pjsua_buddy_config;
 
@@ -3519,4 +3555,14 @@
 
 /**
+ * Find the buddy ID with the specified URI.
+ *
+ * @param uri		The buddy URI.
+ *
+ * @return		The buddy ID, or PJSUA_INVALID_ID if not found.
+ */
+PJ_DECL(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri);
+
+
+/**
  * Get detailed buddy info.
  *
@@ -3534,4 +3580,27 @@
 PJ_DECL(pj_status_t) pjsua_buddy_get_info(pjsua_buddy_id buddy_id,
 					  pjsua_buddy_info *info);
+
+/**
+ * Set the user data associated with the buddy object.
+ *
+ * @param buddy_id	The buddy identification.
+ * @param user_data	Arbitrary application data to be associated with
+ *			the buddy object.
+ *
+ * @return		PJ_SUCCESS on success, or the appropriate error code.
+ */
+PJ_DECL(pj_status_t) pjsua_buddy_set_user_data(pjsua_buddy_id buddy_id,
+					       void *user_data);
+
+
+/**
+ * Get the user data associated with the budy object.
+ *
+ * @param buddy_id	The buddy identification.
+ *
+ * @return		The application data.
+ */
+PJ_DECL(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id);
+
 
 /**
Index: /pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h	(revision 2161)
+++ /pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h	(revision 2162)
@@ -165,4 +165,5 @@
     pj_pool_t		*pool;	    /**< Pool for this buddy.		*/
     unsigned		 index;	    /**< Buddy index.			*/
+    void		*user_data; /**< Application data.		*/
     pj_str_t		 uri;	    /**< Buddy URI.			*/
     pj_str_t		 contact;   /**< Contact learned from subscrp.	*/
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 2161)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 2162)
@@ -160,5 +160,4 @@
     }
 
-
     /* Save the user and domain part. These will be used when finding an 
      * account for incoming requests.
@@ -383,4 +382,37 @@
     
     return pjsua_acc_add(&cfg, is_default, p_acc_id);
+}
+
+
+/*
+ * Set arbitrary data to be associated with the account.
+ */
+PJ_DEF(pj_status_t) pjsua_acc_set_user_data(pjsua_acc_id acc_id,
+					    void *user_data)
+{
+    PJ_ASSERT_RETURN(acc_id>=0 && acc_id<(int)PJ_ARRAY_SIZE(pjsua_var.acc),
+		     PJ_EINVAL);
+    PJ_ASSERT_RETURN(pjsua_var.acc[acc_id].valid, PJ_EINVALIDOP);
+
+    PJSUA_LOCK();
+
+    pjsua_var.acc[acc_id].cfg.user_data = user_data;
+
+    PJSUA_UNLOCK();
+
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Retrieve arbitrary data associated with the account.
+ */
+PJ_DEF(void*) pjsua_acc_get_user_data(pjsua_acc_id acc_id)
+{
+    PJ_ASSERT_RETURN(acc_id>=0 && acc_id<(int)PJ_ARRAY_SIZE(pjsua_var.acc),
+		     NULL);
+    PJ_ASSERT_RETURN(pjsua_var.acc[acc_id].valid, NULL);
+
+    return pjsua_var.acc[acc_id].cfg.user_data;
 }
 
Index: /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c	(revision 2161)
+++ /pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c	(revision 2162)
@@ -71,4 +71,29 @@
 
 /*
+ * Find buddy.
+ */
+PJ_DEF(pjsua_buddy_id) pjsua_buddy_find(const pj_str_t *uri_str)
+{
+    pj_str_t input;
+    pj_pool_t *pool;
+    pjsip_uri *uri;
+    pjsua_buddy_id buddy_id;
+
+    pool = pjsua_pool_create("buddyfind", 512, 512);
+    pj_strdup_with_null(pool, &input, uri_str);
+
+    uri = pjsip_parse_uri(pool, input.ptr, input.slen, 0);
+    if (!uri)
+	buddy_id = PJSUA_INVALID_ID;
+    else
+	buddy_id = pjsua_find_buddy(uri);
+
+    pj_pool_release(pool);
+
+    return buddy_id;
+}
+
+
+/*
  * Check if buddy ID is valid.
  */
@@ -191,4 +216,44 @@
 }
 
+/*
+ * Set the user data associated with the buddy object.
+ */
+PJ_DEF(pj_status_t) pjsua_buddy_set_user_data( pjsua_buddy_id buddy_id,
+					       void *user_data)
+{
+    PJ_ASSERT_RETURN(buddy_id>=0 && 
+		       buddy_id<(int)PJ_ARRAY_SIZE(pjsua_var.buddy),
+		     PJ_EINVAL);
+
+    PJSUA_LOCK();
+
+    pjsua_var.buddy[buddy_id].user_data = user_data;
+
+    PJSUA_UNLOCK();
+
+    return PJ_SUCCESS;
+}
+
+
+/*
+ * Get the user data associated with the budy object.
+ */
+PJ_DEF(void*) pjsua_buddy_get_user_data(pjsua_buddy_id buddy_id)
+{
+    void *user_data;
+
+    PJ_ASSERT_RETURN(buddy_id>=0 && 
+		       buddy_id<(int)PJ_ARRAY_SIZE(pjsua_var.buddy),
+		     NULL);
+
+    PJSUA_LOCK();
+
+    user_data = pjsua_var.buddy[buddy_id].user_data;
+
+    PJSUA_UNLOCK();
+
+    return user_data;
+}
+
 
 /*
@@ -289,4 +354,7 @@
     if (pjsua_var.buddy[index].port == 0)
 	pjsua_var.buddy[index].port = 5060;
+
+    /* Save user data */
+    pjsua_var.buddy[index].user_data = (void*)cfg->user_data;
 
     if (p_buddy_id)
