To Add a Calendar Entry
Example 10-6 Adding a Calendar Entry
#include <csa/csa.h>
CSA_return_code stat;
CSA_session_handle cal;
CSA_attribute attrs[9];
CSA_attribute_value attr_val[9];
CSA_reminder audio;
CSA_reminder mail;
CSA_entry_handle new_entry;
int i;
i = 0;
/* The start date attribute. This attribute has no default
* value and must be specified.
* A CSA_date_time value is a UTC based date and time value
* expressed in the ISO 8601 standard.
*/
attrs[i].name = CSA_ENTRY_ATTR_START_DATE;
attrs[i].value = &attr_val[i];
attrs[i].attribute_extensions = NULL;
attr_val[i].type = CSA_VALUE_DATE_TIME;
attr_val[i].item.date_time_value = iso8601time(time(NULL));
i++;
/* The end date attribute.
* If not specified, the entry will not have the end date
* attribute.
*/
attrs[i].name = CSA_ENTRY_ATTR_END_DATE;
attrs[i].value = &attr_val[i];
attrs[i].attribute_extensions = NULL;
attr_val[i].type = CSA_VALUE_DATE_TIME;
attr_val[i].item.date_time_value = iso8601time(time(NULL) + 3600);
i++;
/* The classification attribute.
* If not specified, the default value is CSA_CLASS_PUBLIC.
*/
attrs[i].name = CSA_ENTRY_ATTR_CLASSIFICATION;
attrs[i].value = &attr_val[i];
attrs[i].attribute_extensions = NULL;
attr_val[i].type = CSA_VALUE_UINT32;
attr_val[i].item.sint32_value = CSA_CLASS_CONFIDENTIAL;
i++;
/* The type attribute. This attribute has no default value and
* must be specified.
*/
attrs[i].name = CSA_ENTRY_ATTR_TYPE;
attrs[i].value = &attr_val[i];
attrs[i].attribute_extensions = NULL;
attr_val[i].type = CSA_VALUE_UINT32;
attr_val[i].item.sint32_value = CSA_TYPE_EVENT;
i++;
/* The sub-type attribute.
* If not specified, the default value is CSA_SUBTYPE_APPOINTMENT
*/
attrs[i].name = CSA_ENTRY_ATTR_SUBTYPE;
attrs[i].value = &attr_val[i];
attrs[i].attribute_extensions = NULL;
attr_val[i].type = CSA_VALUE_STRING;
attr_val[i].item.string_value = CSA_SUBTYPE_APPOINTMENT;
i++;
/* The summary attribute */
attrs[i].name = CSA_ENTRY_ATTR_SUMMARY;
attrs[i].value = &attr_val[i];
attrs[i].attribute_extensions = NULL;
attr_val[i].type = CSA_VALUE_STRING;
attr_val[i].item.string_value = argv6;
attrs[i].attribute_extensions = NULL;
i++;
/* The recurrence rule attribute.
* If not specified, the entry is a one time entry.
* The recurrence rule "D1 #3" specifies that the
* entry is to be repeated daily for 3 days.
*/
attrs[i].name = CSA_ENTRY_ATTR_RECURRENCE_RULE;
attrs[i].value = &attr_val[i];
attrs[i].attribute_extensions = NULL;
attr_val[i].type = CSA_VALUE_STRING;
attr_val[i].item.string_value = argv7;
i++;
/* The audio reminder attribute.
* The lead time of a reminder is a CSA_time_duration value
* which is expressed in the ISO 8601 standard.
* For example, a lead time of 5 minutes is expressed as
* the string "+PT300S". A negative lead time of 5 minutes
* is expressed as "-PT300S".
*/
attrs[i].name = CSA_ENTRY_ATTR_AUDIO_REMINDER;
attrs[i].value = &attr_val[i];
attrs[i].attribute_extensions = NULL;
attr_val[i].type = CSA_VALUE_REMINDER;
attr_val[i].item.reminder_value = &audio;
memset((void *)&audio, NULL, sizeof(audio));
audio.lead_time = "+PT300S"; i++;
/* The mail reminder attribute.
* The e-mail address is specified in the reminder_data field
* This reminder has a lead time of one day.
*/
attrs[i].name = CSA_ENTRY_ATTR_MAIL_REMINDER;
attrs[i].value = &attr_val[i];
attrs[i].attribute_extensions = NULL;
attr_val[i].type = CSA_VALUE_REMINDER;
attr_val[i].item.reminder_value = &mail;
memset((void *)&mail, NULL, sizeof(mail));
mail.lead_time = "+PT86400S";
mail.reminder_data.data = "someuser@somehost";
mail.reminder_data.size = strlen(mail.reminder_data.data);
i++;
/* add an entry with the specified attribute values */
stat = csa_add_entry(cal, i, attrs, &newentry, NULL);
if (stat == CSA_SUCCESS)
csa_free((CSA_buffer)newentry);