src/modules/pua/pua_callback.h
cb3a3a6b
 /*
  * pua module - presence user agent module
  *
  * Copyright (C) 2007 Voice Sistem S.R.L.
  *
27642a08
  * This file is part of Kamailio, a free SIP server.
cb3a3a6b
  *
27642a08
  * Kamailio is free software; you can redistribute it and/or modify
cb3a3a6b
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version
  *
27642a08
  * Kamailio is distributed in the hope that it will be useful,
cb3a3a6b
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License 
  * along with this program; if not, write to the Free Software 
9e1ff448
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
cb3a3a6b
  */
 
 #ifndef PUA_CBACK
 #define PUA_CBACK
 
cf83221d
 #include "../../core/parser/parse_fline.h"
cb3a3a6b
 #include "../pua/hash.h"
 
232401de
 #define PUACB_MAX    		(1<<9)
cb3a3a6b
 
 /* callback function prototype */
232401de
 typedef int (pua_cb)(ua_pres_t* hentity, struct sip_msg*);
cb3a3a6b
 /* register callback function prototype */
 typedef int (*register_puacb_t)(int types, pua_cb f, void* param );
 
 
 struct pua_callback {
 	int id;                      /* id of this callback - useless */
 	int types;                   /* types of events that trigger the callback*/
 	pua_cb* callback;             /* callback function */
 	void* param;
 	struct pua_callback* next;
 };
 
 struct puacb_head_list {
 	struct pua_callback *first;
 	int reg_types;
 };
 
 
 extern struct puacb_head_list*  puacb_list;
 
c70d27ce
 int init_puacb_list(void);
cb3a3a6b
 
c70d27ce
 void destroy_puacb_list(void);
cb3a3a6b
 
 
 /* register a callback for several types of events */
 int register_puacb( int types, pua_cb f, void* param );
 
 /* run all transaction callbacks for an event type */
232401de
 static inline void run_pua_callbacks(ua_pres_t* hentity, struct sip_msg* msg)
cb3a3a6b
 {
 	struct pua_callback *cbp;
 
 	for (cbp= puacb_list->first; cbp; cbp=cbp->next)  {
 		if(cbp->types & hentity->flag) 
 		{	
85a70026
 			LM_DBG("found callback\n");
232401de
 			cbp->callback(hentity, msg);
cb3a3a6b
 		}
 	}
 }
232401de
 
 /* Q: should I call the registered callback functions when the modules refreshes a request? */
cb3a3a6b
 #endif