notify.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2001-2003 FhG Fokus
  5. *
  6. * This file is part of ser, a free SIP server.
  7. *
  8. * ser is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * For a license to use the ser software under conditions
  14. * other than those described here, or to purchase support for this
  15. * software, please contact iptel.org by e-mail at the following addresses:
  16. * [email protected]
  17. *
  18. * ser is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  26. *
  27. */
  28. #ifndef NOTIFY_H
  29. #define NOTIFY_H
  30. #include "../../str.h"
  31. #include "urecord.h"
  32. #include "../../parser/msg_parser.h"
  33. /* FIXME: Possible race condition - a record pointer will be put in notify_record, domain lock
  34. * will be released, meanwhile pa module unregisters the callback and contacts will be removed
  35. * too, then the record will be removed and notify_record will point to an non-existent structure
  36. */
  37. struct urecord;
  38. typedef enum pres_state {
  39. PRES_OFFLINE = 0,
  40. PRES_ONLINE
  41. } pres_state_t;
  42. typedef void (*notcb_t)(str* uid, str* _contact, pres_state_t _p, void* _d);
  43. typedef int (*register_watcher_t)(str* _f, str* _t, notcb_t _c, void* _data);
  44. typedef int (*unregister_watcher_t)(str* _f, str* _t, notcb_t _c, void* _data);
  45. typedef struct notify_cb {
  46. notcb_t cb;
  47. void* data;
  48. struct notify_cb* next;
  49. } notify_cb_t;
  50. void notify_watchers(struct urecord* _r, ucontact_t *_c, int state);
  51. int add_watcher(struct urecord* _r, notcb_t _c, void* _d);
  52. int remove_watcher(struct urecord* _r, notcb_t _c, void* _d);
  53. int register_watcher(str* _d, str* uid, notcb_t _c, void* _data);
  54. int unregister_watcher(str* _d, str* uid, notcb_t _c, void* _data);
  55. int post_script(struct sip_msg* _m, void* param);
  56. #endif /* NOTIFY_H */