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
00026
00027
00028
00029
00030 #ifndef WATCHER_H
00031 #define WATCHER_H
00032
00033 #include "../../str.h"
00034 #include "../../modules/tm/dlg.h"
00035 #include "../../lib/srdb2/db.h"
00036 #include "../../parser/parse_content.h"
00037 #include "../../parser/parse_event.h"
00038 #include <stdio.h>
00039 #include <time.h>
00040
00041 #define DOC_XPIDF MIMETYPE(APPLICATION,XPIDFXML)
00042 #define DOC_LPIDF MIMETYPE(APPLICATION,LPIDFXML)
00043 #define DOC_PIDF MIMETYPE(APPLICATION,PIDFXML)
00044 #define DOC_CPIM_PIDF MIMETYPE(APPLICATION,CPIM_PIDFXML)
00045 #define DOC_MSRTC_PIDF MIMETYPE(APPLICATION,XML_MSRTC_PIDF)
00046 #define DOC_WINFO MIMETYPE(APPLICATION,WATCHERINFOXML)
00047
00048
00049 #define DOC_MULTIPART_RELATED MIMETYPE(MULTIPART,RELATED),
00050 #define DOC_RLMI_XML MIMETYPE(APPLICATION,RLMIXML)
00051
00052 typedef enum watcher_status {
00053 WS_PENDING = 0,
00054 WS_ACTIVE = 1,
00055 WS_REJECTED = 2,
00056 WS_TERMINATED = 3,
00057 WS_PENDING_TERMINATED = 4
00058 } watcher_status_t;
00059
00060 extern str watcher_status_names[];
00061 extern str watcher_event_names[];
00062
00063 typedef enum watcher_event {
00064 WE_SUBSCRIBE = 0,
00065 WE_APPROVED = 1,
00066 WE_DEACTIVATED = 2,
00067 WE_PROBATION = 3,
00068 WE_REJECTED = 4,
00069 WE_TIMEOUT = 5,
00070 WE_GIVEUP = 6,
00071 WE_NORESOURCE = 7
00072 } watcher_event_t;
00073
00074 typedef enum wflags {
00075 WFLAG_SUBSCRIPTION_CHANGED=1
00076 } wflags_t;
00077
00078
00079
00080
00081 typedef struct watcher {
00082 str display_name;
00083 str uri;
00084 time_t expires;
00085 int event_package;
00086 int preferred_mimetype;
00087 int document_index;
00088 dlg_t* dialog;
00089 str id;
00090 str server_contact;
00091 wflags_t flags;
00092 watcher_event_t event;
00093 watcher_status_t status;
00094 struct watcher *prev, *next;
00095 } watcher_t;
00096
00097 struct presentity;
00098
00099
00100 watcher_status_t watcher_status_from_string(str *wsname);
00101
00102
00103 int new_watcher_no_wb(str* _uri, time_t _e, int event_package,
00104 int doc_type, dlg_t* _dlg, str *display_name,
00105 str *server_contact,
00106 str *id,
00107 watcher_t** _w);
00108
00109
00110 void free_watcher(watcher_t* _w);
00111
00114 int append_watcher(struct presentity *_p, watcher_t *_w, int add_to_db);
00115
00116
00117 void remove_watcher(struct presentity* _p, watcher_t* _w);
00118
00119
00120
00121 int find_watcher_dlg(struct presentity* _p, dlg_id_t *dlg_id, int _et, watcher_t** _w);
00122
00123
00124 int db_update_watcher(struct presentity *p, watcher_t* _w);
00125
00126
00127 int update_watcher(struct presentity *p, watcher_t* _w, time_t _e, struct sip_msg *m);
00128
00129
00130 int db_read_watcherinfo(struct presentity *_p, db_con_t* db);
00131
00134 int is_watcher_terminated(watcher_t *w);
00135
00137 int is_watcher_authorized(watcher_t *w);
00138
00140 void set_watcher_terminated_status(watcher_t *w);
00141
00142 const char *event_package2str(int et);
00143
00144 #endif