# &adminguide;

## Overview

The module is a XCAP client for &kamailio; that can be used by other modules. It fetches XCAP elements, either documents or part of them, by sending HTTP GET requests to an XCAP server. It also offers support for conditional queries. It uses the libcurl library as a client-side HTTP transfer library.

The module offers a XCAP client interface with general functions that allow requesting for a specific element from a XCAP server. In addition to that it also offers the service of storing and updating the documents it receives. In this case only an initial request to the module is required - xcapGetNewDoc - which is like a request to the module to handle from that point on the referenced document so as to promise that the newest version will always be present in database.

The update method is also configurable, either through periodical queries, applicable to any kind of XCAP server or with a management command that should be sent by the server upon an update.

The module is currently used by the presence_xml module, if the 'integrated_xcap_server' parameter is not set.

## Dependencies

### &kamailio; Modules

The module is not dependent of any &kamailio; module.

### External Libraries or Applications

The following libraries or applications must be installed before running &kamailio; with this module loaded:

- libxml.

- libcurl.

## Parameters

### `db_url`(str)

The database url.

Default value is &defaultdb;.

#### Set `db_url` parameter

    ...
    modparam("xcap_client", "db_url", "&exampledb;")
    ...

### `xcap_table`(str)

The name of the db table where XCAP documents are stored.

Default value is xcap.

#### Set `xcap_table` parameter

    ...
    modparam("xcap_client", "xcap_table", "xcaps")
    ...

### `periodical_query`(int)

A flag to disable periodical query as an update method for the documents the module is responsible for. It could be disabled when the XCAP server is capable to send the exported management command when a change occurs or when another module in &kamailio; handles updates.

To disable it set this parameter to 0.

Default value is 1.

#### Set `periodical_query` parameter

    ...
    modparam("xcap_client", "periodical_query", 0)
    ...

### `query_period`(int)

Should be set if periodical query is not disabled. Represents the time interval the XCAP servers should be queried for an update.

To disable it set this parameter to 0.

Default value is 100.

#### Set `query_period` parameter

    ...
    modparam("xcap_client", "query_period", 50)
    ...

## RPC Commands

### `xcap_client.refreshXcapDoc`

Management command that should be sent by an XCAP server when a stored document changes.

Name: xcap_client.refreshXcapDoc

Parameters:

- document uri: the uri of the document

- xcap server port: the port of the xcap server

RPC Command Example:

    ...
    # execute in a single line command
    &kamctl; rpc xcap_client.refreshXcapDoc
         /xcap-root/resource-lists/users/eyebeam/buddies-resource-list.xml 8000
    ...

## Remarks

Note: libcurl leak in CentOS 6 - this module uses libcurl library and in case if you are using CentOS 6, be aware that standard libcurl-7.19.7-52 has a memory leak. To fix this memory, install libcurl from city-fan repository. More details at: https://www.digitalocean.com/community/questions/how-to-upgrade-curl-in-centos6