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
00031 #ifndef PRESENTITY_H
00032 #define PRESENTITY_H
00033
00034 #include "../../str.h"
00035 #include "../../modules/tm/dlg.h"
00036 #include "watcher.h"
00037 #include "hslot.h"
00038 #include "trace.h"
00039 #include "pdomain.h"
00040
00041 #include <xcap/pres_rules.h>
00042 #include <cds/msg_queue.h>
00043 #include <cds/list.h>
00044 #include <presence/notifier.h>
00045 #include <presence/subscriber.h>
00046 #include <presence/pres_doc.h>
00047 #include <cds/dbid.h>
00048
00049 typedef struct presence_tuple {
00050 presence_tuple_info_t data;
00051
00052
00053
00054
00055 int is_published;
00056 str etag;
00057 time_t expires;
00058 str published_id;
00059 } presence_tuple_t;
00060
00061 typedef struct {
00062 presence_note_t data;
00063
00064 str etag;
00065 time_t expires;
00066 str dbid;
00067 } pa_presence_note_t;
00068
00069 typedef struct _pa_extension_element_t {
00070 extension_element_t data;
00071
00072 str etag;
00073 time_t expires;
00074 str dbid;
00075 } pa_extension_element_t;
00076
00077 typedef struct {
00078 str user;
00079 str contact;
00080 basic_tuple_status_t state;
00081 } tuple_change_info_t;
00082
00083 struct pdomain;
00084
00085 typedef enum pflag {
00086 PFLAG_PRESENCE_CHANGED=1,
00087 PFLAG_WATCHERINFO_CHANGED=2
00088 } pflag_t;
00089
00090 typedef struct _internal_pa_subscription_t {
00091 struct _internal_pa_subscription_t *prev, *next;
00092 watcher_status_t status;
00093 qsa_subscription_t *subscription;
00094
00095
00096
00097 } internal_pa_subscription_t;
00098
00099
00100 typedef struct presentity {
00101
00102 presentity_info_t data;
00103 str uuid;
00104
00105
00106
00107 str pres_id;
00108 int id_cntr;
00109
00110
00111
00112 int ref_cnt;
00113 pflag_t flags;
00114 struct pdomain *pdomain;
00115 struct presentity* next;
00116 struct presentity* prev;
00117 struct hslot* slot;
00118
00119
00120
00121 watcher_t *first_watcher, *last_watcher;
00122 watcher_t *first_winfo_watcher, *last_winfo_watcher;
00123 internal_pa_subscription_t *first_qsa_subscription, *last_qsa_subscription;
00124
00125
00126
00127 presence_rules_t *authorization_info;
00128 xcap_query_params_t xcap_params;
00129 time_t auth_rules_refresh_time;
00130
00131 msg_queue_t mq;
00132
00133
00134
00135 qsa_subscription_data_t presence_subscription_data;
00136 qsa_subscription_t *presence_subscription;
00137 } presentity_t;
00138
00139
00140
00141
00142
00143
00144 #define get_first_tuple(p) ((presence_tuple_t*)(p->data.first_tuple))
00145 #define get_next_tuple(t) ((presence_tuple_t*)(t->data.next))
00146
00147 #define get_first_note(p) ((pa_presence_note_t*)(p->data.first_note))
00148 #define get_next_note(n) ((pa_presence_note_t*)(n->data.next))
00149
00150 #define get_first_extension(p) ((pa_extension_element_t*)(p->data.first_unknown_element))
00151 #define get_next_extension(pe) ((pa_extension_element_t*)(pe->data.next))
00152
00154 int new_presentity(struct pdomain *pdomain, str* _uri, str *uid,
00155 xcap_query_params_t *xcap_params, presentity_t** _p);
00156
00160 void free_presentity(presentity_t* _p);
00161
00162
00163 void release_presentity(presentity_t* _p);
00164
00169 int db_remove_presentity_data(presentity_t* presentity, const char *table);
00170
00171
00172
00173 int set_auth_rules(presentity_t *p, presence_rules_t *new_auth_rules);
00174
00175
00176
00177 int timer_presentity(presentity_t* _p);
00178
00179
00180
00181
00182
00183 int get_presentity_uid(str *uid_dst, struct sip_msg *m);
00184
00185
00186
00187
00188
00189
00190 int pres_uri2uid(str_t *uid_dst, const str_t *uri);
00191
00192
00193
00194 void free_tuple_change_info_content(tuple_change_info_t *i);
00195
00196
00197
00198
00199
00200 extern int auth_rules_refresh_time;
00201
00202 int pdomain_load_presentities(struct pdomain *pdomain);
00203
00204 #endif