[asterisk-commits] file: branch file/pimp_my_publish r391755 - in /team/file/pimp_my_publish: in...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jun 13 17:51:52 CDT 2013
Author: file
Date: Thu Jun 13 17:51:51 2013
New Revision: 391755
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391755
Log:
Add datastores to publications.
Modified:
team/file/pimp_my_publish/include/asterisk/res_sip_pubsub.h
team/file/pimp_my_publish/res/res_sip_pubsub.c
team/file/pimp_my_publish/res/res_sip_pubsub.exports.in
Modified: team/file/pimp_my_publish/include/asterisk/res_sip_pubsub.h
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_my_publish/include/asterisk/res_sip_pubsub.h?view=diff&rev=391755&r1=391754&r2=391755
==============================================================================
--- team/file/pimp_my_publish/include/asterisk/res_sip_pubsub.h (original)
+++ team/file/pimp_my_publish/include/asterisk/res_sip_pubsub.h Thu Jun 13 17:51:51 2013
@@ -136,6 +136,43 @@
* \brief Unregister a publish handler
*/
void ast_sip_unregister_publish_handler(struct ast_sip_publish_handler *handler);
+
+/*!
+ * \brief Add a datastore to a SIP publication
+ *
+ * Note that SIP uses reference counted datastores. The datastore passed into this function
+ * must have been allocated using ao2_alloc() or there will be serious problems.
+ *
+ * \param publication The publication to add the datastore to
+ * \param datastore The datastore to be added to the subscription
+ * \retval 0 Success
+ * \retval -1 Failure
+ */
+int ast_sip_publication_add_datastore(struct ast_sip_publication *publication, struct ast_datastore *datastore);
+
+/*!
+ * \brief Retrieve a publication datastore
+ *
+ * The datastore retrieved will have its reference count incremented. When the caller is done
+ * with the datastore, the reference counted needs to be decremented using ao2_ref().
+ *
+ * \param publication The publication from which to retrieve the datastore
+ * \param name The name of the datastore to retrieve
+ * \retval NULL Failed to find the specified datastore
+ * \retval non-NULL The specified datastore
+ */
+struct ast_datastore *ast_sip_publication_get_datastore(struct ast_sip_publication *publication, const char *name);
+
+/*!
+ * \brief Remove a publication datastore from the publication
+ *
+ * This operation may cause the datastore's free() callback to be called if the reference
+ * count reaches zero.
+ *
+ * \param publication The publication to remove the datastore from
+ * \param name The name of the datastore to remove
+ */
+void ast_sip_publication_remove_datastore(struct ast_sip_publication *publication, const char *name);
/*!
* \brief Opaque structure representing an RFC 3265 SIP subscription
Modified: team/file/pimp_my_publish/res/res_sip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_my_publish/res/res_sip_pubsub.c?view=diff&rev=391755&r1=391754&r2=391755
==============================================================================
--- team/file/pimp_my_publish/res/res_sip_pubsub.c (original)
+++ team/file/pimp_my_publish/res/res_sip_pubsub.c Thu Jun 13 17:51:51 2013
@@ -131,6 +131,8 @@
* \brief Structure representing a SIP publication
*/
struct ast_sip_publication {
+ /*! Publication datastores set up by handlers */
+ struct ao2_container *datastores;
/*! \brief Entity tag for the publication */
int entity_tag;
/*! \brief Handler for this publication */
@@ -409,6 +411,28 @@
void ast_sip_subscription_remove_datastore(struct ast_sip_subscription *subscription, const char *name)
{
ao2_callback(subscription->datastores, OBJ_KEY | OBJ_UNLINK | OBJ_NODATA, NULL, (void *) name);
+}
+
+int ast_sip_publication_add_datastore(struct ast_sip_publication *publication, struct ast_datastore *datastore)
+{
+ ast_assert(datastore != NULL);
+ ast_assert(datastore->info != NULL);
+ ast_assert(ast_strlen_zero(datastore->uid) == 0);
+
+ if (!ao2_link(publication->datastores, datastore)) {
+ return -1;
+ }
+ return 0;
+}
+
+struct ast_datastore *ast_sip_publication_get_datastore(struct ast_sip_publication *publication, const char *name)
+{
+ return ao2_find(publication->datastores, name, OBJ_KEY);
+}
+
+void ast_sip_publication_remove_datastore(struct ast_sip_publication *publication, const char *name)
+{
+ ao2_callback(publication->datastores, OBJ_KEY | OBJ_UNLINK | OBJ_NODATA, NULL, (void *) name);
}
AST_RWLIST_HEAD_STATIC(publish_handlers, ast_sip_publish_handler);
@@ -802,6 +826,9 @@
{
struct ast_sip_publication *publication = obj;
+ ast_debug(3, "Destroying SIP publication\n");
+
+ ao2_cleanup(publication->datastores);
ao2_cleanup(publication->endpoint);
}
@@ -813,6 +840,11 @@
ast_assert(endpoint != NULL);
if (!(publication = ao2_alloc(sizeof(*publication), publication_destroy_fn))) {
+ return NULL;
+ }
+
+ if (!(publication->datastores = ao2_container_alloc(DATASTORE_BUCKETS, datastore_hash, datastore_cmp))) {
+ ao2_ref(publication, -1);
return NULL;
}
Modified: team/file/pimp_my_publish/res/res_sip_pubsub.exports.in
URL: http://svnview.digium.com/svn/asterisk/team/file/pimp_my_publish/res/res_sip_pubsub.exports.in?view=diff&rev=391755&r1=391754&r2=391755
==============================================================================
--- team/file/pimp_my_publish/res/res_sip_pubsub.exports.in (original)
+++ team/file/pimp_my_publish/res/res_sip_pubsub.exports.in Thu Jun 13 17:51:51 2013
@@ -16,6 +16,9 @@
LINKER_SYMBOL_PREFIXast_sip_publication_create_response;
LINKER_SYMBOL_PREFIXast_sip_register_publish_handler;
LINKER_SYMBOL_PREFIXast_sip_unregister_publish_handler;
+ LINKER_SYMBOL_PREFIXast_sip_publication_add_datastore;
+ LINKER_SYMBOL_PREFIXast_sip_publication_get_datastore;
+ LINKER_SYMBOL_PREFIXast_sip_publication_remove_datastore;
local:
*;
};
More information about the asterisk-commits
mailing list