[asterisk-commits] twilson: branch twilson/calendaring r166943 - in /team/twilson/calendaring: i...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 30 16:00:08 CST 2008


Author: twilson
Date: Tue Dec 30 16:00:07 2008
New Revision: 166943

URL: http://svn.digium.com/view/asterisk?view=rev&rev=166943
Log:
Move the LIST_ENTRY insde ast_calendar_tech as per russell on reviewboard

Modified:
    team/twilson/calendaring/include/asterisk/calendar.h
    team/twilson/calendaring/main/calendar.c
    team/twilson/calendaring/res/res_caldav.c
    team/twilson/calendaring/res/res_exchangecal.c
    team/twilson/calendaring/res/res_icalendar.c

Modified: team/twilson/calendaring/include/asterisk/calendar.h
URL: http://svn.digium.com/view/asterisk/team/twilson/calendaring/include/asterisk/calendar.h?view=diff&rev=166943&r1=166942&r2=166943
==============================================================================
--- team/twilson/calendaring/include/asterisk/calendar.h (original)
+++ team/twilson/calendaring/include/asterisk/calendar.h Tue Dec 30 16:00:07 2008
@@ -78,6 +78,7 @@
 	void *(* load_calendar)(void *data);   /*!< Create private structure, add calendar events, etc. */
 	void *(* unref_calendar)(void *obj);   /*!< Function to be called to free the private structure */
 	int (* write_event)(struct ast_calendar_event *event);  /*!< Function for writing an event to the calendar */
+	AST_LIST_ENTRY(ast_calendar_tech) list;
 };
 
 enum ast_calendar_busy_state {
@@ -134,7 +135,7 @@
  * \retval 0 success
  * \retval -1 failure
  */
-int ast_calendar_register(const struct ast_calendar_tech *tech);
+int ast_calendar_register(struct ast_calendar_tech *tech);
 
 /*! \brief Unregister a new calendar technology
  *
@@ -143,7 +144,7 @@
  * \retval 0 success
  * \retva -1 failure
  */
-void ast_calendar_unregister(const struct ast_calendar_tech *tech);
+void ast_calendar_unregister(struct ast_calendar_tech *tech);
 
 /*! \brief Allocate an astobj2 ast_calendar_event object
  *

Modified: team/twilson/calendaring/main/calendar.c
URL: http://svn.digium.com/view/asterisk/team/twilson/calendaring/main/calendar.c?view=diff&rev=166943&r1=166942&r2=166943
==============================================================================
--- team/twilson/calendaring/main/calendar.c (original)
+++ team/twilson/calendaring/main/calendar.c Tue Dec 30 16:00:07 2008
@@ -65,17 +65,12 @@
 	.duplicate = eventlist_duplicate,
 };
 
-struct caltechlist {
-	const struct ast_calendar_tech *tech;
-	AST_LIST_ENTRY(caltechlist) list;
-};
-
 struct evententry {
 	struct ast_calendar_event *event;
 	AST_LIST_ENTRY(evententry) list;
 };
 
-AST_LIST_HEAD_STATIC(techs, caltechlist);
+AST_LIST_HEAD_STATIC(techs, ast_calendar_tech);
 AST_LIST_HEAD_NOLOCK(eventlist, evententry); /* define the type */
 
 static struct ast_calendar *unref_calendar(struct ast_calendar *cal)
@@ -196,30 +191,22 @@
 	return calendar_is_busy(cal) ? AST_DEVICE_INUSE : AST_DEVICE_NOT_INUSE;
 }
 
-int ast_calendar_register(const struct ast_calendar_tech *tech)
-{
-	struct caltechlist *caltech_list;
+int ast_calendar_register(struct ast_calendar_tech *tech)
+{
+	struct ast_calendar_tech *iter;
 
 	AST_LIST_LOCK(&techs);
-	AST_LIST_TRAVERSE(&techs, caltech_list, list) {
-		if(!strcasecmp(tech->type, caltech_list->tech->type)) {
+	AST_LIST_TRAVERSE(&techs, iter, list) {
+		if(!strcasecmp(tech->type, iter->type)) {
 			ast_log(LOG_WARNING, "Already have a handler for calendar type '%s'\n", tech->type);
 			AST_LIST_UNLOCK(&techs);
 			return -1;
 		}
 	}
+	AST_LIST_INSERT_HEAD(&techs, tech, list);
 	AST_LIST_UNLOCK(&techs);
 
-	if (!(caltech_list = ast_calloc(1, sizeof(*caltech_list)))) {
-		return -1;
-	}
-
-	caltech_list->tech = tech;
-	AST_LIST_LOCK(&techs);
-	AST_LIST_INSERT_HEAD(&techs, caltech_list, list);
-	AST_LIST_UNLOCK(&techs);
-
-	ast_verb(2, "Registered calendar type '%s' (%s)\n", caltech_list->tech->type, caltech_list->tech->description);
+	ast_verb(2, "Registered calendar type '%s' (%s)\n", tech->type, tech->description);
 
 	return 0;
 }
@@ -236,13 +223,13 @@
 	return 0;
 }
 
-void ast_calendar_unregister(const struct ast_calendar_tech *tech)
-{
-	struct caltechlist *caltech_list;
+void ast_calendar_unregister(struct ast_calendar_tech *tech)
+{
+	struct ast_calendar_tech *iter;
 
 	AST_LIST_LOCK(&techs);
-	AST_LIST_TRAVERSE_SAFE_BEGIN(&techs, caltech_list, list) {
-		if (caltech_list->tech != tech) {
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&techs, iter, list) {
+		if (iter != tech) {
 			continue;
 		}
 
@@ -259,13 +246,11 @@
 
 static const struct ast_calendar_tech *ast_get_calendar_tech(const char *name)
 {
-	struct caltechlist *caltech_list;
 	const struct ast_calendar_tech *ret = NULL;
 
 	AST_LIST_LOCK(&techs);
-	AST_LIST_TRAVERSE(&techs, caltech_list, list) {
-		if (!strcasecmp(name, caltech_list->tech->type)) {
-			ret = caltech_list->tech;
+	AST_LIST_TRAVERSE(&techs, ret, list) {
+		if (!strcasecmp(name, ret->type)) {
 			break;
 		}
 	}

Modified: team/twilson/calendaring/res/res_caldav.c
URL: http://svn.digium.com/view/asterisk/team/twilson/calendaring/res/res_caldav.c?view=diff&rev=166943&r1=166942&r2=166943
==============================================================================
--- team/twilson/calendaring/res/res_caldav.c (original)
+++ team/twilson/calendaring/res/res_caldav.c Tue Dec 30 16:00:07 2008
@@ -47,7 +47,7 @@
 static void *unref_caldav(void *obj);
 static int caldav_write_event(struct ast_calendar_event *event);
 
-static const struct ast_calendar_tech caldav_tech = {
+static struct ast_calendar_tech caldav_tech = {
 	.type = "caldav",
 	.description = "CalDAV calendars",
 	.module = AST_MODULE,

Modified: team/twilson/calendaring/res/res_exchangecal.c
URL: http://svn.digium.com/view/asterisk/team/twilson/calendaring/res/res_exchangecal.c?view=diff&rev=166943&r1=166942&r2=166943
==============================================================================
--- team/twilson/calendaring/res/res_exchangecal.c (original)
+++ team/twilson/calendaring/res/res_exchangecal.c Tue Dec 30 16:00:07 2008
@@ -46,7 +46,7 @@
 static void *unref_exchangecal(void *obj);
 static int exchangecal_write_event(struct ast_calendar_event *event);
 
-static const struct ast_calendar_tech exchangecal_tech = {
+static struct ast_calendar_tech exchangecal_tech = {
 	.type = "exchange",
 	.description = "MS Exchange calendars",
 	.module = AST_MODULE,

Modified: team/twilson/calendaring/res/res_icalendar.c
URL: http://svn.digium.com/view/asterisk/team/twilson/calendaring/res/res_icalendar.c?view=diff&rev=166943&r1=166942&r2=166943
==============================================================================
--- team/twilson/calendaring/res/res_icalendar.c (original)
+++ team/twilson/calendaring/res/res_icalendar.c Tue Dec 30 16:00:07 2008
@@ -43,7 +43,7 @@
 static void *ical_load_calendar(void *data);
 static void *unref_icalendar(void *obj);
 
-static const struct ast_calendar_tech ical_tech = {
+static struct ast_calendar_tech ical_tech = {
 	.type = "ical",
 	.module = AST_MODULE,
 	.description = "iCalendar .ics calendars",




More information about the asterisk-commits mailing list