123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
- <section id="pa.functions"><title>Functions</title>
- <variablelist>
- <varlistentry>
- <term><varname>handle_subscription(domain)</varname></term>
- <listitem>
- <para>This function processes SUBSCRIBE requests to "presence" and
- "presence.winfo" (see <link
- linkend="pa.param.watcherinfo_notify">watcherinfo_notify
- parameter</link>) events. </para>
- <para>Meaning of the parameters is as follows:</para>
- <itemizedlist>
- <listitem>
- <para><emphasis>domain</emphasis> - This can be either "registrar" or "jabber".
- </para>
- </listitem>
- </itemizedlist>
- <example>
- <title><function>handle_subscription</function> usage</title>
- <programlisting>
- ...
- handle_subscription("registrar");
- ...
- </programlisting>
- </example>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><varname>handle_publish(domain)</varname></term>
- <listitem><para>Processes PUBLISH request and generates response to it.
- </para></listitem>
- </varlistentry>
- <varlistentry>
- <term><varname>target_online(domain)</varname></term>
- <listitem><para>This function returns 1 if the target (using get_to_uid on
- current message) is online, -1 otherwise.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><varname>check_subscription_status(status)</varname></term>
- <listitem><para>This function returns 1 if last subscription is in status
- given by parameter, -1 otherwise. The <parameter>status</parameter> can have
- values:
-
- <variablelist>
- <varlistentry>
- <term>pending</term>
- <listitem><para>Subscription was created but no status information will
- be sent to the watcher.</para></listitem>
- </varlistentry>
- <varlistentry>
- <term>active</term>
- <listitem><para>Subscription was established and all presence
- information will be sent to the watcher.</para></listitem>
- </varlistentry>
- <!-- <varlistentry>
- <term>rejected</term>
- <listitem><para>Subscription was not established due to authorization
- rules.</para></listitem>
- </varlistentry>-->
- <varlistentry>
- <term>terminated</term>
- <listitem><para>Subscription was terminated.</para></listitem>
- </varlistentry>
-
- </variablelist>
-
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><varname>store_winfo(domain)</varname></term>
- <listitem><para>This function stores data about currently created
- subscription into database for later dumping in the form of watcherinfo
- notification. It should be called after handle_subscription
- during processing SUBSCRIBE request.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><varname>dump_stored_winfo(domain, event_package)</varname></term>
- <listitem><para>This function tries to send stored watcherinfo data
- in the context of existing watcherinfo subscription. It uses get_to_uid as
- target for notification. If there is no watcherinfo subscription to such
- presentity, no information is sent.</para>
- <para>If the client responds with 2xx on generated NOTIFY request, the
- stored information is removed from database.
- </para>
- <example><title><function>target_online</function>,
- <function>store_winfo</function>, <function>dump_stored_winfo</function> usage</title>
- <programlisting>
- ...
- if (method=="SUBSCRIBE") {
- if (!t_newtran()) {
- sl_reply_error();
- break;
- };
-
- if (handle_subscription("registrar")) {; # uses uid from AVP (get_to_uid)
- if (@msg.event=~"presence\.winfo") {
- log(1, "subscription to watcherinfo\n");
- dump_stored_winfo("registrar", "presence");
- log(1, "OFFLINE AUTH: watcherinfo dumped\n");
- }
- else {
- if ((@msg.event=~"presence") && (check_subscription_status("pending"))) {
- log(1, "pending subscription to presence\n");
- # if offline user and new "pending" subscription
- if (!target_online("registrar") && (@to.tag=="")) {
- log(1, "OFFLINE AUTH: storing for offline user\n");
- store_winfo("registrar");
- }
- }
- }
- }
- break;
- };
- ...
- </programlisting>
- </example>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><varname>authorize_message(filename)</varname></term>
- <listitem><para>This function reads and processes IM authorization data and
- returns 1 if message can be accepted by destination user. If there is no IM
- authorization document on given XCAP server, it returns 1 too (MESSAGE is
- enabled by default). If the sender is blocked by recipient rules, this
- function returns -1. For more details about authorization documents see
- <xref linkend="im_rules"/>.
- </para>
- <para>Filename parameter specifies the name of file on XCAP server which
- contains message authorization rules. It is <quote>im-rules.xml</quote> by
- default.
- </para>
- <example><title><function>authorize_message</function> usage</title>
- <programlisting>
- ...
- if (method=="MESSAGE") {
- if (authorize_message("im-rules.xml")) {
- if (!lookup("location")) {
- sl_reply("404", "Not Found");
- break;
- };
- if (!t_relay()) { sl_reply_error(); };
- }
- else {
- sl_reply("403", "Forbidden");
- }
- break;
- }
- ...
- </programlisting>
- </example>
- </listitem>
- </varlistentry>
- </variablelist>
- </section>
|