functions.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
  4. <section id="rls.functions"><title>Functions</title>
  5. <variablelist>
  6. <varlistentry id="handle_rls_subscription">
  7. <term><varname>handle_rls_subscription</varname></term>
  8. <listitem>
  9. <para>Handle subscription to resource list uri.</para>
  10. <variablelist><title>Parameters:</title>
  11. <!-- <varlistentry>
  12. <term>xcap_root (string)</term>
  13. <listitem><para>String representing XCAP root for resource
  14. lists. For example <quote>http://localhost/xcap-root</quote>.
  15. </para></listitem>
  16. </varlistentry>-->
  17. <varlistentry>
  18. <term>create_error_response (integer)</term>
  19. <listitem><para>If set to 0 error responses are not sent
  20. to the client. This may be useful, if used together with PA
  21. module.
  22. </para></listitem>
  23. </varlistentry>
  24. </variablelist>
  25. <para>This function handles resource list subscription. XCAP document
  26. containing the list must be loaded before using one of query function
  27. (<xref linkend="query_rls_services"/>, <xref
  28. linkend="query_resource_list"/>).
  29. </para>
  30. <example><title>handling subscription</title>
  31. <programlisting>
  32. ...
  33. if (method=="SUBSCRIBE") {
  34. if (!t_newtran()) {
  35. sl_reply_error();
  36. };
  37. if (query_rls_services()) {
  38. handle_rls_subscription("1");
  39. }
  40. else {
  41. # no such list exists -> process it with PA module
  42. handle_subscription("registrar");
  43. }
  44. break;
  45. };
  46. ...
  47. </programlisting>
  48. <para>In this case for every incomming SUBSCRIBE request SER asks for
  49. "global resource list". If such list exists, the subscription is
  50. processed like resource list subscription.
  51. </para>
  52. </example>
  53. </listitem>
  54. </varlistentry>
  55. <varlistentry>
  56. <term><varname>is_simple_rls_target</varname></term>
  57. <listitem>
  58. <para>Test uri according to given template.</para>
  59. <variablelist><title>Parameters:</title>
  60. <varlistentry>
  61. <term>template (string)</term>
  62. <listitem><para>Template to be compared with To URI.</para></listitem>
  63. </varlistentry>
  64. </variablelist>
  65. <para>Function tries to compare username in To URI with given
  66. template. If there are different domains in To and From URIs,
  67. the function fails. There can be used "$uid" in template and it
  68. is replaced by value returned by get_from_uid.
  69. </para>
  70. <para><emphasis>In the future should be this function replaced by AVP
  71. operations but I was not able to do it with them now...</emphasis></para>
  72. <example><title>handling subscription</title>
  73. <programlisting>
  74. ...
  75. if (method=="SUBSCRIBE") {
  76. if (!t_newtran()) {
  77. sl_reply_error();
  78. break;
  79. };
  80. if (lookup_domain("From")) {
  81. if (lookup_user("From")) {
  82. if (is_simple_rls_target("$uid-list")) {
  83. # takes From UID and makes XCAP query
  84. # for user's list named "default"
  85. if (!query_resource_list("default")) {
  86. t_reply("500", "XCAP query error");
  87. break;
  88. }
  89. handle_rls_subscription("1");
  90. break;
  91. }
  92. }
  93. }
  94. }
  95. ...
  96. </programlisting>
  97. <para>In this case if SUBSCRIBE request arrives and From is
  98. [email protected] and To is [email protected], the function
  99. returns true and the subscription is handled like subscription to
  100. "user's resource list" (not "global") as written above.
  101. </para>
  102. </example>
  103. </listitem>
  104. </varlistentry>
  105. <varlistentry id="query_rls_services">
  106. <term><varname>query_rls_services</varname></term>
  107. <listitem>
  108. <para>Get list from global rls-services document.</para>
  109. <para>Function loads "global resource list" from XCAP server. This list
  110. is then processed by RLS module using <xref linkend="handle_rls_subscription"/>.
  111. </para>
  112. </listitem>
  113. </varlistentry>
  114. <varlistentry id="query_resource_list">
  115. <term><varname>query_resource_list</varname></term>
  116. <listitem>
  117. <para>Get user's resource list.</para>
  118. <variablelist><title>Parameters:</title>
  119. <varlistentry>
  120. <term>list_name (string)</term>
  121. <listitem><para>Name of the requested list. If empty, it loads whole
  122. user's resource-lists document as one list.</para></listitem>
  123. </varlistentry>
  124. </variablelist>
  125. <para>Function loads "user's resource list" from XCAP server. This list
  126. is then processed by RLS module using <xref linkend="handle_rls_subscription"/>.
  127. </para>
  128. </listitem>
  129. </varlistentry>
  130. <varlistentry>
  131. <term><varname>have_flat_list</varname></term>
  132. <listitem>
  133. <para>Test if a resource list is loaded.</para>
  134. <para>Function tests if a list was loaded using one of query
  135. functions (<xref linkend="query_resource_list"/> or <xref
  136. linkend="query_rls_services"/>) and returns 1 if yes and -1
  137. otherwise.
  138. </para>
  139. </listitem>
  140. </varlistentry>
  141. </variablelist>
  142. </section>