modules_s/usrloc/notify.h

00001 /*
00002  * $Id$
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  *
00006  * This file is part of ser, a free SIP server.
00007  *
00008  * ser is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * For a license to use the ser software under conditions
00014  * other than those described here, or to purchase support for this
00015  * software, please contact iptel.org by e-mail at the following addresses:
00016  *    info@iptel.org
00017  *
00018  * ser is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License 
00024  * along with this program; if not, write to the Free Software 
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  *
00027  */
00028 
00029 #ifndef NOTIFY_H
00030 #define NOTIFY_H
00031 
00032 #include "../../str.h"
00033 #include "urecord.h"
00034 #include "../../parser/msg_parser.h"
00035 
00036 /* FIXME: Possible race condition - a record pointer will be put in notify_record, domain lock
00037  * will be released, meanwhile pa module unregisters the callback and contacts will be removed
00038  * too, then the record will be removed and notify_record will point to an non-existent structure
00039  */
00040 
00041 struct urecord;
00042 
00043 typedef enum pres_state {
00044         PRES_OFFLINE = 0,
00045         PRES_ONLINE
00046 } pres_state_t;
00047 
00048 typedef void (*notcb_t)(str* uid, str* _contact, pres_state_t _p, void* _d);
00049 
00050 typedef int (*register_watcher_t)(str* _f, str* _t, notcb_t _c, void* _data);
00051 typedef int (*unregister_watcher_t)(str* _f, str* _t, notcb_t _c, void* _data);
00052 
00053 typedef struct notify_cb {
00054         notcb_t cb;
00055         void* data;
00056         struct notify_cb* next;
00057 } notify_cb_t;
00058 
00059 
00060 void notify_watchers(struct urecord* _r, ucontact_t *_c, int state);
00061 
00062 int add_watcher(struct urecord* _r, notcb_t _c, void* _d);
00063 
00064 int remove_watcher(struct urecord* _r, notcb_t _c, void* _d);
00065 
00066 int register_watcher(str* _d, str* uid, notcb_t _c, void* _data);
00067 
00068 int unregister_watcher(str* _d, str* uid, notcb_t _c, void* _data);
00069 
00070 int post_script(struct sip_msg* _m, void* param);
00071 
00072 #endif /* NOTIFY_H */