Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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;
00046 xmpp_cb_f *cbf;
00047 void *cbp;
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
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