summaryrefslogtreecommitdiff
path: root/include/asterisk/res_pjsip_body_generator_types.h
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-01-31 22:27:07 +0000
committerMark Michelson <mmichelson@digium.com>2014-01-31 22:27:07 +0000
commitf55abe9cf19911ae365bc16c63e3524b0b17e71f (patch)
tree2ce5c30e3f1cf65c54fb2e91fb7a230752125c16 /include/asterisk/res_pjsip_body_generator_types.h
parente29c5e0c5c952427047860ec44038a85d479c202 (diff)
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required to state what event they handled along with what body types they knew how to generate. While this serves well when implementing a base RFC, it has problems when trying to extend the body to support non-standard or proprietary body elements. The code also was NOTIFY-specific, meaning that when the time comes that we start writing code to send out PUBLISH requests with MWI or presence bodies, we would likely find ourselves duplicating code that had previously been written. This changeset introduces the concept of body generators and body supplements. A body generator is responsible for allocating a native structure for a given body type, providing the primary body content, converting the native structure to a string, and deallocating resources. A body supplement takes the primary body content (the native structure, not a string) generated by the body generator and adds nonstandard elements to the body. With these elements living in their own module, it becomes easy to extend our support for body types and to re-use resources when sending a PUBLISH request. Body generators and body supplements register themselves with the pubsub core, similar to how subscription and publish handlers had done. Now, subscription handlers do not need to know what type of body content they generate, but they still need to inform the pubsub core about what the default body type for a given event package is. The pubsub core keeps track of what body generators and body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core will check that there is a subscription handler for the event in the SUBSCRIBE, then it will check that there is a body generator that can provide the content specified in the Accept header(s). Because of the nature of body generators and supplements, it means res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no longer worry about body types, instead calling ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body. Review: https://reviewboard.asterisk.org/r/3150 ........ Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/res_pjsip_body_generator_types.h')
-rw-r--r--include/asterisk/res_pjsip_body_generator_types.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/include/asterisk/res_pjsip_body_generator_types.h b/include/asterisk/res_pjsip_body_generator_types.h
new file mode 100644
index 000000000..f27e8968a
--- /dev/null
+++ b/include/asterisk/res_pjsip_body_generator_types.h
@@ -0,0 +1,61 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2014, Digium, Inc.
+ *
+ * Mark Michelson <mmichelson@digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+#ifndef _RES_PJSIP_BODY_GENERATOR_TYPES_H
+#define _RES_PJSIP_BODY_GENERATOR_TYPES_H
+
+#include "asterisk/pbx.h"
+
+/*!
+ * \brief structure used for presence XML bodies
+ *
+ * This is used for the following body types:
+ * \li application/pidf+xml
+ * \li application/xpidf+xml
+ * \li application/cpim-pidf+xml
+ */
+struct ast_sip_exten_state_data {
+ /*! The extension of the current state change */
+ const char *exten;
+ /*! The extension state of the change */
+ enum ast_extension_states exten_state;
+ /*! The presence state of the change */
+ enum ast_presence_state presence_state;
+ /*! Current device state information */
+ struct ao2_container *device_state_info;
+ /*! Local dialog URI */
+ char local[PJSIP_MAX_URL_SIZE];
+ /*! Remote dialog URI */
+ char remote[PJSIP_MAX_URL_SIZE];
+ /*! Allocation pool */
+ pj_pool_t *pool;
+};
+
+/*!
+ * \brief Message counter used for message-summary XML bodies
+ *
+ * This is used for application/simple-message-summary bodies.
+ */
+struct ast_sip_message_accumulator {
+ /*! Number of old messages */
+ int old_msgs;
+ /*! Number of new messages */
+ int new_msgs;
+};
+
+#endif /* _RES_PJSIP_BODY_GENERATOR_TYPES_H */