presence/event_list.h

Go to the documentation of this file.
00001 /*
00002  * $Id: event_list.h 1953 2007-04-04 08:50:33Z anca_vamanu $
00003  *
00004  * presence module - presence server implementation
00005  *
00006  * Copyright (C) 2006 Voice Sistem S.R.L.
00007  *
00008  * This file is part of Kamailio, a free SIP server.
00009  *
00010  * Kamailio is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version
00014  *
00015  * Kamailio is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License 
00021  * along with this program; if not, write to the Free Software 
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  * History:
00025  * --------
00026  *  2007-04-05  initial version (anca)
00027  */
00028 
00029 /*! \file
00030  * \brief Kamailio presence module :: Events
00031  * \ingroup presence 
00032  */
00033 
00034 
00035 #ifndef _PRES_EV_LST_H
00036 #define  _PRES_EV_LST_H
00037 
00038 #include "../../parser/msg_parser.h"
00039 #include "../../parser/parse_event.h"
00040 #include "../../str.h"
00041 #include "subscribe.h"
00042 
00043 #define WINFO_TYPE         1<< 0
00044 #define PUBL_TYPE        1<< 1
00045 
00046 struct subscription;
00047 
00048 typedef int (apply_auth_t)(str* , struct subscription*, str** );
00049 
00050 typedef int (publ_handling_t)(struct sip_msg*);
00051 
00052 typedef int (subs_handling_t)(struct sip_msg*);
00053 
00054 typedef str* (agg_nbody_t)(str* pres_user, str* pres_domain, str** body_array, int n, int off_index);
00055 /* params for agg_body_t 
00056  * body_array= an array with all the bodies stored for that resource
00057  * n= the number of bodies
00058  * off_index= the index of the registration(etag) for which a Publish
00059  *          with Expires: 0 has just been received
00060  * */
00061 typedef str* (aux_body_processing_t)(struct subscription *subs, str* body);
00062 /* params for agg_body_t 
00063  * subs= a subscription structure to manipulate the body for a certain watcher
00064  * body= the original body
00065  *
00066  * return value: 0: means that there was no manipulation or the manipulation was
00067  *                  done directly in the original body
00068  *           pointer: a pointer to str for the "per watcher" body. gets freed by aux_free_body()
00069  * */
00070 typedef int (is_allowed_t)(struct subscription* subs);
00071 typedef int (get_rules_doc_t)(str* user, str* domain, str** rules_doc);
00072 /* return code rules for is_allowed_t
00073  * < 0  if error occured
00074  * =0  if no change in status(if no xcap document exists)
00075  * >0   if change in status
00076  * */
00077 
00078 /* event specific body free function */
00079 typedef void(free_body_t)(char* body);
00080 
00081 struct pres_ev
00082 {
00083    str name;
00084    event_t* evp;
00085    str content_type;
00086    int default_expires;
00087    int type;
00088    int etag_not_new;
00089    /*
00090     *  0 - the standard mechanism (allocating new etag for each Publish)
00091     *  1 - allocating an etag only for an initial Publish 
00092     * */
00093    /* fileds that deal with authorization rules*/
00094    /*
00095     *  req_auth -> flag 0  - if not require 
00096     *  is_watcher_allowed  - get subscription state from xcap rules
00097     *  apply_auth_nbody    - alter the body according to authorization rules
00098     */
00099    int req_auth;
00100    get_rules_doc_t* get_rules_doc;
00101    apply_auth_t*  apply_auth_nbody;
00102    is_allowed_t*  get_auth_status;
00103    
00104    /* an agg_body_t function should be registered if the event permits having
00105     * multiple published states and requires an aggregation of the information
00106     * otherwise, this field should be NULL and the last published state is taken 
00107     * when constructing Notify msg 
00108     * */
00109    agg_nbody_t* agg_nbody;
00110    publ_handling_t  * evs_publ_handl;
00111    subs_handling_t  * evs_subs_handl;
00112    free_body_t* free_body;
00113    /* sometimes it is necessary that a module make changes for a body for each 
00114     * active watcher (e.g. setting the "version" parameter in an XML document.
00115     * If a module registers the aux_body_processing callback, it gets called for
00116     * each watcher. It either gets the body received by the PUBLISH, or the body
00117     * generated by the agg_nbody function.
00118     * The module can deceide if it makes a copy of the original body, which is then
00119     * manipulated, or if it works directly in the original body. If the module makes a
00120     * copy of the original body, it also has to register the aux_free_body() to 
00121     * free this "per watcher" body.
00122     */
00123    aux_body_processing_t* aux_body_processing;
00124    free_body_t* aux_free_body;
00125    struct pres_ev* wipeer;       
00126    struct pres_ev* next;
00127    
00128 };
00129 typedef struct pres_ev pres_ev_t;
00130 
00131 typedef struct evlist
00132 {
00133    int ev_count;
00134    pres_ev_t* events;
00135 }evlist_t;  
00136 
00137 evlist_t* init_evlist(void);
00138 
00139 int add_event(pres_ev_t* event);
00140 
00141 typedef int (*add_event_t)(pres_ev_t* event);
00142 
00143 void free_event_params(param_t* params, int mem_type);
00144 
00145 pres_ev_t* contains_event(str* name, event_t* parsed_event);
00146 
00147 typedef pres_ev_t* (*contains_event_t)(str* name, event_t* parsed_event);
00148 
00149 int get_event_list(str** ev_list);
00150 
00151 typedef int (*get_event_list_t) (str** ev_list);
00152 
00153 void destroy_evlist(void);
00154 
00155 extern evlist_t* EvList;
00156 
00157 pres_ev_t* search_event(event_t* event);
00158 typedef pres_ev_t* (*search_event_t)(event_t* event);
00159 
00160 event_t* shm_copy_event(event_t* e);
00161 
00162 void shm_free_event(event_t* ev);
00163 
00164 void free_pres_event(pres_ev_t* ev);
00165 
00166 
00167 #endif

Generated on Thu May 24 02:00:26 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6