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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 28 13:07:06 CDT 2009


Author: twilson
Date: Thu May 28 13:07:01 2009
New Revision: 197692

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=197692
Log:
Cleanup somethings to get ready for commit

Modified:
    team/twilson/calendaring/configs/calendar.conf.sample
    team/twilson/calendaring/configure   (contents, props changed)
    team/twilson/calendaring/include/asterisk/autoconfig.h.in
    team/twilson/calendaring/res/res_caldav.c
    team/twilson/calendaring/res/res_calendar.c

Modified: team/twilson/calendaring/configs/calendar.conf.sample
URL: http://svn.asterisk.org/svn-view/asterisk/team/twilson/calendaring/configs/calendar.conf.sample?view=diff&rev=197692&r1=197691&r2=197692
==============================================================================
--- team/twilson/calendaring/configs/calendar.conf.sample (original)
+++ team/twilson/calendaring/configs/calendar.conf.sample Thu May 28 13:07:01 2009
@@ -1,6 +1,3 @@
-[general]
-enabled = yes
-
 ;[calendar1]
 ;type = ical              ;  type of calendar--currently supported: ical, caldav, or exchange
 ;url = https://example.com/home/jdoe/Calendar/   ; URL to shared calendar (Zimbra example)

Propchange: team/twilson/calendaring/configure
            ('svn:eol-style' removed)

Propchange: team/twilson/calendaring/configure
            ('svn:keywords' removed)

Propchange: team/twilson/calendaring/configure
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Thu May 28 13:07:01 2009
@@ -1,1 +1,1 @@
-text/plain
+application/octet-stream

Modified: team/twilson/calendaring/include/asterisk/autoconfig.h.in
URL: http://svn.asterisk.org/svn-view/asterisk/team/twilson/calendaring/include/asterisk/autoconfig.h.in?view=diff&rev=197692&r1=197691&r2=197692
==============================================================================
--- team/twilson/calendaring/include/asterisk/autoconfig.h.in (original)
+++ team/twilson/calendaring/include/asterisk/autoconfig.h.in Thu May 28 13:07:01 2009
@@ -1214,9 +1214,6 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
-/* Define to 1 if the C compiler supports function prototypes. */
-#undef PROTOTYPES
-
 /* Define to necessary symbol if this constant uses a non-standard name on
    your system. */
 #undef PTHREAD_CREATE_JOINABLE
@@ -1232,11 +1229,6 @@
 
 /* Define to the type of arg 5 for `select'. */
 #undef SELECT_TYPE_ARG5
-
-/* Define to 1 if the `setvbuf' function takes the buffering type as its
-   second argument and the buffer pointer as the third, as on System V before
-   release 3. */
-#undef SETVBUF_REVERSED
 
 /* The size of `int', as computed by sizeof. */
 #undef SIZEOF_INT
@@ -1258,20 +1250,30 @@
 /* Define to 1 if your <sys/time.h> declares `struct tm'. */
 #undef TM_IN_SYS_TIME
 
-/* Define to 1 if on AIX 3.
-   System headers sometimes define this.
-   We just want to avoid a redefinition error message.  */
+/* Enable extensions on AIX 3, Interix.  */
 #ifndef _ALL_SOURCE
 # undef _ALL_SOURCE
 #endif
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-#undef _FILE_OFFSET_BITS
-
 /* Enable GNU extensions on systems that have them.  */
 #ifndef _GNU_SOURCE
 # undef _GNU_SOURCE
 #endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+
+
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
 
 /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
 #undef _LARGEFILE_SOURCE
@@ -1288,20 +1290,6 @@
 
 /* Define to 1 if you need to in order for `stat' and other things to work. */
 #undef _POSIX_SOURCE
-
-/* Enable extensions on Solaris.  */
-#ifndef __EXTENSIONS__
-# undef __EXTENSIONS__
-#endif
-#ifndef _POSIX_PTHREAD_SEMANTICS
-# undef _POSIX_PTHREAD_SEMANTICS
-#endif
-#ifndef _TANDEM_SOURCE
-# undef _TANDEM_SOURCE
-#endif
-
-/* Define like PROTOTYPES; this can be used by system headers. */
-#undef __PROTOTYPES
 
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const

Modified: team/twilson/calendaring/res/res_caldav.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/twilson/calendaring/res/res_caldav.c?view=diff&rev=197692&r1=197691&r2=197692
==============================================================================
--- team/twilson/calendaring/res/res_caldav.c (original)
+++ team/twilson/calendaring/res/res_caldav.c Thu May 28 13:07:01 2009
@@ -77,7 +77,7 @@
 {
 	struct caldav_pvt *pvt = obj;
 
-	ast_debug(1, "Destroying pvt for iCalendar %s\n", pvt->owner->name);
+	ast_debug(1, "Destroying pvt for CalDAV calendar %s\n", pvt->owner->name);
 	if (pvt->session) {
 		ne_session_destroy(pvt->session);
 	}
@@ -117,7 +117,7 @@
 	struct caldav_pvt *pvt = userdata;
 
 	if (attempts > 1) {
-		ast_log(LOG_WARNING, "Invalid username or password for iCalendar '%s'\n", pvt->owner->name);
+		ast_log(LOG_WARNING, "Invalid username or password for CalDAV calendar '%s'\n", pvt->owner->name);
 		return -1;
 	}
 
@@ -527,6 +527,12 @@
 	return 0;
 }
 
+static int verify_cert(void *userdata, int failures, const ne_ssl_certificate *cert)
+{
+	/* Verify all certs */
+	return 0;
+}
+
 static void *caldav_load_calendar(void *void_data)
 {
 	struct caldav_pvt *pvt;
@@ -539,12 +545,19 @@
 		return NULL;
 	}
 
+	if (ao2_trylock(cal)) {
+		if (cal->unloading) {
+			ast_log(LOG_WARNING, "Unloading module, load_calendar cancelled.\n");
+		} else {
+			ast_log(LOG_WARNING, "Could not lock calendar, which is totally freaking me out. I give up.\n");
+		}
+		return NULL;
+	}
+
 	if (!(pvt = ao2_alloc(sizeof(*pvt), caldav_destructor))) {
 		ast_log(LOG_ERROR, "Could not allocate caldav_pvt structure for calendar: %s\n", cal->name);
 		return NULL;
 	}
-
-	ao2_lock(cal);
 
 	pvt->owner = cal;
 
@@ -573,14 +586,14 @@
 	}
 
 	if (ast_strlen_zero(pvt->url)) {
-		ast_log(LOG_WARNING, "No URL was specified for iCalendar '%s' - skipping.\n", cal->name);
+		ast_log(LOG_WARNING, "No URL was specified for CalDAV calendar '%s' - skipping.\n", cal->name);
 		pvt = unref_caldav(pvt);
 		ao2_unlock(cal);
 		return NULL;
 	}
 
 	if (ne_uri_parse(pvt->url, &pvt->uri) || pvt->uri.host == NULL || pvt->uri.path == NULL) {
-		ast_log(LOG_WARNING, "Could not parse url '%s' for iCalendar '%s' - skipping.\n", pvt->url, cal->name);
+		ast_log(LOG_WARNING, "Could not parse url '%s' for CalDAV calendar '%s' - skipping.\n", pvt->url, cal->name);
 		pvt = unref_caldav(pvt);
 		ao2_unlock(cal);
 		return NULL;
@@ -598,6 +611,7 @@
 	ne_set_server_auth(pvt->session, auth_credentials, pvt);
 	if (!strncasecmp(pvt->uri.scheme, "https", sizeof(pvt->uri.scheme))) {
 		ne_ssl_trust_default_ca(pvt->session);
+		ne_ssl_set_verify(pvt->session, verify_cert, NULL);
 	}
 
 	cal->tech_pvt = pvt;
@@ -655,7 +669,7 @@
 	return 0;
 }
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Asterisk MS Exchange Calendar Integration",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Asterisk CalDAV Calendar Integration",
 		.load = load_module,
 		.unload = unload_module,
 	);

Modified: team/twilson/calendaring/res/res_calendar.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/twilson/calendaring/res/res_calendar.c?view=diff&rev=197692&r1=197691&r2=197692
==============================================================================
--- team/twilson/calendaring/res/res_calendar.c (original)
+++ team/twilson/calendaring/res/res_calendar.c Thu May 28 13:07:01 2009
@@ -153,7 +153,7 @@
 	</function>
 
 ***/
-#define MAX_BUCKETS 19
+#define CALENDAR_BUCKETS 19
 
 static struct ao2_container *calendars;
 static struct sched_context *sched;
@@ -251,7 +251,9 @@
 	cal->unloading = 1;
 	ast_cond_signal(&cal->unload);
 	pthread_join(cal->thread, NULL);
-	cal->tech_pvt = cal->tech->unref_calendar(cal->tech_pvt);
+	if (cal->tech_pvt) {
+		cal->tech_pvt = cal->tech->unref_calendar(cal->tech_pvt);
+	}
 	ast_calendar_clear_events(cal);
 	ast_string_field_free_memory(cal);
 	ao2_ref(cal->events, -1);
@@ -320,7 +322,7 @@
 			return NULL;
 		}
 
-		if (!(cal->events = ao2_container_alloc(MAX_BUCKETS, event_hash_fn, event_cmp_fn))) {
+		if (!(cal->events = ao2_container_alloc(CALENDAR_BUCKETS, event_hash_fn, event_cmp_fn))) {
 			ast_log(LOG_ERROR, "Could not allocate events container for %s\n", cat);
 			cal = unref_calendar(cal);
 			return NULL;
@@ -367,7 +369,13 @@
 		cal->thread = AST_PTHREADT_NULL;
 		ast_cond_init(&cal->unload, NULL);
 		ao2_link(calendars, cal);
-		ast_pthread_create(&cal->thread, NULL, cal->tech->load_calendar, cal);
+		if (ast_pthread_create(&cal->thread, NULL, cal->tech->load_calendar, cal)) {
+			/* If we start failing to create threads, go ahead and return NULL
+			 * and the tech module will be unregistered
+			 */ 
+			ao2_unlink(calendars, cal);
+			cal = unref_calendar(cal);
+		}
 	}
 
 	return cal;
@@ -447,7 +455,7 @@
 			continue;
 		}
 
-		ao2_callback(calendars, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, match_caltech_cb, (struct ast_calendar_tech *) tech);
+		ao2_callback(calendars, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, match_caltech_cb, tech);
 
 		AST_LIST_REMOVE_CURRENT(list);
 		ast_verb(2, "Unregistered calendar type '%s'\n", tech->type);
@@ -471,8 +479,6 @@
 		}
 		ast_free(attendee);
 	}
-
-	return;
 }
 
 /* This is only called from ao2_callbacks that are going to unref the event for us,
@@ -522,12 +528,10 @@
 {
 	struct ast_calendar_event *event;
 	if (!(event = ao2_alloc(sizeof(*event), calendar_event_destructor))) {
-		ast_log(LOG_ERROR, "Could not allocate memory for event!\n");
 		return NULL;
 	}
 
 	if (ast_string_field_init(event, 32)) {
-		ast_log(LOG_ERROR, "Could not allocate memory for event fields\n");
 		event = ast_calendar_unref_event(event);
 		return NULL;
 	}
@@ -544,7 +548,7 @@
 
 struct ao2_container *ast_calendar_event_container_alloc(void)
 {
-	return ao2_container_alloc(MAX_BUCKETS, event_hash_fn, event_cmp_fn);
+	return ao2_container_alloc(CALENDAR_BUCKETS, event_hash_fn, event_cmp_fn);
 }
 
 static void event_notification_destroy(void *data)
@@ -647,7 +651,6 @@
 	res = ast_channel_datastore_add(chan, datastore);
 
 	if (!(apptext = ast_str_create(32))) {
-		ast_log(LOG_ERROR, "Could not allocate space for string\n");
 		goto notify_cleanup;
 	}
 
@@ -843,10 +846,8 @@
 
 static int load_config(void *data)
 {
-	const char *cat = NULL;
 	struct ast_flags config_flags = { CONFIG_FLAG_FILEUNCHANGED };
 	struct ast_config *tmpcfg;
-	const char *val;
 
 	if (!(tmpcfg = ast_config_load2("calendar.conf", "calendar", config_flags)) ||
 		tmpcfg == CONFIG_STATUS_FILEINVALID) {
@@ -863,19 +864,6 @@
 	}
 
 	calendar_config = tmpcfg;
-
-	while ((cat = ast_category_browse(calendar_config, cat))) {
-		if (!strcasecmp(cat, "general")) {
-			if (!(val = ast_variable_retrieve(calendar_config, cat, "enabled")) || !ast_true(val)) {
-				ast_log(LOG_NOTICE, "Disabling calendar support\n");
-				ast_config_destroy(calendar_config);
-				calendar_config = NULL;
-				return -1;
-			} else {
-				ast_log(LOG_NOTICE, "Enabling calendar support\n");
-			}
-		}
-	}
 
 	return 0;
 }
@@ -1577,7 +1565,7 @@
 		return 0;
 	}
 
-	if (!(calendars = ao2_container_alloc(MAX_BUCKETS, calendar_hash_fn, calendar_cmp_fn))) {
+	if (!(calendars = ao2_container_alloc(CALENDAR_BUCKETS, calendar_hash_fn, calendar_cmp_fn))) {
 		ast_log(LOG_ERROR, "Unable to allocate calendars container!\n");
 		return -1;
 	}




More information about the asterisk-commits mailing list