Przeglądaj źródła

modules_k/presence: Fixed presence hard-state implementation

- Removed modparams added when I did this originally
- Hard-state is still "publish"ed to the presentity table (with expiry
  of -1)
- Removed exported function for updating hard-state presentity and
  added a new type to pres_refresh_watchers instead (also updated
  refreshWatchers MI command)
- Hard-state presentity now fetched using the event->get_pidf_doc()
  function instead of directly from the database
- Also fixed two bugs (from my notifier work) found during testing:
  - query_db_notify() sends NOTIFY requests immediately (instead of
    through notifier tasks)
  - segmentation fault in update_pw_dialogs_dbonlymode() when there
    are no matching dialogs
Peter Dunkley 13 lat temu
rodzic
commit
258bc7e2f9

+ 160 - 226
modules_k/presence/README

@@ -34,38 +34,36 @@ Juha Heinanen
         3. Parameters
         3. Parameters
 
 
               3.1. db_url(str)
               3.1. db_url(str)
-              3.2. xcap_db_url(str)
-              3.3. presentity_table(str)
-              3.4. active_watchers_table(str)
-              3.5. watchers_table(str)
-              3.6. xcap_table(str)
-              3.7. clean_period (int)
-              3.8. db_update_period (int)
-              3.9. waitn_time (int)
-              3.10. notifier_poll_rate (int)
-              3.11. notifier_processes (int)
-              3.12. to_tag_pref (str)
-              3.13. expires_offset (int)
-              3.14. max_expires (int)
-              3.15. server_address (str)
-              3.16. subs_db_mode (int)
-              3.17. publ_cache (int)
-              3.18. subs_htable_size (int)
-              3.19. pres_htable_size (int)
-              3.20. send_fast_notify (int)
-              3.21. enable_sphere_check (int)
-              3.22. timeout_rm_subs (int)
-              3.23. fetch_rows (integer)
-              3.24. integrated_xcap_server (integer)
+              3.2. presentity_table(str)
+              3.3. active_watchers_table(str)
+              3.4. watchers_table(str)
+              3.5. clean_period (int)
+              3.6. db_update_period (int)
+              3.7. waitn_time (int)
+              3.8. notifier_poll_rate (int)
+              3.9. notifier_processes (int)
+              3.10. to_tag_pref (str)
+              3.11. expires_offset (int)
+              3.12. max_expires (int)
+              3.13. server_address (str)
+              3.14. subs_db_mode (int)
+              3.15. publ_cache (int)
+              3.16. subs_htable_size (int)
+              3.17. pres_htable_size (int)
+              3.18. send_fast_notify (int)
+              3.19. enable_sphere_check (int)
+              3.20. timeout_rm_subs (int)
+              3.21. fetch_rows (integer)
 
 
         4. Functions
         4. Functions
 
 
               4.1. handle_publish(char* sender_uri)
               4.1. handle_publish(char* sender_uri)
               4.2. handle_subscribe([watcher_uri])
               4.2. handle_subscribe([watcher_uri])
               4.3. pres_auth_status(watcher_uri, presentity_uri)
               4.3. pres_auth_status(watcher_uri, presentity_uri)
-              4.4. pres_refresh_watchers(uri, event, type)
+              4.4. pres_refresh_watchers(uri, event, type[, file_uri,
+                      filename])
+
               4.5. pres_update_watchers(uri, event)
               4.5. pres_update_watchers(uri, event)
-              4.6. pres_update_presentity(uri, file_uri, filename)
 
 
         5. MI Commands
         5. MI Commands
 
 
@@ -97,35 +95,31 @@ Juha Heinanen
    List of Examples
    List of Examples
 
 
    1.1. Set db_url parameter
    1.1. Set db_url parameter
-   1.2. Set xcap_db_url parameter
-   1.3. Set presentity_table parameter
-   1.4. Set active_watchers_table parameter
-   1.5. Set watchers_table parameter
-   1.6. Set xcap_table parameter
-   1.7. Set clean_period parameter
-   1.8. Set db_update_period parameter
-   1.9. Set waitn_time parameter
-   1.10. Set notifier_poll_rate parameter
-   1.11. Set notifier_processes parameter
-   1.12. Set to_tag_pref parameter
-   1.13. Set expires_offset parameter
-   1.14. Set max_expires parameter
-   1.15. Set server_address parameter
-   1.16. Set subs_db_mode parameter
-   1.17. Set publ_cache parameter
-   1.18. Set subs_htable_size parameter
-   1.19. Set pres_htable_size parameter
-   1.20. Set send_fast_notify parameter
-   1.21. Set enable_sphere_check parameter
-   1.22. Set timeout_rm_subs parameter
-   1.23. Set fetch_rows parameter
-   1.24. Set integrated_xcap_server parameter
-   1.25. handle_publish usage
-   1.26. handle_subscribe usage
-   1.27. pres_auth_status usage
-   1.28. pres_refresh_watchers usage
-   1.29. pres_update_watchers usage
-   1.30. pres_update_presentity usage
+   1.2. Set presentity_table parameter
+   1.3. Set active_watchers_table parameter
+   1.4. Set watchers_table parameter
+   1.5. Set clean_period parameter
+   1.6. Set db_update_period parameter
+   1.7. Set waitn_time parameter
+   1.8. Set notifier_poll_rate parameter
+   1.9. Set notifier_processes parameter
+   1.10. Set to_tag_pref parameter
+   1.11. Set expires_offset parameter
+   1.12. Set max_expires parameter
+   1.13. Set server_address parameter
+   1.14. Set subs_db_mode parameter
+   1.15. Set publ_cache parameter
+   1.16. Set subs_htable_size parameter
+   1.17. Set pres_htable_size parameter
+   1.18. Set send_fast_notify parameter
+   1.19. Set enable_sphere_check parameter
+   1.20. Set timeout_rm_subs parameter
+   1.21. Set fetch_rows parameter
+   1.22. handle_publish usage
+   1.23. handle_subscribe usage
+   1.24. pres_auth_status usage
+   1.25. pres_refresh_watchers usage
+   1.26. pres_update_watchers usage
    2.1. presence_api_t structure
    2.1. presence_api_t structure
 
 
 Chapter 1. Admin Guide
 Chapter 1. Admin Guide
@@ -141,38 +135,35 @@ Chapter 1. Admin Guide
    3. Parameters
    3. Parameters
 
 
         3.1. db_url(str)
         3.1. db_url(str)
-        3.2. xcap_db_url(str)
-        3.3. presentity_table(str)
-        3.4. active_watchers_table(str)
-        3.5. watchers_table(str)
-        3.6. xcap_table(str)
-        3.7. clean_period (int)
-        3.8. db_update_period (int)
-        3.9. waitn_time (int)
-        3.10. notifier_poll_rate (int)
-        3.11. notifier_processes (int)
-        3.12. to_tag_pref (str)
-        3.13. expires_offset (int)
-        3.14. max_expires (int)
-        3.15. server_address (str)
-        3.16. subs_db_mode (int)
-        3.17. publ_cache (int)
-        3.18. subs_htable_size (int)
-        3.19. pres_htable_size (int)
-        3.20. send_fast_notify (int)
-        3.21. enable_sphere_check (int)
-        3.22. timeout_rm_subs (int)
-        3.23. fetch_rows (integer)
-        3.24. integrated_xcap_server (integer)
+        3.2. presentity_table(str)
+        3.3. active_watchers_table(str)
+        3.4. watchers_table(str)
+        3.5. clean_period (int)
+        3.6. db_update_period (int)
+        3.7. waitn_time (int)
+        3.8. notifier_poll_rate (int)
+        3.9. notifier_processes (int)
+        3.10. to_tag_pref (str)
+        3.11. expires_offset (int)
+        3.12. max_expires (int)
+        3.13. server_address (str)
+        3.14. subs_db_mode (int)
+        3.15. publ_cache (int)
+        3.16. subs_htable_size (int)
+        3.17. pres_htable_size (int)
+        3.18. send_fast_notify (int)
+        3.19. enable_sphere_check (int)
+        3.20. timeout_rm_subs (int)
+        3.21. fetch_rows (integer)
 
 
    4. Functions
    4. Functions
 
 
         4.1. handle_publish(char* sender_uri)
         4.1. handle_publish(char* sender_uri)
         4.2. handle_subscribe([watcher_uri])
         4.2. handle_subscribe([watcher_uri])
         4.3. pres_auth_status(watcher_uri, presentity_uri)
         4.3. pres_auth_status(watcher_uri, presentity_uri)
-        4.4. pres_refresh_watchers(uri, event, type)
+        4.4. pres_refresh_watchers(uri, event, type[, file_uri, filename])
+
         4.5. pres_update_watchers(uri, event)
         4.5. pres_update_watchers(uri, event)
-        4.6. pres_update_presentity(uri, file_uri, filename)
 
 
    5. MI Commands
    5. MI Commands
 
 
@@ -226,29 +217,26 @@ Chapter 1. Admin Guide
 3. Parameters
 3. Parameters
 
 
    3.1. db_url(str)
    3.1. db_url(str)
-   3.2. xcap_db_url(str)
-   3.3. presentity_table(str)
-   3.4. active_watchers_table(str)
-   3.5. watchers_table(str)
-   3.6. xcap_table(str)
-   3.7. clean_period (int)
-   3.8. db_update_period (int)
-   3.9. waitn_time (int)
-   3.10. notifier_poll_rate (int)
-   3.11. notifier_processes (int)
-   3.12. to_tag_pref (str)
-   3.13. expires_offset (int)
-   3.14. max_expires (int)
-   3.15. server_address (str)
-   3.16. subs_db_mode (int)
-   3.17. publ_cache (int)
-   3.18. subs_htable_size (int)
-   3.19. pres_htable_size (int)
-   3.20. send_fast_notify (int)
-   3.21. enable_sphere_check (int)
-   3.22. timeout_rm_subs (int)
-   3.23. fetch_rows (integer)
-   3.24. integrated_xcap_server (integer)
+   3.2. presentity_table(str)
+   3.3. active_watchers_table(str)
+   3.4. watchers_table(str)
+   3.5. clean_period (int)
+   3.6. db_update_period (int)
+   3.7. waitn_time (int)
+   3.8. notifier_poll_rate (int)
+   3.9. notifier_processes (int)
+   3.10. to_tag_pref (str)
+   3.11. expires_offset (int)
+   3.12. max_expires (int)
+   3.13. server_address (str)
+   3.14. subs_db_mode (int)
+   3.15. publ_cache (int)
+   3.16. subs_htable_size (int)
+   3.17. pres_htable_size (int)
+   3.18. send_fast_notify (int)
+   3.19. enable_sphere_check (int)
+   3.20. timeout_rm_subs (int)
+   3.21. fetch_rows (integer)
 
 
 3.1. db_url(str)
 3.1. db_url(str)
 
 
@@ -265,69 +253,41 @@ modparam("presence", "db_url",
         "mysql://openser:openserrw@localhost/openser")
         "mysql://openser:openserrw@localhost/openser")
 ...
 ...
 
 
-3.2. xcap_db_url(str)
-
-   The XCAP database url.
-
-   This option is only required if integrated_xcap_server is enabled AND
-   the xcap table is on a difference server from the other presence
-   tables. If this option is not set db_url is used for the
-   integrated_xcap_server when required.
-
-   Default value is “NULL”.
-
-   Example 1.2. Set xcap_db_url parameter
-...
-modparam("presence", "xcap_db_url",
-        "mysql://openser:openserrw@localhost/openser")
-...
-
-3.3. presentity_table(str)
+3.2. presentity_table(str)
 
 
    The name of the db table where PUBLISH presence information is stored.
    The name of the db table where PUBLISH presence information is stored.
 
 
    Default value is “presentity”.
    Default value is “presentity”.
 
 
-   Example 1.3. Set presentity_table parameter
+   Example 1.2. Set presentity_table parameter
 ...
 ...
 modparam("presence", "presentity_table", "presentity")
 modparam("presence", "presentity_table", "presentity")
 ...
 ...
 
 
-3.4. active_watchers_table(str)
+3.3. active_watchers_table(str)
 
 
    The name of the db table where active subscription information is
    The name of the db table where active subscription information is
    stored.
    stored.
 
 
    Default value is “active_watchers”.
    Default value is “active_watchers”.
 
 
-   Example 1.4. Set active_watchers_table parameter
+   Example 1.3. Set active_watchers_table parameter
 ...
 ...
 modparam("presence", "active_watchers_table", "active_watchers")
 modparam("presence", "active_watchers_table", "active_watchers")
 ...
 ...
 
 
-3.5. watchers_table(str)
+3.4. watchers_table(str)
 
 
    The name of the db table where subscription states are stored.
    The name of the db table where subscription states are stored.
 
 
    Default value is “watchers”.
    Default value is “watchers”.
 
 
-   Example 1.5. Set watchers_table parameter
+   Example 1.4. Set watchers_table parameter
 ...
 ...
 modparam("presence", "watchers_table", "watchers")
 modparam("presence", "watchers_table", "watchers")
 ...
 ...
 
 
-3.6. xcap_table(str)
-
-   The name of the db table where XML documents are stored.
-
-   Default value is “xcap”.
-
-   Example 1.6. Set xcap_table parameter
-...
-modparam("presence", "xcap_table", "xcap")
-...
-
-3.7. clean_period (int)
+3.5. clean_period (int)
 
 
    The period in seconds between checks if there are expired messages
    The period in seconds between checks if there are expired messages
    stored in database.
    stored in database.
@@ -335,12 +295,12 @@ modparam("presence", "xcap_table", "xcap")
    Default value is “100”. A zero or negative value disables this
    Default value is “100”. A zero or negative value disables this
    activity.
    activity.
 
 
-   Example 1.7. Set clean_period parameter
+   Example 1.5. Set clean_period parameter
 ...
 ...
 modparam("presence", "clean_period", 100)
 modparam("presence", "clean_period", 100)
 ...
 ...
 
 
-3.8. db_update_period (int)
+3.6. db_update_period (int)
 
 
    The period at which to synchronize cached subscriber info with the
    The period at which to synchronize cached subscriber info with the
    database.
    database.
@@ -348,12 +308,12 @@ modparam("presence", "clean_period", 100)
    Default value is “100”. A zero or negative value disables
    Default value is “100”. A zero or negative value disables
    synchronization.
    synchronization.
 
 
-   Example 1.8. Set db_update_period parameter
+   Example 1.6. Set db_update_period parameter
 ...
 ...
 modparam("presence", "db_update_period", 100)
 modparam("presence", "db_update_period", 100)
 ...
 ...
 
 
-3.9. waitn_time (int)
+3.7. waitn_time (int)
 
 
    The maximum time period that NOTIFY requests will be buffered for. The
    The maximum time period that NOTIFY requests will be buffered for. The
    server will attempt to send NOTIFY requests within many seconds of a
    server will attempt to send NOTIFY requests within many seconds of a
@@ -365,12 +325,12 @@ modparam("presence", "db_update_period", 100)
 
 
    Default value is “5”.
    Default value is “5”.
 
 
-   Example 1.9. Set waitn_time parameter
+   Example 1.7. Set waitn_time parameter
 ...
 ...
 modparam("presence", "waitn_time", 10)
 modparam("presence", "waitn_time", 10)
 ...
 ...
 
 
-3.10. notifier_poll_rate (int)
+3.8. notifier_poll_rate (int)
 
 
    The number of times per second that the notifier processes should check
    The number of times per second that the notifier processes should check
    for work. Approximately 1/(waitn_time * notifier_poll_rate *
    for work. Approximately 1/(waitn_time * notifier_poll_rate *
@@ -382,12 +342,12 @@ modparam("presence", "waitn_time", 10)
 
 
    Default value is “10”.
    Default value is “10”.
 
 
-   Example 1.10. Set notifier_poll_rate parameter
+   Example 1.8. Set notifier_poll_rate parameter
 ...
 ...
 modparam("presence", "notifier_poll_rate", 20)
 modparam("presence", "notifier_poll_rate", 20)
 ...
 ...
 
 
-3.11. notifier_processes (int)
+3.9. notifier_processes (int)
 
 
    The number of notifier processes that should be started.
    The number of notifier processes that should be started.
 
 
@@ -402,24 +362,24 @@ modparam("presence", "notifier_poll_rate", 20)
 
 
    Default value is “1”.
    Default value is “1”.
 
 
-   Example 1.11. Set notifier_processes parameter
+   Example 1.9. Set notifier_processes parameter
 ...
 ...
 modparam("presence", "notifier_processes", 2)
 modparam("presence", "notifier_processes", 2)
 ...
 ...
 
 
-3.12. to_tag_pref (str)
+3.10. to_tag_pref (str)
 
 
    The prefix used when generating to_tag when sending replies for
    The prefix used when generating to_tag when sending replies for
    SUBSCRIBE requests.
    SUBSCRIBE requests.
 
 
    Default value is “10”.
    Default value is “10”.
 
 
-   Example 1.12. Set to_tag_pref parameter
+   Example 1.10. Set to_tag_pref parameter
 ...
 ...
 modparam("presence", "to_tag_pref", 'pres')
 modparam("presence", "to_tag_pref", 'pres')
 ...
 ...
 
 
-3.13. expires_offset (int)
+3.11. expires_offset (int)
 
 
    The value in seconds that should be subtracted from the expires value
    The value in seconds that should be subtracted from the expires value
    when sending a 200OK for a publish. It is used for forcing the client
    when sending a 200OK for a publish. It is used for forcing the client
@@ -427,35 +387,35 @@ modparam("presence", "to_tag_pref", 'pres')
 
 
    Default value is “0”.
    Default value is “0”.
 
 
-   Example 1.13. Set expires_offset parameter
+   Example 1.11. Set expires_offset parameter
 ...
 ...
 modparam("presence", "expires_offset", 10)
 modparam("presence", "expires_offset", 10)
 ...
 ...
 
 
-3.14. max_expires (int)
+3.12. max_expires (int)
 
 
    The the maximum admissible expires value for PUBLISH/SUBSCRIBE message
    The the maximum admissible expires value for PUBLISH/SUBSCRIBE message
    (in seconds).
    (in seconds).
 
 
    Default value is “3600”.
    Default value is “3600”.
 
 
-   Example 1.14. Set max_expires parameter
+   Example 1.12. Set max_expires parameter
 ...
 ...
 modparam("presence", "max_expires", 3600)
 modparam("presence", "max_expires", 3600)
 ...
 ...
 
 
-3.15. server_address (str)
+3.13. server_address (str)
 
 
    The presence server address which will become the value of Contact
    The presence server address which will become the value of Contact
    header filed for 200 OK replies to SUBSCRIBE and PUBLISH and in NOTIFY
    header filed for 200 OK replies to SUBSCRIBE and PUBLISH and in NOTIFY
    messages.
    messages.
 
 
-   Example 1.15. Set server_address parameter
+   Example 1.13. Set server_address parameter
 ...
 ...
 modparam("presence", "server_address", "sip:10.10.10.10:5060")
 modparam("presence", "server_address", "sip:10.10.10.10:5060")
 ...
 ...
 
 
-3.16. subs_db_mode (int)
+3.14. subs_db_mode (int)
 
 
    The presence module can utilize database for persistent subscription
    The presence module can utilize database for persistent subscription
    storage. If you use database, your subscriptions will survive machine
    storage. If you use database, your subscriptions will survive machine
@@ -489,12 +449,12 @@ modparam("presence", "server_address", "sip:10.10.10.10:5060")
 
 
    Default value is 2 (Write-Back scheme).
    Default value is 2 (Write-Back scheme).
 
 
-   Example 1.16. Set subs_db_mode parameter
+   Example 1.14. Set subs_db_mode parameter
 ...
 ...
 modparam("presence", "subs_db_mode", 1)
 modparam("presence", "subs_db_mode", 1)
 ...
 ...
 
 
-3.17. publ_cache (int)
+3.15. publ_cache (int)
 
 
    To improve performance, the presence module holds by default a publish
    To improve performance, the presence module holds by default a publish
    cache that says if a certain publication exists in database. This is
    cache that says if a certain publication exists in database. This is
@@ -510,12 +470,12 @@ modparam("presence", "subs_db_mode", 1)
 
 
    Default value is “1”.
    Default value is “1”.
 
 
-   Example 1.17. Set publ_cache parameter
+   Example 1.15. Set publ_cache parameter
 ...
 ...
 modparam("presence", "publ_cache", 0)
 modparam("presence", "publ_cache", 0)
 ...
 ...
 
 
-3.18. subs_htable_size (int)
+3.16. subs_htable_size (int)
 
 
    The size of the in-memory hash table to store subscription dialogs.
    The size of the in-memory hash table to store subscription dialogs.
    This parameter will be used as the power of 2 when computing table
    This parameter will be used as the power of 2 when computing table
@@ -523,24 +483,24 @@ modparam("presence", "publ_cache", 0)
 
 
    Default value is “9 (512)”.
    Default value is “9 (512)”.
 
 
-   Example 1.18. Set subs_htable_size parameter
+   Example 1.16. Set subs_htable_size parameter
 ...
 ...
 modparam("presence", "subs_htable_size", 11)
 modparam("presence", "subs_htable_size", 11)
 ...
 ...
 
 
-3.19. pres_htable_size (int)
+3.17. pres_htable_size (int)
 
 
    The size of the in-memory hash table to store publish records. This
    The size of the in-memory hash table to store publish records. This
    parameter will be used as the power of 2 when computing table size.
    parameter will be used as the power of 2 when computing table size.
 
 
    Default value is “9 (512)”.
    Default value is “9 (512)”.
 
 
-   Example 1.19. Set pres_htable_size parameter
+   Example 1.17. Set pres_htable_size parameter
 ...
 ...
 modparam("presence", "pres_htable_size", 11)
 modparam("presence", "pres_htable_size", 11)
 ...
 ...
 
 
-3.20. send_fast_notify (int)
+3.18. send_fast_notify (int)
 
 
    This parameter enables or disables the sending of an initial empty
    This parameter enables or disables the sending of an initial empty
    NOTIFY after a SUBSCRIBE/reSUBSCRIBE. This caused problems for MWI
    NOTIFY after a SUBSCRIBE/reSUBSCRIBE. This caused problems for MWI
@@ -550,12 +510,12 @@ modparam("presence", "pres_htable_size", 11)
 
 
    Default value is “1 ”.
    Default value is “1 ”.
 
 
-   Example 1.20. Set send_fast_notify parameter
+   Example 1.18. Set send_fast_notify parameter
 ...
 ...
 modparam("presence", "send_fast_notify", 0)
 modparam("presence", "send_fast_notify", 0)
 ...
 ...
 
 
-3.21. enable_sphere_check (int)
+3.19. enable_sphere_check (int)
 
 
    This parameter is a flag that should be set if permission rules include
    This parameter is a flag that should be set if permission rules include
    sphere checking. The sphere information is expected to be present in
    sphere checking. The sphere information is expected to be present in
@@ -565,12 +525,12 @@ modparam("presence", "send_fast_notify", 0)
 
 
    Default value is “0 ”.
    Default value is “0 ”.
 
 
-   Example 1.21. Set enable_sphere_check parameter
+   Example 1.19. Set enable_sphere_check parameter
 ...
 ...
 modparam("presence", "enable_sphere_check", 1)
 modparam("presence", "enable_sphere_check", 1)
 ...
 ...
 
 
-3.22. timeout_rm_subs (int)
+3.20. timeout_rm_subs (int)
 
 
    This parameter is a flag that should be set if subscriptions should be
    This parameter is a flag that should be set if subscriptions should be
    removed from the active_watchers when a NOTIFY times out. RFC3265
    removed from the active_watchers when a NOTIFY times out. RFC3265
@@ -580,44 +540,29 @@ modparam("presence", "enable_sphere_check", 1)
 
 
    Default value is “1”.
    Default value is “1”.
 
 
-   Example 1.22. Set timeout_rm_subs parameter
+   Example 1.20. Set timeout_rm_subs parameter
 ...
 ...
 modparam("presence", "timeout_rm_subs", 0)
 modparam("presence", "timeout_rm_subs", 0)
 ...
 ...
 
 
-3.23. fetch_rows (integer)
+3.21. fetch_rows (integer)
 
 
    Number of rows to be loaded in one step from database.
    Number of rows to be loaded in one step from database.
 
 
    Default value is 500.
    Default value is 500.
 
 
-   Example 1.23. Set fetch_rows parameter
+   Example 1.21. Set fetch_rows parameter
 ...
 ...
 modparam("presence", "fetch_rows", 1000)
 modparam("presence", "fetch_rows", 1000)
 ...
 ...
 
 
-3.24. integrated_xcap_server (integer)
-
-   Enable the integrated XCAP server connection. This is only required if
-   you want to use the pres_update_presentity() function. Setting to 0
-   means no integrated XCAP server, setting to 1 means enable integrated
-   XCAP server.
-
-   Default value is 0.
-
-   Example 1.24. Set integrated_xcap_server parameter
-...
-modparam("presence", "integrated_xcap_server", 1)
-...
-
 4. Functions
 4. Functions
 
 
    4.1. handle_publish(char* sender_uri)
    4.1. handle_publish(char* sender_uri)
    4.2. handle_subscribe([watcher_uri])
    4.2. handle_subscribe([watcher_uri])
    4.3. pres_auth_status(watcher_uri, presentity_uri)
    4.3. pres_auth_status(watcher_uri, presentity_uri)
-   4.4. pres_refresh_watchers(uri, event, type)
+   4.4. pres_refresh_watchers(uri, event, type[, file_uri, filename])
    4.5. pres_update_watchers(uri, event)
    4.5. pres_update_watchers(uri, event)
-   4.6. pres_update_presentity(uri, file_uri, filename)
 
 
 4.1.  handle_publish(char* sender_uri)
 4.1.  handle_publish(char* sender_uri)
 
 
@@ -639,7 +584,7 @@ modparam("presence", "integrated_xcap_server", 1)
 
 
    The module sends an appropriate stateless reply in all cases.
    The module sends an appropriate stateless reply in all cases.
 
 
-   Example 1.25. handle_publish usage
+   Example 1.22. handle_publish usage
 ...
 ...
         if(is_method("PUBLISH"))
         if(is_method("PUBLISH"))
         {
         {
@@ -670,7 +615,7 @@ modparam("presence", "integrated_xcap_server", 1)
 
 
    The module sends an appropriate stateless reply in all cases.
    The module sends an appropriate stateless reply in all cases.
 
 
-   Example 1.26. handle_subscribe usage
+   Example 1.23. handle_subscribe usage
 ...
 ...
 if(method=="SUBSCRIBE")
 if(method=="SUBSCRIBE")
     handle_subscribe();
     handle_subscribe();
@@ -687,7 +632,7 @@ if(method=="SUBSCRIBE")
 
 
    This function can be used from REQUEST_ROUTE.
    This function can be used from REQUEST_ROUTE.
 
 
-   Example 1.27. pres_auth_status usage
+   Example 1.24. pres_auth_status usage
 ...
 ...
 if (method=="MESSAGE") {
 if (method=="MESSAGE") {
     pres_auth_status("$fu", $ru");
     pres_auth_status("$fu", $ru");
@@ -699,7 +644,7 @@ if (method=="MESSAGE") {
 }
 }
 ...
 ...
 
 
-4.4.  pres_refresh_watchers(uri, event, type)
+4.4.  pres_refresh_watchers(uri, event, type[, file_uri, filename])
 
 
    The function can be used in configuration to triger notifies to
    The function can be used in configuration to triger notifies to
    watchers if a change in watchers authorization or in published state
    watchers if a change in watchers authorization or in published state
@@ -709,16 +654,21 @@ if (method=="MESSAGE") {
      * uri - the uri of the user who made the change and whose watchers
      * uri - the uri of the user who made the change and whose watchers
        should be informed.
        should be informed.
      * event - the event package.
      * event - the event package.
-     * type - it distinguishes between the two different types of events
+     * type - it distinguishes between the three different types of events
        that can trigger the refresh, depending on its value:
        that can trigger the refresh, depending on its value:
           + 0 - a change in watchers authentication.
           + 0 - a change in watchers authentication.
-          + 1 - a statical update in published state (either through
-            direct update in db table or by modifying the pidf
-            manipulation document, if pidf_manipulation parameter is set).
+          + 1 - a statical update in published state through direct update
+            in db table.
+          + 2 - a statical update in published state by modifying the pidf
+            manipulation document.
+     * file_uri - the uri of the pidf-manipulation file on the XCAP server
+       (only used for type 2).
+     * filename - the name of the pidf-manipulation file on the XCAP
+       server (only used for type 2).
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.28. pres_refresh_watchers usage
+   Example 1.25. pres_refresh_watchers usage
 ...
 ...
 pres_refresh_watchers("sip:[email protected]", "presence", 1);
 pres_refresh_watchers("sip:[email protected]", "presence", 1);
 ...
 ...
@@ -736,31 +686,11 @@ pres_refresh_watchers("sip:[email protected]", "presence", 1);
 
 
    This function can be used from ANY_ROUTE.
    This function can be used from ANY_ROUTE.
 
 
-   Example 1.29. pres_update_watchers usage
+   Example 1.26. pres_update_watchers usage
 ...
 ...
 pres_update_watchers("sip:[email protected]", "presence");
 pres_update_watchers("sip:[email protected]", "presence");
 ...
 ...
 
 
-4.6.  pres_update_presentity(uri, file_uri, filename)
-
-   The function can be used in configuration to triger updates to
-   presentities based on the content of pidf-manipulation documents stored
-   in the xcap db table. This enables "hard-state" presence to be set.
-
-   Parameters:
-     * uri - the uri of the presentity
-     * file_uri - the uri of the document on the XCAP server
-     * filename - the filename part of the uri of the document this is
-       used as the presentity ETag
-
-   This function can be used from ANY_ROUTE.
-
-   Example 1.30. pres_update_presentity usage
-...
-pres_update_presentity("$xcapuri(u=>xuid)", "$xcapuri(u=>uri_adoc)", "$xcapuri(u
-=>file)");
-...
-
 5. MI Commands
 5. MI Commands
 
 
    5.1. refreshWatchers
    5.1. refreshWatchers
@@ -774,16 +704,20 @@ pres_update_presentity("$xcapuri(u=>xuid)", "$xcapuri(u=>uri_adoc)", "$xcapuri(u
    Name: refreshWatchers
    Name: refreshWatchers
 
 
    Parameters:
    Parameters:
-     * presentity_uri : the uri of the user who made the change and whose
-       watchers should be informed
-     * event : the event package
-     * refresh type : it distinguishes between the two different types of
-       events that can trigger a refresh:
-          + a change in watchers authentication: refresh type= 0 ;
-          + a statical update in published state (either through direct
-            update in db table or by modifying the pidf manipulation
-            document, if pidf_manipulation parameter is set): refresh
-            type!= 0.
+     * uri - the uri of the user who made the change and whose watchers
+       should be informed
+     * event - the event package.
+     * type - it distinguishes between the three different types of events
+       that can trigger the refresh, depending on its value:
+          + 0 - a change in watchers authentication.
+          + 1 - a statical update in published state through direct update
+            in db table.
+          + 2 - a statical update in published state by modifying the pidf
+            manipulation document.
+     * file_uri - the uri of the pidf-manipulation file on the XCAP server
+       (only used for type 2).
+     * filename - the name of the pidf-manipulation file on the XCAP
+       server (only used for type 2).
 
 
    MI FIFO Command Format:
    MI FIFO Command Format:
                 :refreshWatchers:fifo_reply
                 :refreshWatchers:fifo_reply

+ 39 - 118
modules_k/presence/doc/presence_admin.xml

@@ -103,31 +103,6 @@ modparam("presence", "db_url",
 </programlisting>
 </programlisting>
 		</example>
 		</example>
 	</section>
 	</section>
-	<section>
-		<title><varname>xcap_db_url</varname>(str)</title>
-		<para>
-		The XCAP database url.
-		</para>
-		<para>This option is only required if integrated_xcap_server is
-		enabled AND the xcap table is on a difference server from the
-		other presence tables.  If this option is not set db_url is
-		used for the integrated_xcap_server when required.
-		</para>
-		<para>
-		<emphasis>Default value is <quote>NULL</quote>.</emphasis>
-		</para>
-		<example>
-		<title>Set <varname>xcap_db_url</varname> parameter</title>
-		<programlisting format="linespecific">
-...
-modparam("presence", "xcap_db_url", 
-	"&defaultdb;")
-...
-</programlisting>
-		</example>
-	</section>
-
-
 	<section>
 	<section>
 		<title><varname>presentity_table</varname>(str)</title>
 		<title><varname>presentity_table</varname>(str)</title>
 		<para>
 		<para>
@@ -182,25 +157,6 @@ modparam("presence", "watchers_table", "watchers")
 </programlisting>
 </programlisting>
 		</example>
 		</example>
 	</section>
 	</section>
-	<section>
-		<title><varname>xcap_table</varname>(str)</title>
-		<para>
-		The name of the db table where XML documents are stored.
-		</para>
-		<para>
-		<emphasis>	Default value is <quote>xcap</quote>.
-		</emphasis>
-		</para>
-		<example>
-		<title>Set <varname>xcap_table</varname> parameter</title>
-		<programlisting format="linespecific">
-...
-modparam("presence", "xcap_table", "xcap")
-...
-</programlisting>
-		</example>
-	</section>
-
 	<section>
 	<section>
 		<title><varname>clean_period</varname> (int)</title>
 		<title><varname>clean_period</varname> (int)</title>
 		<para>
 		<para>
@@ -616,28 +572,6 @@ modparam("presence", "timeout_rm_subs", 0)
 ...
 ...
 modparam("presence", "fetch_rows", 1000)
 modparam("presence", "fetch_rows", 1000)
 ...
 ...
-</programlisting>
-	    </example>
-	</section>
-	<section>
-	    <title><varname>integrated_xcap_server</varname> (integer)</title>
-	    <para>
-		Enable the integrated XCAP server connection.  This is only
-		required if you want to use the pres_update_presentity()
-		function.  Setting to 0 means no integrated XCAP server,
-		setting to 1 means enable integrated XCAP server.
-	    </para>
-	    <para>
-		<emphasis>
-		    Default value is 0.
-		</emphasis>
-	    </para>
-	    <example>
-		<title>Set <varname>integrated_xcap_server</varname> parameter</title>
-		<programlisting format="linespecific">
-...
-modparam("presence", "integrated_xcap_server", 1)
-...
 </programlisting>
 </programlisting>
 	    </example>
 	    </example>
 	</section>
 	</section>
@@ -789,7 +723,7 @@ if (method=="MESSAGE") {
 
 
 	<section>
 	<section>
 		<title>
 		<title>
-		<function moreinfo="none">pres_refresh_watchers(uri, event, type)</function>
+		<function moreinfo="none">pres_refresh_watchers(uri, event, type[, file_uri, filename])</function>
 		</title>
 		</title>
 		<para>
 		<para>
 			The function can be used in configuration to triger notifies to watchers
 			The function can be used in configuration to triger notifies to watchers
@@ -806,23 +740,34 @@ if (method=="MESSAGE") {
 				<para>event - the event package.</para>
 				<para>event - the event package.</para>
 			</listitem>
 			</listitem>
 			<listitem>
 			<listitem>
-				<para>type - it distinguishes between the two different types of events
+				<para>type - it distinguishes between the three different types of events
 						that can trigger the refresh, depending on its value:
 						that can trigger the refresh, depending on its value:
 						<itemizedlist>
 						<itemizedlist>
 							<listitem>
 							<listitem>
 								<para>0 - a change in watchers authentication.</para>
 								<para>0 - a change in watchers authentication.</para>
 							</listitem>
 							</listitem>
 							<listitem>
 							<listitem>
-								<para>
-									1 - a statical update in published state (either through direct
-									update in db table or by modifying the pidf manipulation document,
-									if pidf_manipulation parameter is set).
+								<para>1 - a statical update in published state through direct
+								update in db table.
+								</para>
+							</listitem>
+							<listitem>
+								<para>2 - a statical update in published state by modifying
+								the pidf manipulation document.
 								</para>
 								</para>
 							</listitem>
 							</listitem>
 						</itemizedlist>
 						</itemizedlist>
 				</para>
 				</para>
 			</listitem>
 			</listitem>
-        </itemizedlist>
+			<listitem>
+				<para>file_uri - the uri of the pidf-manipulation file on
+				the XCAP server (only used for type 2).</para>
+			</listitem>
+			<listitem>
+				<para>filename - the name of the pidf-manipulation file on
+				the XCAP server (only used for type 2).</para>
+			</listitem>
+        	</itemizedlist>
 		<para>
 		<para>
 		This function can be used from ANY_ROUTE.
 		This function can be used from ANY_ROUTE.
 		</para>
 		</para>
@@ -864,40 +809,6 @@ pres_refresh_watchers("sip:[email protected]", "presence", 1);
 ...
 ...
 pres_update_watchers("sip:[email protected]", "presence");
 pres_update_watchers("sip:[email protected]", "presence");
 ...
 ...
-</programlisting>
-		</example>
-	</section>
-	<section>
-		<title>
-		<function moreinfo="none">pres_update_presentity(uri, file_uri, filename)</function>
-		</title>
-		<para>
-			The function can be used in configuration to triger updates to presentities
-			based on the content of pidf-manipulation documents stored in the xcap db
-			table.  This enables "hard-state" presence to be set.
-		</para>
-		<para>Parameters:</para>
-		<itemizedlist>
-			<listitem>
-				<para>uri - the uri of the presentity</para>
-			</listitem>
-			<listitem>
-				<para>file_uri - the uri of the document on the XCAP server</para>
-			</listitem>
-			<listitem>
-				<para>filename - the filename part of the uri of the document
-					this is used as the presentity ETag</para>
-			</listitem>
-		</itemizedlist>
-		<para>
-		This function can be used from ANY_ROUTE.
-		</para>
-		<example>
-		<title><function>pres_update_presentity</function> usage</title>
-		<programlisting format="linespecific">
-...
-pres_update_presentity("$xcapuri(u=>xuid)", "$xcapuri(u=>uri_adoc)", "$xcapuri(u=>file)");
-...
 </programlisting>
 </programlisting>
 		</example>
 		</example>
 	</section>
 	</section>
@@ -919,31 +830,41 @@ pres_update_presentity("$xcapuri(u=>xuid)", "$xcapuri(u=>uri_adoc)", "$xcapuri(u
 		<para>Parameters:</para>
 		<para>Parameters:</para>
 		<itemizedlist>
 		<itemizedlist>
 			<listitem>
 			<listitem>
-				<para>presentity_uri : the uri of the user who made the change
+				<para>uri - the uri of the user who made the change
 				and whose watchers should be informed</para>
 				and whose watchers should be informed</para>
 			</listitem>
 			</listitem>
 			<listitem>
 			<listitem>
-				<para>event : the event package</para>
+				<para>event - the event package.</para>
 			</listitem>
 			</listitem>
 			<listitem>
 			<listitem>
-				<para>refresh type : it distinguishes between the two different types of events
-						that can trigger a refresh: 
+				<para>type - it distinguishes between the three different types of events
+						that can trigger the refresh, depending on its value:
 						<itemizedlist>
 						<itemizedlist>
 							<listitem>
 							<listitem>
-								<para> a change in watchers authentication: refresh type= 0 ; </para>
+								<para>0 - a change in watchers authentication.</para>
+							</listitem>
+							<listitem>
+								<para>1 - a statical update in published state through direct
+								update in db table.
+								</para>
 							</listitem>
 							</listitem>
 							<listitem>
 							<listitem>
-								<para>
-									a statical update in published state (either through direct 
-									update in db table or by modifying the pidf manipulation document,
-									if pidf_manipulation parameter is set): refresh type!= 0.
+								<para>2 - a statical update in published state by modifying
+								the pidf manipulation document.
 								</para>
 								</para>
 							</listitem>
 							</listitem>
 						</itemizedlist>
 						</itemizedlist>
 				</para>
 				</para>
 			</listitem>
 			</listitem>
-        </itemizedlist>
-
+			<listitem>
+				<para>file_uri - the uri of the pidf-manipulation file on
+				the XCAP server (only used for type 2).</para>
+			</listitem>
+			<listitem>
+				<para>filename - the name of the pidf-manipulation file on
+				the XCAP server (only used for type 2).</para>
+			</listitem>
+        	</itemizedlist>
         <para>
         <para>
 		MI FIFO Command Format:
 		MI FIFO Command Format:
 		</para>
 		</para>

+ 2 - 1
modules_k/presence/event_list.c

@@ -239,6 +239,7 @@ int add_event(pres_ev_t* event)
 	ev->apply_auth_nbody= event->apply_auth_nbody;
 	ev->apply_auth_nbody= event->apply_auth_nbody;
 	ev->get_auth_status= event->get_auth_status;
 	ev->get_auth_status= event->get_auth_status;
 	ev->get_rules_doc= event->get_rules_doc;
 	ev->get_rules_doc= event->get_rules_doc;
+	ev->get_pidf_doc= event->get_pidf_doc;
 	ev->evs_publ_handl= event->evs_publ_handl;
 	ev->evs_publ_handl= event->evs_publ_handl;
 	ev->evs_subs_handl= event->evs_subs_handl;
 	ev->evs_subs_handl= event->evs_subs_handl;
 	ev->etag_not_new= event->etag_not_new;
 	ev->etag_not_new= event->etag_not_new;
@@ -356,7 +357,7 @@ pres_ev_t* search_event(event_t* event)
 				strncasecmp(pres_ev->evp->name.s,event->name.s,
 				strncasecmp(pres_ev->evp->name.s,event->name.s,
 					pres_ev->evp->name.len)== 0))
 					pres_ev->evp->name.len)== 0))
 		{
 		{
-			if((event->params.list== NULL && pres_ev->evp->params.list== NULL) || event->type==EVENT_UA_PROFILE)
+			if(event->params.list== NULL && pres_ev->evp->params.list== NULL)
 			{
 			{
 				return pres_ev;
 				return pres_ev;
 			}
 			}

+ 2 - 0
modules_k/presence/event_list.h

@@ -67,6 +67,7 @@ typedef str* (aux_body_processing_t)(struct subscription *subs, str* body);
  *	*/
  *	*/
 typedef int (is_allowed_t)(struct subscription* subs);
 typedef int (is_allowed_t)(struct subscription* subs);
 typedef int (get_rules_doc_t)(str* user, str* domain, str** rules_doc);
 typedef int (get_rules_doc_t)(str* user, str* domain, str** rules_doc);
+typedef int (get_pidf_doc_t)(str* user, str* domain, str* file_uri, str** rules_doc);
 /* return code rules for is_allowed_t
 /* return code rules for is_allowed_t
  *	< 0  if error occured
  *	< 0  if error occured
  *	=0	 if no change in status(if no xcap document exists)
  *	=0	 if no change in status(if no xcap document exists)
@@ -96,6 +97,7 @@ struct pres_ev
 	 */
 	 */
 	int req_auth;
 	int req_auth;
 	get_rules_doc_t* get_rules_doc;
 	get_rules_doc_t* get_rules_doc;
+	get_pidf_doc_t* get_pidf_doc;
 	apply_auth_t*  apply_auth_nbody;
 	apply_auth_t*  apply_auth_nbody;
 	is_allowed_t*  get_auth_status;
 	is_allowed_t*  get_auth_status;
 	
 	

+ 31 - 26
modules_k/presence/notify.c

@@ -1386,40 +1386,45 @@ int query_db_notify(str* pres_uri, pres_ev_t* event, subs_t* watcher_subs )
 		ret_code= 1;
 		ret_code= 1;
 		goto done;
 		goto done;
 	}
 	}
-	
-	if(event->type & PUBL_TYPE)
-	{
-		notify_body = get_p_notify_body(*pres_uri, event, NULL, NULL);
-		if(notify_body == NULL)
-		{
-			LM_DBG("Could not get the notify_body\n");
-			/* goto error; */
-		}
-	}	
 
 
 	s= subs_array;
 	s= subs_array;
-	
-	while(s)
-	{
-
-		if (event->aux_body_processing) {
-			aux_body = event->aux_body_processing(s, notify_body);
-		}
 
 
-		if(notify(s, watcher_subs, aux_body?aux_body:notify_body, 0)< 0 )
+	if (pres_notifier_processes > 0)
+	{
+		while(s)
 		{
 		{
-			LM_ERR("Could not send notify for [event]=%.*s\n",
-					event->name.len, event->name.s);
-			goto done;
+			set_updated(s);
+			s= s->next;
 		}
 		}
+	}
+	else
+	{
+		if(event->type & PUBL_TYPE)
+			notify_body = get_p_notify_body(*pres_uri, event, NULL, NULL);
 
 
-		if(aux_body!=NULL) {
-			if(aux_body->s)	{
-				event->aux_free_body(aux_body->s);
+		while(s)
+		{
+	
+			if (event->aux_body_processing) {
+				aux_body = event->aux_body_processing(s, notify_body);
 			}
 			}
-			pkg_free(aux_body);
+	
+			if(notify(s, watcher_subs, aux_body?aux_body:notify_body, 0)< 0 )
+			{
+				LM_ERR("Could not send notify for [event]=%.*s\n",
+						event->name.len, event->name.s);
+				goto done;
+			}
+	
+			if(aux_body!=NULL) {
+				if(aux_body->s)	{
+					event->aux_free_body(aux_body->s);
+				}
+				pkg_free(aux_body);
+			}
+			s= s->next;
 		}
 		}
-		s= s->next;
+
 	}
 	}
 
 
 	ret_code= 1;
 	ret_code= 1;

+ 110 - 131
modules_k/presence/presence.c

@@ -79,7 +79,6 @@ MODULE_VERSION
 #define S_TABLE_VERSION  3
 #define S_TABLE_VERSION  3
 #define P_TABLE_VERSION  3
 #define P_TABLE_VERSION  3
 #define ACTWATCH_TABLE_VERSION 11
 #define ACTWATCH_TABLE_VERSION 11
-#define XCAP_TABLE_VERSION 4
 
 
 char *log_buf = NULL;
 char *log_buf = NULL;
 static int clean_period=100;
 static int clean_period=100;
@@ -88,12 +87,9 @@ static int db_update_period=100;
 /* database connection */
 /* database connection */
 db1_con_t *pa_db = NULL;
 db1_con_t *pa_db = NULL;
 db_func_t pa_dbf;
 db_func_t pa_dbf;
-db1_con_t *pres_xcap_db = NULL;
-db_func_t pres_xcap_dbf;
 str presentity_table= str_init("presentity");
 str presentity_table= str_init("presentity");
 str active_watchers_table = str_init("active_watchers");
 str active_watchers_table = str_init("active_watchers");
 str watchers_table= str_init("watchers");
 str watchers_table= str_init("watchers");
-str pres_xcap_table= str_init("xcap");
 
 
 int pres_fetch_rows = 500;
 int pres_fetch_rows = 500;
 int library_mode= 0;
 int library_mode= 0;
@@ -125,18 +121,18 @@ static int mi_child_init(void);
 static int w_pres_auth_status(struct sip_msg* _msg, char* _sp1, char* _sp2);
 static int w_pres_auth_status(struct sip_msg* _msg, char* _sp1, char* _sp2);
 static int w_pres_refresh_watchers(struct sip_msg *msg, char *puri,
 static int w_pres_refresh_watchers(struct sip_msg *msg, char *puri,
 		char *pevent, char *ptype);
 		char *pevent, char *ptype);
+static int w_pres_refresh_watchers5(struct sip_msg *msg, char *puri,
+		char *pevent, char *ptype, char *furi, char *fname);
 static int w_pres_update_watchers(struct sip_msg *msg, char *puri,
 static int w_pres_update_watchers(struct sip_msg *msg, char *puri,
 		char *pevent);
 		char *pevent);
 static int fixup_refresh_watchers(void** param, int param_no);
 static int fixup_refresh_watchers(void** param, int param_no);
 static int fixup_update_watchers(void** param, int param_no);
 static int fixup_update_watchers(void** param, int param_no);
-static int fixup_update_presentity(void** param, int param_no);
 
 
 int counter =0;
 int counter =0;
 int pid = 0;
 int pid = 0;
 char prefix='a';
 char prefix='a';
 int startup_time=0;
 int startup_time=0;
 str db_url = {0, 0};
 str db_url = {0, 0};
-str pres_xcap_db_url = {0, 0};
 int expires_offset = 0;
 int expires_offset = 0;
 int max_expires= 3600;
 int max_expires= 3600;
 int shtable_size= 9;
 int shtable_size= 9;
@@ -149,7 +145,6 @@ int publ_cache_enabled = 1;
 int pres_waitn_time = 5;
 int pres_waitn_time = 5;
 int pres_notifier_poll_rate = 10;
 int pres_notifier_poll_rate = 10;
 int pres_notifier_processes = 1;
 int pres_notifier_processes = 1;
-int pres_integrated_xcap_server = 0;
 
 
 int *pres_notifier_id = NULL;
 int *pres_notifier_id = NULL;
 
 
@@ -170,10 +165,10 @@ static cmd_export_t cmds[]=
 		fixup_pvar_pvar, fixup_free_pvar_pvar, REQUEST_ROUTE},
 		fixup_pvar_pvar, fixup_free_pvar_pvar, REQUEST_ROUTE},
 	{"pres_refresh_watchers", (cmd_function)w_pres_refresh_watchers, 3,
 	{"pres_refresh_watchers", (cmd_function)w_pres_refresh_watchers, 3,
 		fixup_refresh_watchers, 0, ANY_ROUTE},
 		fixup_refresh_watchers, 0, ANY_ROUTE},
+	{"pres_refresh_watchers", (cmd_function)w_pres_refresh_watchers5,5,
+		fixup_refresh_watchers, 0, ANY_ROUTE},
 	{"pres_update_watchers",  (cmd_function)w_pres_update_watchers,  2,
 	{"pres_update_watchers",  (cmd_function)w_pres_update_watchers,  2,
 		fixup_update_watchers, 0, ANY_ROUTE},
 		fixup_update_watchers, 0, ANY_ROUTE},
-	{"pres_update_presentity", (cmd_function)pres_update_presentity, 3,
-		fixup_update_presentity, 0, ANY_ROUTE},
 	{"bind_presence",         (cmd_function)bind_presence,           1,
 	{"bind_presence",         (cmd_function)bind_presence,           1,
 		0, 0, 0},
 		0, 0, 0},
 	{ 0, 0, 0, 0, 0, 0}
 	{ 0, 0, 0, 0, 0, 0}
@@ -181,11 +176,9 @@ static cmd_export_t cmds[]=
 
 
 static param_export_t params[]={
 static param_export_t params[]={
 	{ "db_url",                 STR_PARAM, &db_url.s},
 	{ "db_url",                 STR_PARAM, &db_url.s},
-	{ "xcap_db_url",            STR_PARAM, &pres_xcap_db_url.s},
 	{ "presentity_table",       STR_PARAM, &presentity_table.s},
 	{ "presentity_table",       STR_PARAM, &presentity_table.s},
 	{ "active_watchers_table",  STR_PARAM, &active_watchers_table.s},
 	{ "active_watchers_table",  STR_PARAM, &active_watchers_table.s},
 	{ "watchers_table",         STR_PARAM, &watchers_table.s},
 	{ "watchers_table",         STR_PARAM, &watchers_table.s},
-	{ "xcap_table",             STR_PARAM, &pres_xcap_table.s},
 	{ "clean_period",           INT_PARAM, &clean_period },
 	{ "clean_period",           INT_PARAM, &clean_period },
 	{ "db_update_period",       INT_PARAM, &db_update_period },
 	{ "db_update_period",       INT_PARAM, &db_update_period },
 	{ "waitn_time",             INT_PARAM, &pres_waitn_time },
 	{ "waitn_time",             INT_PARAM, &pres_waitn_time },
@@ -203,7 +196,6 @@ static param_export_t params[]={
 	{ "timeout_rm_subs",        INT_PARAM, &timeout_rm_subs},
 	{ "timeout_rm_subs",        INT_PARAM, &timeout_rm_subs},
 	{ "send_fast_notify",       INT_PARAM, &send_fast_notify},
 	{ "send_fast_notify",       INT_PARAM, &send_fast_notify},
 	{ "fetch_rows",             INT_PARAM, &pres_fetch_rows},
 	{ "fetch_rows",             INT_PARAM, &pres_fetch_rows},
-	{ "integrated_xcap_server", INT_PARAM, &pres_integrated_xcap_server},
     {0,0,0}
     {0,0,0}
 };
 };
 
 
@@ -246,21 +238,8 @@ static int mod_init(void)
 	active_watchers_table.len = strlen(active_watchers_table.s);
 	active_watchers_table.len = strlen(active_watchers_table.s);
 	watchers_table.len = strlen(watchers_table.s);
 	watchers_table.len = strlen(watchers_table.s);
 
 
-	if(pres_integrated_xcap_server == 1)
-	{
-		pres_xcap_db_url.s = pres_xcap_db_url.s ? pres_xcap_db_url.s : db_url.s;
-		pres_xcap_db_url.len = strlen(pres_xcap_db_url.s);
-		pres_xcap_table.len = strlen(pres_xcap_table.s);
-	}
-
 	if(db_url.s== NULL)
 	if(db_url.s== NULL)
 		library_mode= 1;
 		library_mode= 1;
-	else if(pres_integrated_xcap_server == 1)
-	{
-		pres_xcap_db_url.s = pres_xcap_db_url.s ? pres_xcap_db_url.s : db_url.s;
-		pres_xcap_db_url.len = strlen(pres_xcap_db_url.s);
-		pres_xcap_table.len = strlen(pres_xcap_table.s);
-	}
 
 
 	EvList= init_evlist();
 	EvList= init_evlist();
 	if(!EvList){
 	if(!EvList){
@@ -316,6 +295,7 @@ static int mod_init(void)
 		LM_ERR("Database module not found\n");
 		LM_ERR("Database module not found\n");
 		return -1;
 		return -1;
 	}
 	}
+	
 
 
 	if (!DB_CAPABILITY(pa_dbf, DB_CAP_ALL))
 	if (!DB_CAPABILITY(pa_dbf, DB_CAP_ALL))
 	{
 	{
@@ -330,52 +310,20 @@ static int mod_init(void)
 		LM_ERR("Connection to database failed\n");
 		LM_ERR("Connection to database failed\n");
 		return -1;
 		return -1;
 	}
 	}
+
 	/*verify table versions */
 	/*verify table versions */
 	if((db_check_table_version(&pa_dbf, pa_db, &presentity_table, P_TABLE_VERSION) < 0) ||
 	if((db_check_table_version(&pa_dbf, pa_db, &presentity_table, P_TABLE_VERSION) < 0) ||
 		(db_check_table_version(&pa_dbf, pa_db, &watchers_table, S_TABLE_VERSION) < 0)) {
 		(db_check_table_version(&pa_dbf, pa_db, &watchers_table, S_TABLE_VERSION) < 0)) {
 			LM_ERR("error during table version check\n");
 			LM_ERR("error during table version check\n");
 			return -1;
 			return -1;
 	}
 	}
+
 	if(subs_dbmode != NO_DB &&
 	if(subs_dbmode != NO_DB &&
 		db_check_table_version(&pa_dbf, pa_db, &active_watchers_table, ACTWATCH_TABLE_VERSION) < 0) {
 		db_check_table_version(&pa_dbf, pa_db, &active_watchers_table, ACTWATCH_TABLE_VERSION) < 0) {
 		LM_ERR("wrong table version for %s\n", active_watchers_table.s);
 		LM_ERR("wrong table version for %s\n", active_watchers_table.s);
 		return -1;
 		return -1;
 	}
 	}
 
 
-	if (pres_integrated_xcap_server == 1)
-	{
-		if(pres_xcap_db_url.s== NULL)
-		{
-			LM_ERR("xcap database url not set!\n");
-			return -1;
-		}
-
-		if (db_bind_mod(&pres_xcap_db_url, &pres_xcap_dbf))
-		{
-			LM_ERR("Database module not found\n");
-			return -1;
-		}
-
-		if (!DB_CAPABILITY(pres_xcap_dbf, DB_CAP_ALL))
-		{
-			LM_ERR("Database module does not implement all functions"
-					" needed by presence module\n");
-			return -1;
-		}
-
-		pres_xcap_db = pres_xcap_dbf.init(&pres_xcap_db_url);
-		if (!pres_xcap_db)
-		{
-			LM_ERR("Connection to database failed\n");
-			return -1;
-		}
-
-		if(db_check_table_version(&pres_xcap_dbf, pres_xcap_db, &pres_xcap_table, XCAP_TABLE_VERSION) < 0) {
-				LM_ERR("error during table version check\n");
-				return -1;
-		}
-	}
-
 	if(subs_dbmode != DB_ONLY) {
 	if(subs_dbmode != DB_ONLY) {
 		if(shtable_size< 1)
 		if(shtable_size< 1)
 			shtable_size= 512;
 			shtable_size= 512;
@@ -448,12 +396,6 @@ static int mod_init(void)
 	pa_dbf.close(pa_db);
 	pa_dbf.close(pa_db);
 	pa_db = NULL;
 	pa_db = NULL;
 
 
-	if (pres_integrated_xcap_server == 1)
-	{
-		pres_xcap_dbf.close(pres_xcap_db);
-		pres_xcap_db = NULL;
-	}
-
 	return 0;
 	return 0;
 }
 }
 
 
@@ -529,29 +471,6 @@ static int child_init(int rank)
 		return -1;
 		return -1;
 	}
 	}
 
 
-	if (pres_integrated_xcap_server == 1)
-	{
-		if (pres_xcap_dbf.init==0)
-		{
-			LM_CRIT("child_init: database not bound\n");
-			return -1;
-		}
-		if (pres_xcap_db)
-			return 0;
-		pres_xcap_db = pres_xcap_dbf.init(&pres_xcap_db_url);
-		if (!pres_xcap_db)
-		{
-			LM_ERR("child %d: unsuccessful connecting to database\n", rank);
-			return -1;
-		}
-	
-		if (pres_xcap_dbf.use_table(pres_xcap_db, &pres_xcap_table) < 0)
-		{
-			LM_ERR( "child %d:unsuccessful use_table xcap_table\n", rank);
-			return -1;
-		}
-	}
-
 	LM_DBG("child %d: Database connection opened successfully\n", rank);
 	LM_DBG("child %d: Database connection opened successfully\n", rank);
 	
 	
 	return 0;
 	return 0;
@@ -597,29 +516,6 @@ static int mi_child_init(void)
 		return -1;
 		return -1;
 	}
 	}
 
 
-	if (pres_integrated_xcap_server == 1)
-	{
-		if (pres_xcap_dbf.init==0)
-		{
-			LM_CRIT("database not bound\n");
-			return -1;
-		}
-		if (pres_xcap_db)
-			return 0;
-		pres_xcap_db = pres_xcap_dbf.init(&db_url);
-		if (!pres_xcap_db)
-		{
-			LM_ERR("connecting database\n");
-			return -1;
-		}
-	
-		if (pres_xcap_dbf.use_table(pres_xcap_db, &pres_xcap_table) < 0)
-		{
-			LM_ERR( "unsuccessful use_table xcap_table\n");
-			return -1;
-		}
-	}
-
 	LM_DBG("Database connection opened successfully\n");
 	LM_DBG("Database connection opened successfully\n");
 	return 0;
 	return 0;
 }
 }
@@ -648,9 +544,6 @@ static void destroy(void)
 	if(pa_db && pa_dbf.close)
 	if(pa_db && pa_dbf.close)
 		pa_dbf.close(pa_db);
 		pa_dbf.close(pa_db);
 
 
-	if(pres_xcap_db && pres_xcap_dbf.close)
-		pres_xcap_dbf.close(pres_xcap_db);
-
 	if (pres_notifier_id != NULL)
 	if (pres_notifier_id != NULL)
 		shm_free(pres_notifier_id);
 		shm_free(pres_notifier_id);
 
 
@@ -702,7 +595,7 @@ static int fixup_subscribe(void** param, int param_no)
 	return 0;
 	return 0;
 }
 }
 
 
-int pres_refresh_watchers(str *pres, str *event, int type)
+int pres_refresh_watchers(str *pres, str *event, int type, str *file_uri, str *filename)
 {
 {
 	pres_ev_t *ev;
 	pres_ev_t *ev;
 	struct sip_uri uri;
 	struct sip_uri uri;
@@ -750,6 +643,14 @@ int pres_refresh_watchers(str *pres, str *event, int type)
 		rules_doc = NULL;
 		rules_doc = NULL;
 
 
 	} else {
 	} else {
+		if (type == 2) {
+			if (update_hard_presentity(pres, ev, file_uri, filename) < 0)
+			{
+				LM_ERR("updating hard presentity\n");
+				goto error;
+			}
+		}
+
 		/* if a request to refresh notified info */
 		/* if a request to refresh notified info */
 		if(query_db_notify(pres, ev, NULL)< 0)
 		if(query_db_notify(pres, ev, NULL)< 0)
 		{
 		{
@@ -781,7 +682,7 @@ error:
 static struct mi_root* mi_refreshWatchers(struct mi_root* cmd, void* param)
 static struct mi_root* mi_refreshWatchers(struct mi_root* cmd, void* param)
 {
 {
 	struct mi_node* node= NULL;
 	struct mi_node* node= NULL;
-	str pres_uri, event;
+	str pres_uri, event, file_uri = {0, 0}, filename = {0, 0};
 	unsigned int refresh_type;
 	unsigned int refresh_type;
 
 
 	LM_DBG("start\n");
 	LM_DBG("start\n");
@@ -823,13 +724,38 @@ static struct mi_root* mi_refreshWatchers(struct mi_root* cmd, void* param)
 		goto error;
 		goto error;
 	}
 	}
 
 
+	if (refresh_type == 2)
+	{
+		node = node->next;
+		if(node == NULL)
+			return 0;
+		file_uri = node->value;
+		if(file_uri.s== NULL || file_uri.len== 0)
+		{
+			LM_ERR( "empty file uri parameter\n");
+			return init_mi_tree(400, "Empty file uri parameter", 24);
+		}
+
+		node = node->next;
+		if(node == NULL)
+			return 0;
+		filename = node->value;
+		if(filename.s== NULL || filename.len== 0)
+		{
+			LM_ERR( "empty file name parameter\n");
+			return init_mi_tree(400, "Empty file name parameter", 25);
+		}
+	}
+
 	if(node->next!= NULL)
 	if(node->next!= NULL)
 	{
 	{
 		LM_ERR( "Too many parameters\n");
 		LM_ERR( "Too many parameters\n");
 		return init_mi_tree(400, "Too many parameters", 19);
 		return init_mi_tree(400, "Too many parameters", 19);
 	}
 	}
 
 
-	if(pres_refresh_watchers(&pres_uri, &event, refresh_type)<0)
+	if(pres_refresh_watchers(&pres_uri, &event, refresh_type,
+					file_uri.len ? &file_uri: NULL,
+					filename.len ? &filename : NULL)<0)
 		return 0;
 		return 0;
 	
 	
 	return init_mi_tree(200, "OK", 2);
 	return init_mi_tree(200, "OK", 2);
@@ -1352,6 +1278,12 @@ static int update_pw_dialogs_dbonlymode(subs_t* subs, subs_t** subs_array)
 
 
 	LM_DBG("found %d matching dialogs\n", nr_rows);
 	LM_DBG("found %d matching dialogs\n", nr_rows);
 
 
+	if (nr_rows <= 0)
+	{
+		pa_dbf.free_result(pa_db, result);
+		return 0;
+	}
+
 	/* get the results and fill in return data structure */
 	/* get the results and fill in return data structure */
 	for (loop=0; loop <nr_rows; loop++)
 	for (loop=0; loop <nr_rows; loop++)
 	{
 	{
@@ -1689,7 +1621,61 @@ static int w_pres_refresh_watchers(struct sip_msg *msg, char *puri,
 		return -1;
 		return -1;
 	}
 	}
 
 
-	if(pres_refresh_watchers(&pres_uri, &event, refresh_type)<0)
+	if (refresh_type == 2)
+	{
+		LM_ERR("Wrong number of parameters for type 2\n");
+		return -1;
+	}
+
+	if(pres_refresh_watchers(&pres_uri, &event, refresh_type, NULL, NULL)<0)
+		return -1;
+
+	return 1;
+}
+
+static int w_pres_refresh_watchers5(struct sip_msg *msg, char *puri,
+		char *pevent, char *ptype, char *furi, char *fname)
+{
+	str pres_uri, event, file_uri, filename;
+	int refresh_type;
+
+	if(fixup_get_svalue(msg, (gparam_p)puri, &pres_uri)!=0)
+	{
+		LM_ERR("invalid uri parameter");
+		return -1;
+	}
+
+	if(fixup_get_svalue(msg, (gparam_p)pevent, &event)!=0)
+	{
+		LM_ERR("invalid event parameter");
+		return -1;
+	}
+
+	if(fixup_get_ivalue(msg, (gparam_p)ptype, &refresh_type)!=0)
+	{
+		LM_ERR("no type value\n");
+		return -1;
+	}
+
+	if(fixup_get_svalue(msg, (gparam_p)furi, &file_uri)!=0)
+	{
+		LM_ERR("invalid file uri parameter");
+		return -1;
+	}
+
+	if(fixup_get_svalue(msg, (gparam_p)fname, &filename)!=0)
+	{
+		LM_ERR("invalid filename parameter");
+		return -1;
+	}
+
+	if (refresh_type != 2)
+	{
+		LM_ERR("Wrong number of parameters for type %d\n", refresh_type);
+		return -1;
+	}
+
+	if(pres_refresh_watchers(&pres_uri, &event, refresh_type, &file_uri, &filename)<0)
 		return -1;
 		return -1;
 
 
 	return 1;
 	return 1;
@@ -1700,14 +1686,18 @@ static int w_pres_refresh_watchers(struct sip_msg *msg, char *puri,
  */
  */
 static int fixup_refresh_watchers(void** param, int param_no)
 static int fixup_refresh_watchers(void** param, int param_no)
 {
 {
-	if(param_no==1)
-	{
+	if(param_no==1) {
 		return fixup_spve_null(param, 1);
 		return fixup_spve_null(param, 1);
 	} else if(param_no==2) {
 	} else if(param_no==2) {
 		return fixup_spve_null(param, 1);
 		return fixup_spve_null(param, 1);
 	} else if(param_no==3) {
 	} else if(param_no==3) {
 		return fixup_igp_null(param, 1);
 		return fixup_igp_null(param, 1);
+	} else if(param_no==4) {
+		return fixup_spve_null(param, 1);
+	} else if(param_no==5) {
+		return fixup_spve_null(param, 1);
 	}
 	}
+	
 	return 0;
 	return 0;
 }
 }
 
 
@@ -1791,14 +1781,3 @@ static int fixup_update_watchers(void** param, int param_no)
 	}
 	}
 	return 0;
 	return 0;
 }
 }
-
-/**
- * fixup for pres_update_presentity
- */
-static int fixup_update_presentity(void** param, int param_no)
-{
-	if(param_no==1 || param_no==2 || param_no==3)
-		return fixup_spve_null(param, 1);
-
-	return 0;
-}

+ 0 - 5
modules_k/presence/presence.h

@@ -63,8 +63,6 @@ extern sl_api_t slb;
 /* DB module bind */
 /* DB module bind */
 extern db_func_t pa_dbf;
 extern db_func_t pa_dbf;
 extern db1_con_t* pa_db;
 extern db1_con_t* pa_db;
-extern db_func_t pres_xcap_dbf;
-extern db1_con_t* pres_xcap_db;
 
 
 /* PRESENCE database */
 /* PRESENCE database */
 extern str db_url;
 extern str db_url;
@@ -96,9 +94,6 @@ extern int pres_notifier_processes;
 extern int phtable_size;
 extern int phtable_size;
 extern phtable_t* pres_htable;
 extern phtable_t* pres_htable;
 
 
-extern int pres_integrated_xcap_server;
-extern str pres_xcap_table;
-
 int update_watchers_status(str pres_uri, pres_ev_t* ev, str* rules_doc);
 int update_watchers_status(str pres_uri, pres_ev_t* ev, str* rules_doc);
 int pres_auth_status(struct sip_msg* msg, str watcher_uri, str presentity_uri);
 int pres_auth_status(struct sip_msg* msg, str watcher_uri, str presentity_uri);
 
 

+ 1 - 1
modules_k/presence/presentity.c

@@ -297,7 +297,7 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body,
 	{
 	{
 		/* get rules_document */
 		/* get rules_document */
 		if(presentity->event->get_rules_doc(&presentity->user,
 		if(presentity->event->get_rules_doc(&presentity->user,
-					&presentity->domain, &rules_doc))
+					&presentity->domain, &rules_doc) < 0)
 		{
 		{
 			LM_ERR("getting rules doc\n");
 			LM_ERR("getting rules doc\n");
 			goto error;
 			goto error;

+ 24 - 129
modules_k/presence/publish.c

@@ -33,7 +33,6 @@
 
 
 #include "../../ut.h"
 #include "../../ut.h"
 #include "../../str.h"
 #include "../../str.h"
-#include "../../mod_fix.h"
 #include "../../parser/parse_to.h"
 #include "../../parser/parse_to.h"
 #include "../../parser/parse_uri.h" 
 #include "../../parser/parse_uri.h" 
 #include "../../parser/parse_expires.h" 
 #include "../../parser/parse_expires.h" 
@@ -48,7 +47,6 @@
 #include "utils_func.h"
 #include "utils_func.h"
 #include "publish.h"
 #include "publish.h"
 #include "presentity.h"
 #include "presentity.h"
-#include "../xcap_client/xcap_callbacks.h"
 
 
 extern gen_lock_set_t* set;
 extern gen_lock_set_t* set;
 
 
@@ -57,10 +55,6 @@ static str pu_400b_rpl = str_init("Invalid request");
 static str pu_500_rpl  = str_init("Server Internal Error");
 static str pu_500_rpl  = str_init("Server Internal Error");
 static str pu_489_rpl  = str_init("Bad Event");
 static str pu_489_rpl  = str_init("Bad Event");
 
 
-static str str_doc_uri_col = str_init("doc_uri");
-static str str_doc_type_col = str_init("doc_type");
-static str str_doc_col = str_init("doc");
-
 struct p_modif
 struct p_modif
 {
 {
 	presentity_t* p;
 	presentity_t* p;
@@ -514,152 +508,48 @@ error:
 
 
 }
 }
 
 
-static int fetch_presentity(str furi, str *presentity)
+int update_hard_presentity(str *pres_uri, pres_ev_t *event, str *file_uri, str *filename)
 {
 {
-	db_key_t query_cols[2], result_cols[1];
-	db_val_t query_vals[2], *row_vals;
-	db1_res_t *result;
-	db_row_t *row;
-	int n_query_cols = 0, n_result_cols = 0;;
-	char *tmp;
-
-	query_cols[n_query_cols] = &str_doc_uri_col;
-	query_vals[n_query_cols].type = DB1_STR;
-	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.str_val = furi;
-	n_query_cols++;
-
-	query_cols[n_query_cols] = &str_doc_type_col;
-	query_vals[n_query_cols].type = DB1_INT;
-	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.int_val = PIDF_MANIPULATION;
-	n_query_cols++;
-
-	result_cols[n_result_cols++] = &str_doc_col;
-
-	if (pres_xcap_dbf.use_table(pres_xcap_db, &pres_xcap_table) < 0)
-	{
-		LM_ERR("calling use_table()\n");
-		return -1;
-	}
-
-	if (pres_xcap_dbf.query(pres_xcap_db, query_cols, 0, query_vals, result_cols,
-				n_query_cols, n_result_cols, 0, &result) < 0)
-	{
-		LM_ERR("calling query()\n");
-		return -1;
-	}
-
-	if (result == NULL)
-	{
-		LM_ERR("bad result\n");
-		return -1;
-	}
-
-	if (result->n <=0)
-	{
-		pres_xcap_dbf.free_result(pres_xcap_db, result);
-		return 0;
-	}
-
-	if (result->n > 1)
-	{
-		pres_xcap_dbf.free_result(pres_xcap_db, result);
-		return -1;
-	}
-
-	row = &result->rows[0];
-	row_vals = ROW_VALUES(row);
-
-	tmp = (char *)row_vals[0].val.string_val;
-	if (tmp == NULL)
-	{
-		LM_ERR("xcap document is empty\n");
-		pres_xcap_dbf.free_result(pres_xcap_db, result);
-		return -1;
-	}
-	presentity->len = strlen(tmp);
-
-	presentity->s = pkg_malloc(presentity->len * sizeof(char));
-	if (presentity->s == NULL)
-	{
-		LM_ERR("allocating memory\n");
-		pres_xcap_dbf.free_result(pres_xcap_db, result);
-		return -1;
-	}
-	memcpy(presentity->s, tmp, presentity->len);
-
-	pres_xcap_dbf.free_result(pres_xcap_db, result);
-	return 1;
-}
-
-int pres_update_presentity(struct sip_msg *msg, char *puri, char *furi, char *fname)
-{
-	int pres_result, ret = -1, new_t;
+	int ret = -1, new_t, pidf_result;
+	str *pidf_doc;
 	char *sphere = NULL;
 	char *sphere = NULL;
-	str pres_uri, file_uri, filename, presentity, ev;
-	pres_ev_t *event;
 	presentity_t *pres = NULL;
 	presentity_t *pres = NULL;
 	struct sip_uri parsed_uri;
 	struct sip_uri parsed_uri;
 
 
-	if(fixup_get_svalue(msg, (gparam_p)puri, &pres_uri)!=0)
-	{
-		LM_ERR("invalid uri parameter");
-		return -1;
-	}
-	if(fixup_get_svalue(msg, (gparam_p)furi, &file_uri)!=0)
-	{
-		LM_ERR("invalid file_uri parameter");
-		return -1;
-	}
-	if(fixup_get_svalue(msg, (gparam_p)fname, &filename)!=0)
-	{
-		LM_ERR("invalid filename parameter");
-		return -1;
-	}
-
 	LM_INFO("Hard-state file %.*s (uri %.*s) updated for %.*s\n",
 	LM_INFO("Hard-state file %.*s (uri %.*s) updated for %.*s\n",
-		filename.len, filename.s,
-		file_uri.len, file_uri.s,
-		pres_uri.len, pres_uri.s);
-
-	if (pres_integrated_xcap_server != 1)
-	{
-		LM_ERR("integrated XCAP server not configured\n");
-		return -1;
-	}
+		filename->len, filename->s,
+		file_uri->len, file_uri->s,
+		pres_uri->len, pres_uri->s);
 
 
-	ev.s = "presence";
-	ev.len = 8;
-	event = contains_event(&ev, NULL);
-	if (event == NULL)
+	if (!event->get_pidf_doc)
 	{
 	{
-		LM_ERR("presence event not supported\n");
+		LM_WARN("pidf-manipulation not supported for %.*s\n", event->name.len, event->name.s);
 		return -1;
 		return -1;
 	}
 	}
 
 
-	if (parse_uri(pres_uri.s, pres_uri.len, &parsed_uri) < 0)
+	if (parse_uri(pres_uri->s, pres_uri->len, &parsed_uri) < 0)
 	{
 	{
 		LM_ERR("bad presentity URI\n");
 		LM_ERR("bad presentity URI\n");
 		return -1;
 		return -1;
 	}
 	}
 
 
-	pres_result = fetch_presentity(file_uri, &presentity);
-	if (pres_result < 0)
+	pidf_result = event->get_pidf_doc(&parsed_uri.user, &parsed_uri.host, file_uri, &pidf_doc);
+
+	if (pidf_result < 0)
 	{
 	{
-		LM_ERR("retrieving presentity\n");
+		LM_ERR("retrieving pidf-manipulation document\n");
 		return -1;
 		return -1;
 	}
 	}
-	else if (pres_result > 0)
+	else if (pidf_result > 0)
 	{
 	{
 		/* Insert/replace presentity... */
 		/* Insert/replace presentity... */
 		LM_DBG("INSERT/REPLACE\n");
 		LM_DBG("INSERT/REPLACE\n");
 		xmlDocPtr doc;
 		xmlDocPtr doc;
 
 
 		if (sphere_enable)
 		if (sphere_enable)
-			sphere = extract_sphere(presentity);
+			sphere = extract_sphere(*pidf_doc);
 
 
-		doc = xmlParseMemory(presentity.s, presentity.len);
+		doc = xmlParseMemory(pidf_doc->s, pidf_doc->len);
 		if (doc == NULL)
 		if (doc == NULL)
 		{
 		{
 			LM_ERR("bad body format\n");
 			LM_ERR("bad body format\n");
@@ -681,14 +571,14 @@ int pres_update_presentity(struct sip_msg *msg, char *puri, char *furi, char *fn
 		new_t = 0;
 		new_t = 0;
 	}
 	}
 
 
-	pres = new_presentity(&parsed_uri.host, &parsed_uri.user, -1, event, &filename, NULL);
+	pres = new_presentity(&parsed_uri.host, &parsed_uri.user, -1, event, filename, NULL);
 	if (pres == NULL)
 	if (pres == NULL)
 	{
 	{
 		LM_ERR("creating presentity structure\n");
 		LM_ERR("creating presentity structure\n");
 		goto done;
 		goto done;
 	}
 	}
 
 
-	if (update_presentity(NULL, pres, &presentity, new_t, NULL, sphere) < 0)
+	if (update_presentity(NULL, pres, pidf_doc, new_t, NULL, sphere) < 0)
 	{
 	{
 		LM_ERR("updating presentity\n");
 		LM_ERR("updating presentity\n");
 		goto done;
 		goto done;
@@ -699,7 +589,12 @@ int pres_update_presentity(struct sip_msg *msg, char *puri, char *furi, char *fn
 done:
 done:
 	if (pres) pkg_free(pres);
 	if (pres) pkg_free(pres);
 	if (sphere) pkg_free(sphere);
 	if (sphere) pkg_free(sphere);
-	if (presentity.s) pkg_free(presentity.s);
+	if(pidf_doc)
+	{
+		if(pidf_doc->s)
+			pkg_free(pidf_doc->s);
+		pkg_free(pidf_doc);
+	}
 
 
 	return ret;
 	return ret;
 }
 }

+ 2 - 1
modules_k/presence/publish.h

@@ -48,5 +48,6 @@
 void msg_presentity_clean(unsigned int ticks,void *param);
 void msg_presentity_clean(unsigned int ticks,void *param);
 
 
 int handle_publish(struct sip_msg* msg, char* str1 ,char* str2);
 int handle_publish(struct sip_msg* msg, char* str1 ,char* str2);
-int pres_update_presentity(struct sip_msg *msg, char *puri, char *furi, char *fname);
+int update_hard_presentity(str *pres_uri, pres_ev_t *event, str *file_uri, str *filename);
+
 #endif
 #endif