xcap_client_devel.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?xml version="1.0" encoding='ISO-8859-1'?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  4. <!-- Include general documentation entities -->
  5. <!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
  6. %docentities;
  7. ]>
  8. <!-- Module Developer's Guide -->
  9. <chapter>
  10. <title>&develguide;</title>
  11. <para>
  12. The module exports a number of functions that allow selecting
  13. and retrieving an element from an xcap server and also registering
  14. a callback to be called when the management command refreshXcapDoc is received
  15. and the document in question is retrieved.
  16. </para>
  17. <section>
  18. <title>
  19. <function moreinfo="none">bind_xcap_api(xcap_api_t* api)</function>
  20. </title>
  21. <para>
  22. This function allows binding the needed functions.
  23. </para>
  24. <example>
  25. <title><function>xcap_api</function> structure</title>
  26. <programlisting format="linespecific">
  27. ...
  28. typedef struct xcap_api {
  29. /* xcap node selection and retrieving functions*/
  30. xcap_get_elem_t get_elem;
  31. xcap_nodeSel_init_t int_node_sel;
  32. xcap_nodeSel_add_step_t add_step;
  33. xcap_nodeSel_add_terminal_t add_terminal;
  34. xcap_nodeSel_free_t free_node_sel;
  35. xcapGetNewDoc_t getNewDoc; /* an initial request for the module
  36. fo fetch this document that does not exist in xcap db table
  37. and handle its update*/
  38. /* function to register a callback to document changes*/
  39. register_xcapcb_t register_xcb;
  40. }xcap_api_t;
  41. ...
  42. </programlisting>
  43. </example>
  44. </section>
  45. <section>
  46. <title>
  47. <function moreinfo="none">get_elem</function>
  48. </title>
  49. <para>
  50. Field type:
  51. <programlisting format="linespecific">
  52. ...
  53. typedef char* (*xcap_get_elem_t)(char* xcap_root,
  54. xcap_doc_sel_t* doc_sel, xcap_node_sel_t* node_sel);
  55. ...
  56. </programlisting>
  57. </para>
  58. <para>
  59. This function sends a HTTP request and gets the specified information
  60. from the xcap server.
  61. </para>
  62. <para>
  63. The parameters signification:
  64. </para>
  65. <itemizedlist>
  66. <listitem>
  67. <para>
  68. <emphasis>xcap_root</emphasis>-
  69. the XCAP server address;
  70. </para>
  71. </listitem>
  72. <listitem>
  73. <para>
  74. <emphasis>doc_sel</emphasis>-
  75. structure with document selection info;
  76. </para>
  77. <programlisting format="linespecific">
  78. Parameter type:
  79. ...
  80. typedef struct xcap_doc_sel
  81. {
  82. str auid; /* application defined Unique ID*/
  83. int type; /* the type of the path segment
  84. after the AUID which must either
  85. be GLOBAL_TYPE (for "global") or
  86. USERS_TYPE (for "users") */
  87. str xid; /* the XCAP User Identifier
  88. if type is USERS_TYPE */
  89. str filename;
  90. }xcap_doc_sel_t;
  91. ...
  92. </programlisting>
  93. </listitem>
  94. <listitem>
  95. <para>
  96. <emphasis>node_sel</emphasis>-
  97. structure with node selection info;
  98. </para>
  99. <programlisting format="linespecific">
  100. Parameter type:
  101. ...
  102. typedef struct xcap_node_sel
  103. {
  104. step_t* steps;
  105. step_t* last_step;
  106. int size;
  107. ns_list_t* ns_list;
  108. ns_list_t* last_ns;
  109. int ns_no;
  110. }xcap_node_sel_t;
  111. typedef struct step
  112. {
  113. str val;
  114. struct step* next;
  115. }step_t;
  116. typedef struct ns_list
  117. {
  118. int name;
  119. str value;
  120. struct ns_list* next;
  121. }ns_list_t;
  122. ...
  123. </programlisting>
  124. <para>
  125. The node selector is represented like a list of steps that will
  126. be represented in the path string separated by '/' signs.
  127. The namespaces for the nodes are stored also in a list, as an
  128. association of name and value, where the value is to be included
  129. in the respective string val field of the step.
  130. </para>
  131. <para>
  132. To construct the node structure the following functions in the xcap_api
  133. structure should be used: 'int_node_sel', 'add_step' and if needed,
  134. 'add_terminal'.
  135. </para>
  136. <para>
  137. If the intention is to retrieve the whole document this argument must
  138. be NULL.
  139. </para>
  140. </listitem>
  141. </itemizedlist>
  142. </section>
  143. <section>
  144. <title>
  145. <function moreinfo="none">register_xcb</function>
  146. </title>
  147. <para>
  148. Field type:
  149. <programlisting format="linespecific">
  150. ...
  151. typedef int (*register_xcapcb_t)(int types, xcap_cb f);
  152. ...
  153. </programlisting>
  154. </para>
  155. <para>
  156. - 'types' parameter can have a combined value of PRES_RULES, RESOURCE_LIST,
  157. RLS_SERVICES and PIDF_MANIPULATION.
  158. </para>
  159. <para>
  160. -the callback function has type :
  161. <programlisting format="linespecific">
  162. ...
  163. typedef int (xcap_cb)(int doc_type, str xid, char* doc);
  164. ...
  165. </programlisting>
  166. </para>
  167. </section>
  168. </chapter>