xmpp_api.h

Go to the documentation of this file.
00001 /*
00002  * $Id: xmpp_api.h 5003 2008-09-26 11:01:51Z henningw $
00003  *
00004  * XMPP Module
00005  * This file is part of Kamailio, a free SIP server.
00006  *
00007  * Copyright (C) 2006 Voice Sistem S.R.L.
00008  *
00009  * Kamailio is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version
00013  *
00014  * Kamailio is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022  *
00023  * 
00024  */
00025 
00026 /*! \file
00027  * \brief The XMPP api
00028  * \ingroup xmpp
00029  */
00030 
00031 
00032 #ifndef _XMPP_API_H_
00033 #define _XMPP_API_H_
00034 
00035 #define XMPP_RCV_MESSAGE      (1<<0)
00036 #define XMPP_RCV_PRESENCE     (1<<1)
00037 #define XMPP_RCV_IQ          (1<<2)
00038 
00039 typedef void (xmpp_cb_f) (char *msg, int type, void *param);
00040 typedef int (*register_xmpp_cb_t)(int types, xmpp_cb_f f, void *param);
00041 
00042 
00043 typedef struct xmpp_callback_
00044 {
00045    int types;                   /*!< types of events that trigger the callback*/
00046    xmpp_cb_f *cbf;              /*!< callback function */
00047    void *cbp;                   /*!< param to be passed to callback function */
00048    struct xmpp_callback_ *next;
00049 } xmpp_callback_t;
00050 
00051 typedef struct xmpp_cb_list_
00052 {
00053    xmpp_callback_t *first;
00054    int types;
00055 } xmpp_cb_list_t;
00056 
00057 
00058 extern xmpp_cb_list_t*  _xmpp_cb_list;
00059 
00060 
00061 #define xmpp_isset_cb_type(_types_) \
00062    ((_xmpp_cb_list->types)|(_types_) )
00063 
00064 
00065 int init_xmpp_cb_list(void);
00066 
00067 void destroy_xmpp_cb_list(void);
00068 
00069 
00070 int register_xmpp_cb( int types, xmpp_cb_f f, void *param );
00071 
00072 /*! \brief run all transaction callbacks for an event type */
00073 static inline void run_xmpp_callbacks( int type, char *msg)
00074 {
00075    xmpp_callback_t *it;
00076 
00077    for (it=_xmpp_cb_list->first; it; it=it->next)  {
00078       if(it->types&type) {
00079          LM_DBG("cb: msg=%p, callback type %d/%d fired\n",
00080             msg, type, it->types );
00081          it->cbf( msg, type, it->cbp );
00082       }
00083    }
00084 }
00085 
00086 typedef int (*xmpp_send_xpacket_f)(str *from, str *to, str *msg, str *id);
00087 int xmpp_send_xpacket(str *from, str *to, str *msg, str *id);
00088 
00089 typedef int (*xmpp_send_xmessage_f)(str *from, str *to, str *msg, str *id);
00090 int xmpp_send_xmessage(str *from, str *to, str *msg, str *id);
00091 
00092 typedef int (*xmpp_send_xsubscribe_f)(str *from, str *to, str *msg, str *id);
00093 int xmpp_send_xsubscribe(str *from, str *to, str *msg, str *id);
00094 
00095 typedef int (*xmpp_send_xnotify_f)(str *from, str *to, str *msg, str *id);
00096 int xmpp_send_xnotify(str *from, str *to, str *msg, str *id);
00097 
00098 typedef char* (*xmpp_translate_uri_f)(char *uri);
00099 char *decode_uri_sip_xmpp(char *uri);
00100 char *encode_uri_sip_xmpp(char *uri);
00101 char *decode_uri_xmpp_sip(char *jid);
00102 char *encode_uri_xmpp_sip(char *jid);
00103 
00104 typedef struct xmpp_api_
00105 {
00106    register_xmpp_cb_t register_callback;
00107    xmpp_send_xpacket_f xpacket;
00108    xmpp_send_xmessage_f xmessage;
00109    xmpp_send_xsubscribe_f xsubscribe;
00110    xmpp_send_xnotify_f xnotify;
00111    xmpp_translate_uri_f decode_uri_sip_xmpp;
00112    xmpp_translate_uri_f encode_uri_sip_xmpp;
00113    xmpp_translate_uri_f decode_uri_xmpp_sip;
00114    xmpp_translate_uri_f encode_uri_xmpp_sip;
00115 } xmpp_api_t;
00116 
00117 typedef int (*bind_xmpp_t)(xmpp_api_t* api);
00118 int bind_xmpp(xmpp_api_t* api);
00119 
00120 #endif
00121 

Generated on Fri May 25 00:00:35 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6