diff -Naur old/modules/presence/Makefile new/modules/presence/Makefile
--- old/modules/presence/Makefile	2007-05-09 17:22:00.000000000 +0100
+++ new/modules/presence/Makefile	2007-06-21 15:23:44.000000000 +0100
@@ -12,6 +12,6 @@
 
 DEFS+=-I$(SYSBASE)/include/libxml2 -I$(LOCALBASE)/include/libxml2 \
       -I$(LOCALBASE)/include
-LIBS+=-L$(SYSBASE)/include/lib  -L$(LOCALBASE)/lib -lxml2
+LIBS+=-L$(SYSBASE)/include/lib  -L$(LOCALBASE)/lib -lxml2 -lxcap -lcds -lcurl
 
 include ../../Makefile.modules
diff -Naur old/modules/presence/notify.c new/modules/presence/notify.c
--- old/modules/presence/notify.c	2007-05-09 17:22:00.000000000 +0100
+++ new/modules/presence/notify.c	2007-06-21 15:31:50.000000000 +0100
@@ -1228,100 +1228,39 @@
 
 xmlDocPtr get_xcap_tree(str user, str domain)
 {
-	db_key_t query_cols[5];
-	db_val_t query_vals[5];
-	db_key_t result_cols[3];
-	int n_query_cols = 0;
-	db_res_t *result = 0;
-	db_row_t *row ;	
-	db_val_t *row_vals ;
-	str body ;
 	xmlDocPtr xcap_tree =NULL;
-
-	query_cols[n_query_cols] = "username";
-	query_vals[n_query_cols].type = DB_STR;
-	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.str_val.s = user.s;
-	query_vals[n_query_cols].val.str_val.len = user.len;
-	n_query_cols++;
-	
-	query_cols[n_query_cols] = "domain";
-	query_vals[n_query_cols].type = DB_STR;
-	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.str_val.s = domain.s;
-	query_vals[n_query_cols].val.str_val.len = domain.len;
-	n_query_cols++;
-	
-	query_cols[n_query_cols] = "doc_type";
-	query_vals[n_query_cols].type = DB_INT;
-	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.int_val= PRES_RULES;
-	n_query_cols++;
-
-	result_cols[0] = "xcap";
-
-	if (pa_dbf.use_table(pa_db, xcap_table) < 0) 
-	{
-		LOG(L_ERR, "PRESENCE:get_xcap_tree: Error in use_table\n");
-		return NULL;
-	}
-
-	if( pa_dbf.query(pa_db, query_cols, 0 , query_vals, result_cols, 
-				n_query_cols, 1, 0, &result)<0)
-	{
-		LOG(L_ERR, "PRESENCE:get_xcap_tree:Error while querying table xcap for"
-		" [username]=%.*s , domain=%.*s\n",user.len, user.s, domain.len,
-		domain.s);
-		goto error;
-	}
-	if(result== NULL)
-		return NULL;
-
-	if(result && result->n<=0)
-	{
-		LOG(L_ERR, "PRESENCE:get_xcap_tree:The query in table xcap for"
-				" [username]=%.*s , domain=%.*s returned no result\n",
-				user.len, user.s, domain.len, domain.s);
-		goto error;
-	}
-	LOG(L_ERR, "PRESENCE:get_xcap_tree:The query in table xcap for"
-			" [username]=%.*s , domain=%.*s returned result",	user.len,
-			user.s, domain.len, domain.s );
-
-	row = &result->rows[0];
-	row_vals = ROW_VALUES(row);
-
-	body.s = (char*)row_vals[0].val.string_val;
-	if(body.s== NULL)
-	{
-		DBG("PRESENCE:get_xcap_tree: Xcap doc NULL\n");
-		goto error;
-	}	
-	body.len = strlen(body.s);
-	if(body.len== 0)
-	{
-		DBG("PRESENCE:get_xcap_tree: Xcap doc empty\n");
-		goto error;
-	}			
+	int sz,n;
+	char *uri = NULL;
+	xcap_query_params_t *xcap_params =NULL;
+        char *data = NULL;
+        int dsize = 0;
+        int res = RES_OK;
+     	
+	sz=10+user.len+strlen(xcap_server)+strlen(xcap_root)+strlen(xcap_app_usage)+strlen(xcap_document_name);
+	uri=(char*)pkg_malloc(sz);
+	n=sprintf(uri,"%s/%s/%s/users/%.*s/%s",xcap_server,xcap_root,xcap_app_usage,user.len,user.s,xcap_document_name);
+        
+	xcap_params = (xcap_query_params_t*) pkg_malloc(sizeof(xcap_query_params_t));	
+	xcap_params->xcap_root.s=xcap_root;
+	xcap_params->xcap_root.len =strlen(xcap_root);
+	xcap_params->auth_user.s=xcap_auth_username;
+	xcap_params->auth_user.len =strlen(xcap_auth_username);
+	xcap_params->auth_pass.s=xcap_auth_password;
+	xcap_params->auth_pass.len =strlen(xcap_auth_password);
 	
-	DBG("PRESENCE:get_xcap_tree: xcap body:\n%.*s", body.len,body.s);
+        res = xcap_query(uri, xcap_params, &data, &dsize);
 	
-	xcap_tree = xmlParseMemory(body.s, body.len);
+	pkg_free(xcap_params);
+	pkg_free(uri);
+	
+	xcap_tree = xmlParseMemory(data, dsize);
 	if(xcap_tree == NULL)
 	{
 		LOG(L_ERR,"PRESENCE:get_xcap_tree: ERROR while parsing memory\n");
-		goto error;
+		return NULL;
 	}
 
-	if(result!=NULL)
-		pa_dbf.free_result(pa_db, result);
-
 	return xcap_tree;
-
-error:
-	if(result!=NULL)
-		pa_dbf.free_result(pa_db, result);
-	return NULL;
 }
 
 
diff -Naur old/modules/presence/notify.h new/modules/presence/notify.h
--- old/modules/presence/notify.h	2007-05-09 17:22:00.000000000 +0100
+++ new/modules/presence/notify.h	2007-06-21 15:28:12.000000000 +0100
@@ -28,6 +28,8 @@
 
 #include "../../str.h"
 #include "subscribe.h"
+#include <xcap/xcap_client.h>
+
 
 #ifndef NOTIFY_H
 #define NOTIFY_H
diff -Naur old/modules/presence/presence.c new/modules/presence/presence.c
--- old/modules/presence/presence.c	2007-05-09 17:22:00.000000000 +0100
+++ new/modules/presence/presence.c	2007-06-21 15:27:48.000000000 +0100
@@ -69,6 +69,12 @@
 char *xcap_table= "xcap_xml";  
 int use_db=1;
 str server_address;
+char *xcap_server="http://localhost";  
+char *xcap_root="xcap-root";  
+char *xcap_app_usage="pres-rules";
+char *xcap_document_name="presrules";
+char *xcap_auth_username="openser";
+char *xcap_auth_password="openserrw";
 
 /* to tag prefix */
 char* to_tag_pref = "10";
@@ -125,6 +131,12 @@
 	{ "force_active",			INT_PARAM, &force_active },
 	{ "max_expires",			INT_PARAM, &max_expires  },
 	{ "server_address",         STR_PARAM, &server_address.s},
+	{ "xcap_server",         STR_PARAM, &xcap_server},
+	{ "xcap_root",         STR_PARAM, &xcap_root},
+	{ "xcap_app_usage",         STR_PARAM, &xcap_app_usage},
+	{ "xcap_document_name",         STR_PARAM, &xcap_document_name},
+	{ "xcap_auth_username",         STR_PARAM, &xcap_auth_username},
+	{ "xcap_auth_password",         STR_PARAM, &xcap_auth_password},
 	{0,0,0}
 };
 
diff -Naur old/modules/presence/presence.h new/modules/presence/presence.h
--- old/modules/presence/presence.h	2007-05-09 17:22:00.000000000 +0100
+++ new/modules/presence/presence.h	2007-06-21 15:27:22.000000000 +0100
@@ -50,6 +50,12 @@
 extern char *active_watchers_table;
 extern char *watchers_table; 
 extern char *xcap_table; 
+extern char *xcap_server; 
+extern char *xcap_root; 
+extern char *xcap_app_usage; 
+extern char *xcap_document_name; 
+extern char *xcap_auth_username; 
+extern char *xcap_auth_password; 
 
 extern int counter;
 extern int pid;
