1 /* $XConsortium: cmsconvert.c /main/5 1996/10/03 10:38:06 drk $ */
3 * (c) Copyright 1993, 1994 Hewlett-Packard Company
4 * (c) Copyright 1993, 1994 International Business Machines Corp.
5 * (c) Copyright 1993, 1994 Novell, Inc.
6 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
13 #include "cmsconvert.h"
14 #include "convert5-4.h"
15 #include "convert4-5.h"
23 * Routines to convert data types used in version 5 to version 4.
27 * forward declaration of functions used in the file
29 static Abb_Appt_4 * _MakeAbbrAppt();
31 static CSA_return_code _AttrsToAbbrAppt(uint size, cms_attribute *attrs,
34 static uint _ConvertV5Access(uint v5rights, boolean_t strictmode);
36 static uint _ConvertV4Access(uint v4rights);
38 static char * _ConvertReminderName(char *rname);
40 static CSA_return_code _Appt4ToCmsentryAttrs(char *calname, Appt_4 *a4,
41 uint *num_attrs, cms_attribute **attrs_r);
42 /*****************************************************************************
44 *****************************************************************************/
46 extern CSA_return_code
47 _DtCmsCmsentriesToAppt4ForClient(cms_entry *entries, Appt_4 **appt)
50 Appt_4 *newappt, *prev, *head;
53 return (CSA_E_INVALID_PARAMETER);
56 while (entries != NULL) {
57 if ((newappt = _DtCm_make_appt4(B_TRUE)) == NULL)
60 if ((stat = _DtCmsAttrsToAppt4(entries->num_attrs + 1,
61 entries->attrs, newappt, B_FALSE)) != CSA_SUCCESS) {
62 _DtCm_free_appt4(newappt);
65 newappt->appt_id.key = entries->key.id;
73 entries = entries->next;
76 if (stat != CSA_SUCCESS) {
77 _DtCm_free_appt4(head);
85 extern CSA_return_code
86 _DtCmsCmsentriesToAbbrAppt4ForClient(cms_entry *entries, Abb_Appt_4 **abbr)
89 Abb_Appt_4 *newabbr, *prev, *head;
92 return (CSA_E_INVALID_PARAMETER);
95 while (entries != NULL) {
96 if ((newabbr = _MakeAbbrAppt()) == NULL)
99 if ((stat = _AttrsToAbbrAppt(entries->num_attrs, entries->attrs,
100 newabbr)) != CSA_SUCCESS) {
101 _DtCm_free_abbrev_appt4(newabbr);
104 newabbr->appt_id.key = entries->key.id;
109 prev->next = newabbr;
112 entries = entries->next;
115 if (stat != CSA_SUCCESS) {
116 _DtCm_free_abbrev_appt4(head);
124 extern Access_Entry_4 *
125 _DtCmsConvertV5AccessList(cms_access_entry *cmslist, boolean_t strictmode)
127 Access_Entry_4 *l, *head, *prev;
128 boolean_t cleanup = B_FALSE;
131 while (cmslist != NULL) {
132 if ((l = (Access_Entry_4 *)calloc(1, sizeof(Access_Entry_4)))
138 if ((l->who = strdup(cmslist->user)) == NULL) {
143 l->access_type = _ConvertV5Access(cmslist->rights, strictmode);
151 cmslist = cmslist->next;
154 if (cleanup == B_TRUE) {
155 _DtCm_free_access_list4(head);
161 extern cms_access_entry *
162 _DtCmsConvertV4AccessList(Access_Entry_4 *alist)
164 cms_access_entry *l, *head, *prev;
165 boolean_t cleanup = B_FALSE;
168 while (alist != NULL) {
169 if ((l = (cms_access_entry *)calloc(1,
170 sizeof(cms_access_entry))) == NULL) {
175 if ((l->user = strdup(alist->who)) == NULL) {
180 l->rights = _ConvertV4Access(alist->access_type);
191 if (cleanup == B_TRUE) {
192 _DtCm_free_cms_access_entry(head);
198 extern CSA_return_code
199 _DtCmsReminderRefToReminder(
200 cms_reminder_ref *rems,
203 CSA_return_code stat = CSA_SUCCESS;
204 Reminder_4 *head, *prev, *rptr;
208 while (rems != NULL) {
210 if ((rptr = (Reminder_4 *)calloc(1, sizeof(Reminder_4)))
212 stat = CSA_E_INSUFFICIENT_MEMORY;
216 rptr->appt_id.tick = rems->key.time;
217 rptr->appt_id.key = rems->key.id;
218 rptr->tick = rems->runtime;
220 if ((rptr->attr.attr=_ConvertReminderName(rems->reminder_name))
223 stat = CSA_E_INSUFFICIENT_MEMORY;
227 if ((rptr->attr.value = calloc(1,1)) == NULL) {
228 free(rptr->attr.attr);
230 stat = CSA_E_INSUFFICIENT_MEMORY;
234 if ((rptr->attr.clientdata = calloc(1,1)) == NULL) {
235 free(rptr->attr.value);
236 free(rptr->attr.attr);
238 stat = CSA_E_INSUFFICIENT_MEMORY;
251 if (stat != CSA_SUCCESS) {
252 _DtCm_free_reminder4(head);
261 extern CSA_return_code
262 _DtCmsV4ReminderToReminderRef(
266 cms_reminder_ref **rems)
268 CSA_return_code stat = CSA_SUCCESS;
269 cms_reminder_ref *head, *prev, *rptr;
275 if ((rptr = (cms_reminder_ref *)calloc(1,
276 sizeof(cms_reminder_ref))) == NULL) {
277 stat = CSA_E_INSUFFICIENT_MEMORY;
281 rptr->key.time = r4->appt_id.tick;
282 rptr->key.id = r4->appt_id.key;
283 rptr->runtime = r4->tick;
285 if ((rptr->reminder_name = strdup(
286 _DtCm_old_reminder_name_to_name(r4->attr.attr)))
289 stat = CSA_E_INSUFFICIENT_MEMORY;
293 sprintf(buf, "%ld:%s@%s", ids->id, calname,
294 _DtCmGetHostAtDomain());
296 if ((rptr->entryid = strdup(buf)) == NULL) {
297 free(rptr->reminder_name);
299 stat = CSA_E_INSUFFICIENT_MEMORY;
313 if (stat != CSA_SUCCESS) {
314 _DtCmsFreeReminderRef(head);
323 extern CSA_return_code
324 _DtCmsCmsAccessToV4Access(cms_access_entry *alist, Access_Entry_4 **a4)
326 CSA_return_code stat = CSA_SUCCESS;
327 Access_Entry_4 *to, *prev, *head;
330 while (alist != NULL) {
331 if ((to = (Access_Entry_4 *)calloc(1, sizeof(Access_Entry_4)))
333 stat = CSA_E_INSUFFICIENT_MEMORY;
337 if ((to->access_type = _DtCmAccessRightToV4AccessType(
338 alist->rights)) < 0) {
339 stat = CSA_E_INVALID_FLAG;
343 if (alist->user == NULL) {
344 stat = CSA_E_INVALID_ATTRIBUTE_VALUE;
348 if ((to->who = strdup(alist->user)) == NULL) {
350 stat = CSA_E_INSUFFICIENT_MEMORY;
364 if (stat != CSA_SUCCESS) {
365 _DtCm_free_access_list4(head);
373 extern CSA_return_code
374 _DtCmsAppt4ToCmsentriesForClient(
379 CSA_return_code stat = CSA_SUCCESS;
380 cms_entry *entry, *head, *prev;
383 return(CSA_E_INVALID_PARAMETER);
386 while (appt != NULL) {
388 if ((entry = (cms_entry *)calloc(1, sizeof(cms_entry))) == NULL)
391 if ((stat = _Appt4ToCmsentryAttrs(calname, appt,
392 &entry->num_attrs, &entry->attrs)) == CSA_SUCCESS) {
393 entry->key.time = appt->appt_id.tick;
394 entry->key.id = appt->appt_id.key;
410 if (stat != CSA_SUCCESS) {
411 _DtCm_free_cms_entries(head);
419 extern CSA_return_code
420 _DtCmsAppt4ToCmsentry(
426 CSA_return_code stat;
430 return(CSA_E_INVALID_PARAMETER);
432 if ((entry = _DtCm_make_cms_entry(_DtCm_entry_name_tbl)) == NULL)
433 return (CSA_E_INSUFFICIENT_MEMORY);
435 entry->key.time = a4->appt_id.tick;
436 entry->key.id = a4->appt_id.key;
438 if ((stat = _DtCm_appt4_to_attrs(calname, a4, entry->num_attrs,
439 entry->attrs, rerule)) != CSA_SUCCESS) {
440 _DtCm_free_cms_entry(entry);
445 return (CSA_SUCCESS);
449 * This routine is used either to convert attrs from clients for insert
450 * or update; or to convert appts for sending to clients
451 * Note: the reference id is not converted
453 extern CSA_return_code
456 cms_attribute *attrs,
460 CSA_return_code stat = CSA_SUCCESS;
463 int i, enddateindex = -1, interval = -1, wknum;
464 int typeindex = -1, stypeindex = -1;
465 boolean_t set_wknum = B_FALSE;
468 * this routine is called to convert valid v2 to v4 attributes
469 * so no checking of CSA_E_INVALID_ATTRIBUTE and
470 * CSA_E_UNSUPPORTED_ATTRIBUTE is necessary
473 for (i = 0; i < size && stat == CSA_SUCCESS; i++) {
474 switch (attrs[i].name.num) {
475 case CSA_ENTRY_ATTR_START_DATE_I:
476 if (check == B_TRUE && attrs[i].value == NULL)
477 stat = CSA_E_INVALID_ATTRIBUTE_VALUE;
478 else if (_csa_iso8601_to_tick(attrs[i].value->\
479 item.date_time_value, &appt->appt_id.tick))
480 stat = CSA_E_INVALID_DATE_TIME;
483 case CSA_ENTRY_ATTR_END_DATE_I:
487 case CSA_ENTRY_ATTR_TYPE_I:
491 case CSA_ENTRY_ATTR_SUBTYPE_I:
495 case CSA_ENTRY_ATTR_SUMMARY_I:
497 if (attrs[i].value->item.string_value) {
498 if ((string = strdup(attrs[i].value->item.\
499 string_value)) == NULL)
500 stat = CSA_E_INSUFFICIENT_MEMORY;
509 case CSA_ENTRY_ATTR_ORGANIZER_I:
511 if ((appt->author = strdup(attrs[i].value->\
512 item.calendar_user_value)) == NULL)
513 stat = CSA_E_INSUFFICIENT_MEMORY;
516 case CSA_ENTRY_ATTR_AUDIO_REMINDER_I:
518 if (attrs[i].value == NULL)
519 stat = _DtCm_remove_reminder(
520 _DtCM_OLD_ATTR_BEEP_REMINDER, appt);
521 else if (attrs[i].value->item.reminder_value == NULL)
522 stat = CSA_E_INVALID_ATTRIBUTE_VALUE;
524 stat = _DtCm_add_reminder(
525 _DtCM_OLD_ATTR_BEEP_REMINDER,
526 attrs[i].value->item.reminder_value,
530 case CSA_ENTRY_ATTR_FLASHING_REMINDER_I:
532 if (attrs[i].value == NULL)
533 stat = _DtCm_remove_reminder(
534 _DtCM_OLD_ATTR_FLASH_REMINDER, appt);
535 else if (attrs[i].value->item.reminder_value == NULL)
536 stat = CSA_E_INVALID_ATTRIBUTE_VALUE;
538 stat = _DtCm_add_reminder(
539 _DtCM_OLD_ATTR_FLASH_REMINDER,
540 attrs[i].value->item.reminder_value,
544 case CSA_ENTRY_ATTR_MAIL_REMINDER_I:
546 if (attrs[i].value == NULL)
547 stat = _DtCm_remove_reminder(
548 _DtCM_OLD_ATTR_MAIL_REMINDER, appt);
549 else if (attrs[i].value->item.reminder_value == NULL)
550 stat = CSA_E_INVALID_ATTRIBUTE_VALUE;
552 stat = _DtCm_add_reminder(
553 _DtCM_OLD_ATTR_MAIL_REMINDER,
554 attrs[i].value->item.reminder_value,
558 case CSA_ENTRY_ATTR_POPUP_REMINDER_I:
560 if (attrs[i].value == NULL)
561 stat = _DtCm_remove_reminder(
562 _DtCM_OLD_ATTR_POPUP_REMINDER, appt);
563 else if (attrs[i].value->item.reminder_value == NULL)
564 stat = CSA_E_INVALID_ATTRIBUTE_VALUE;
566 stat = _DtCm_add_reminder(
567 _DtCM_OLD_ATTR_POPUP_REMINDER,
568 attrs[i].value->item.reminder_value,
572 case CSA_X_DT_ENTRY_ATTR_REPEAT_TYPE_I:
574 if (_DtCm_rtype_to_interval4(
575 attrs[i].value->item.sint32_value,
576 &appt->period.period)) {
578 stat = CSA_E_INVALID_ATTRIBUTE_VALUE;
580 appt->period.period = otherPeriod_4;
584 case CSA_X_DT_ENTRY_ATTR_REPEAT_TIMES_I:
586 if (attrs[i].value) {
588 attrs[i].value->item.uint32_value;
589 if (appt->ntimes == CSA_X_DT_DT_REPEAT_FOREVER)
590 appt->ntimes = _DtCM_OLD_REPEAT_FOREVER;
594 case CSA_X_DT_ENTRY_ATTR_SHOWTIME_I:
597 appt->tag->showtime =
598 attrs[i].value->item.sint32_value;
601 case CSA_ENTRY_ATTR_STATUS_I:
603 if (_DtCm_status_to_apptstatus4(
604 attrs[i].value->item.uint32_value,
605 &appt->appt_status)) {
607 stat = CSA_E_INVALID_ATTRIBUTE_VALUE;
609 appt->appt_status = active_4;
613 case CSA_ENTRY_ATTR_CLASSIFICATION_I:
615 if (_DtCm_classification_to_privacy4(
616 attrs[i].value->item.uint32_value, &appt->privacy))
619 stat = CSA_E_INVALID_ATTRIBUTE_VALUE;
621 appt->privacy = public_4;
625 case CSA_X_DT_ENTRY_ATTR_SEQUENCE_END_DATE_I:
627 if (attrs[i].value &&
628 attrs[i].value->item.date_time_value &&
629 *(attrs[i].value->item.date_time_value))
631 if (_csa_iso8601_to_tick(
632 attrs[i].value->item.date_time_value,
633 &appt->period.enddate))
634 stat = CSA_E_INVALID_DATE_TIME;
638 case CSA_X_DT_ENTRY_ATTR_REPEAT_INTERVAL_I:
640 interval = attrs[i].value->item.uint32_value;
643 case CSA_X_DT_ENTRY_ATTR_REPEAT_OCCURRENCE_NUM_I:
644 if (attrs[i].value) {
646 wknum = attrs[i].value->item.sint32_value;
652 if (stat == CSA_SUCCESS && enddateindex >= 0) {
653 if (attrs[enddateindex].value == NULL ||
654 attrs[enddateindex].value->item.date_time_value == NULL) {
656 } else if (_csa_iso8601_to_tick(attrs[enddateindex].value->\
657 item.date_time_value, &endtick)) {
658 stat = CSA_E_INVALID_DATE_TIME;
660 appt->duration = endtick - appt->appt_id.tick;
664 if (stat == CSA_SUCCESS && (typeindex >= 0 || typeindex >= 0)) {
665 if (typeindex >= 0) {
666 if (stat = _DtCm_attrs_to_eventtype4(
667 attrs[typeindex].value,
668 (stypeindex >= 0 ? attrs[stypeindex].value : NULL),
670 if (check == B_FALSE) {
671 /* this is the case where we are
672 * converting appt for clients
674 appt->tag->tag = otherTag_4;
678 } else if (stypeindex >= 0) {
679 if (attrs[stypeindex].value &&
680 attrs[stypeindex].value->item.string_value)
682 if (strcmp(attrs[stypeindex].value->item.\
683 string_value, CSA_SUBTYPE_APPOINTMENT) == 0)
684 appt->tag->tag = appointment_4;
685 else if (strcmp(attrs[stypeindex].value->item.\
686 string_value, CSA_SUBTYPE_HOLIDAY) == 0)
687 appt->tag->tag = holiday_4;
689 stat = CSA_E_INVALID_ATTRIBUTE_VALUE;
691 stat = CSA_E_INVALID_ATTRIBUTE_VALUE;
695 if (stat == CSA_SUCCESS) {
696 switch (appt->period.period) {
698 if (set_wknum == B_TRUE)
699 appt->period.nth = wknum;
703 case everyNthMonth_4:
705 appt->period.nth = interval;
708 appt->period.nth = 0;
711 if (appt->period.period == single_4)
718 /******************************************************************************
719 * static functions used within the file
720 ******************************************************************************/
723 * attributes are hashed
724 * we are converting v4 events to v3 appts, so attributes are
725 * assumed to be good and all mandatory ones are present
727 static CSA_return_code
728 _AttrsToAbbrAppt(uint size, cms_attribute *attrs, Abb_Appt_4 *appt)
730 CSA_return_code stat = CSA_SUCCESS;
733 int i, typeindex, stypeindex = -1, enddateindex = -1;
736 for (i = 0; i < size && stat == CSA_SUCCESS; i++) {
737 switch (attrs[i].name.num) {
738 case CSA_ENTRY_ATTR_START_DATE_I:
739 _csa_iso8601_to_tick(attrs[i].value->\
740 item.date_time_value, &appt->appt_id.tick);
743 case CSA_ENTRY_ATTR_END_DATE_I:
747 case CSA_ENTRY_ATTR_TYPE_I:
751 case CSA_ENTRY_ATTR_SUBTYPE_I:
755 case CSA_X_DT_ENTRY_ATTR_SHOWTIME_I:
756 appt->tag->showtime = attrs[i].value->item.sint32_value;
759 case CSA_ENTRY_ATTR_SUMMARY_I:
760 if (attrs[i].value && attrs[i].value->item.string_value)
763 if ((appt->what = strdup(attrs[i].value->\
764 item.string_value)) == NULL)
765 stat = CSA_E_INSUFFICIENT_MEMORY;
769 case CSA_ENTRY_ATTR_STATUS_I:
770 if (_DtCm_status_to_apptstatus4(attrs[i].value->item.\
771 uint32_value, &appt->appt_status))
772 appt->appt_status = active_4;
775 case CSA_ENTRY_ATTR_CLASSIFICATION_I:
776 if (_DtCm_classification_to_privacy4(attrs[i].value->\
777 item.uint32_value, &appt->privacy))
778 appt->privacy = public_4;
781 case CSA_X_DT_ENTRY_ATTR_REPEAT_TYPE_I:
782 if (_DtCm_rtype_to_interval4(attrs[i].value->\
783 item.sint32_value, &appt->period.period))
784 appt->period.period = otherPeriod_4;
787 case CSA_X_DT_ENTRY_ATTR_REPEAT_OCCURRENCE_NUM_I:
788 appt->period.nth = attrs[i].value->item.sint32_value;
791 case CSA_X_DT_ENTRY_ATTR_REPEAT_INTERVAL_I:
792 appt->period.nth = attrs[i].value->item.uint32_value;
795 case CSA_X_DT_ENTRY_ATTR_SEQUENCE_END_DATE_I:
796 _csa_iso8601_to_tick(attrs[i].value->item.\
797 date_time_value, &appt->period.enddate);
802 if (stat != CSA_SUCCESS)
805 if (enddateindex >= 0) {
806 _csa_iso8601_to_tick(attrs[enddateindex].value->item.\
807 date_time_value, &endtick);
808 appt->duration = endtick - appt->appt_id.tick;
812 if (_DtCm_attrs_to_eventtype4(attrs[typeindex].value,
813 (stypeindex >= 0 ? attrs[stypeindex].value : NULL), appt->tag))
814 appt->tag->tag = otherTag_4;
816 return (CSA_SUCCESS);
824 if ((a = (Abb_Appt_4 *)calloc(1, sizeof(Abb_Appt_4))) == NULL)
827 if ((a->tag = (Tag_4 *)calloc(1, sizeof(Tag_4))) == NULL) {
832 a->tag->tag = appointment_4;
833 a->tag->showtime = B_TRUE;
839 _ConvertV5Access(uint v5rights, boolean_t strictmode)
843 if (v5rights & CSA_OWNER_RIGHTS)
844 return (access_read_4 | access_write_4 | access_delete_4);
846 if (v5rights & (CSA_VIEW_PUBLIC_ENTRIES|CSA_VIEW_CONFIDENTIAL_ENTRIES|
847 CSA_VIEW_PRIVATE_ENTRIES))
848 access = access_read_4;
850 if ((strictmode == B_TRUE &&
851 (v5rights & CSA_INSERT_PUBLIC_ENTRIES) &&
852 (v5rights & CSA_INSERT_PRIVATE_ENTRIES) &&
853 (v5rights & CSA_INSERT_CONFIDENTIAL_ENTRIES)) ||
854 (strictmode == B_FALSE &&
855 (v5rights & (CSA_INSERT_PUBLIC_ENTRIES |
856 CSA_INSERT_PRIVATE_ENTRIES | CSA_INSERT_CONFIDENTIAL_ENTRIES))))
857 access |= access_write_4;
859 if ((strictmode == B_TRUE &&
860 (v5rights & CSA_CHANGE_PUBLIC_ENTRIES) &&
861 (v5rights & CSA_CHANGE_PRIVATE_ENTRIES) &&
862 (v5rights & CSA_CHANGE_CONFIDENTIAL_ENTRIES)) ||
863 (strictmode == B_FALSE &&
864 (v5rights & (CSA_CHANGE_PUBLIC_ENTRIES |
865 CSA_CHANGE_PRIVATE_ENTRIES | CSA_CHANGE_CONFIDENTIAL_ENTRIES))))
866 access |= access_delete_4;
872 _ConvertV4Access(uint v4rights)
876 if (v4rights & access_read_4)
877 access = CSA_VIEW_PUBLIC_ENTRIES;
879 if (v4rights & access_write_4)
880 access |= CSA_INSERT_PUBLIC_ENTRIES;
882 if (v4rights & (access_write_4 | access_delete_4))
883 access |= CSA_CHANGE_PUBLIC_ENTRIES;
889 _ConvertReminderName(char *rname)
891 if (!strcmp(rname, CSA_ENTRY_ATTR_AUDIO_REMINDER))
892 return (strdup(_DtCM_OLD_ATTR_BEEP_REMINDER));
893 else if (!strcmp(rname, CSA_ENTRY_ATTR_FLASHING_REMINDER))
894 return (strdup(_DtCM_OLD_ATTR_FLASH_REMINDER));
895 else if (!strcmp(rname, CSA_ENTRY_ATTR_MAIL_REMINDER))
896 return (strdup(_DtCM_OLD_ATTR_MAIL_REMINDER));
897 else if (!strcmp(rname, CSA_ENTRY_ATTR_POPUP_REMINDER))
898 return (strdup(_DtCM_OLD_ATTR_POPUP_REMINDER));
900 return (strdup(rname));
903 static CSA_return_code
904 _Appt4ToCmsentryAttrs(
908 cms_attribute **attrs_r)
910 CSA_return_code stat = CSA_SUCCESS;
911 cms_attribute *attrs;
912 cms_attribute tmpattr;
913 cms_attribute_value tmpval;
914 Attribute_4 *reminders = a4->attr;
917 int index, ntimes, count = 0;
920 if (num_attrs == NULL || attrs_r == NULL)
921 return (CSA_E_INVALID_PARAMETER);
923 if ((attrs = (cms_attribute *)calloc(1,
924 sizeof(cms_attribute) * (_DtCM_OLD_ENTRY_ATTR_SIZE+ 1))) == NULL)
925 return (CSA_E_INSUFFICIENT_MEMORY);
927 if (a4->period.period != single_4 &&
928 a4->ntimes == _DtCM_OLD_REPEAT_FOREVER)
929 ntimes = CSA_X_DT_DT_REPEAT_FOREVER;
933 tmpattr.value = &tmpval;
936 tmpattr.name.name = CSA_ENTRY_ATTR_REFERENCE_IDENTIFIER;
937 tmpattr.name.num = CSA_ENTRY_ATTR_REFERENCE_IDENTIFIER_I;
938 tmpval.type = CSA_VALUE_OPAQUE_DATA;
939 tmpval.item.opaque_data_value = &opq;
940 ptr1 = strchr(calname, '@');
941 ptr2 = (ptr1 ? strchr(ptr1, '.') : NULL);
943 sprintf(buf, "%ld:%s%s%s", a4->appt_id.key, calname,
944 (ptr2 == NULL ? "." : ""),
945 (ptr2 == NULL ? _DtCmGetLocalDomain(ptr1+1) : ""));
947 sprintf(buf, "%ld:%s@%s", a4->appt_id.key, calname,
948 _DtCmGetHostAtDomain());
950 opq.size = strlen(buf);
951 opq.data = (unsigned char *)buf;
953 if ((stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr, B_TRUE))
960 tmpattr.name.name = CSA_ENTRY_ATTR_START_DATE;
961 tmpattr.name.num = CSA_ENTRY_ATTR_START_DATE_I;
962 tmpval.type = CSA_VALUE_DATE_TIME;
963 tmpval.item.date_time_value = buf;
964 if ((stat = _csa_tick_to_iso8601(a4->appt_id.tick, buf) ?
965 CSA_E_INVALID_DATE_TIME : CSA_SUCCESS) ||
966 (stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr, B_TRUE))
972 tmpattr.name.name = CSA_ENTRY_ATTR_TYPE;
973 tmpattr.name.num = CSA_ENTRY_ATTR_TYPE_I;
974 tmpval.type = CSA_VALUE_UINT32;
975 tmpval.item.uint32_value = _DtCm_eventtype4_to_type(a4->tag->tag);
976 if ((stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr, B_TRUE))
982 tmpattr.name.name = CSA_ENTRY_ATTR_SUBTYPE;
983 tmpattr.name.num = CSA_ENTRY_ATTR_SUBTYPE_I;
984 tmpval.type = CSA_VALUE_STRING;
985 tmpval.item.string_value = _DtCm_eventtype4_to_subtype(a4->tag->tag);
986 if ((stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr, B_TRUE))
992 tmpattr.name.name = CSA_X_DT_ENTRY_ATTR_SHOWTIME;
993 tmpattr.name.num = CSA_X_DT_ENTRY_ATTR_SHOWTIME_I;
994 tmpval.type = CSA_VALUE_SINT32;
995 tmpval.item.sint32_value = a4->tag->showtime;
996 if ((stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr, B_TRUE))
1002 tmpattr.name.name = CSA_ENTRY_ATTR_END_DATE;
1003 tmpattr.name.num = CSA_ENTRY_ATTR_END_DATE_I;
1004 tmpval.type = CSA_VALUE_DATE_TIME;
1005 tmpval.item.date_time_value = buf;
1006 if ((stat = _csa_tick_to_iso8601(a4->appt_id.tick + a4->duration,
1007 buf) ? CSA_E_INVALID_DATE_TIME : CSA_SUCCESS) != CSA_SUCCESS ||
1008 (stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr, B_TRUE))
1014 tmpattr.name.name = CSA_ENTRY_ATTR_SUMMARY;
1015 tmpattr.name.num = CSA_ENTRY_ATTR_SUMMARY_I;
1016 tmpval.type = CSA_VALUE_STRING;
1017 tmpval.item.string_value = a4->what;
1018 if ((stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr, B_TRUE))
1024 tmpattr.name.name = CSA_ENTRY_ATTR_ORGANIZER;
1025 tmpattr.name.num = CSA_ENTRY_ATTR_ORGANIZER_I;
1026 tmpval.type = CSA_VALUE_CALENDAR_USER;
1027 tmpval.item.calendar_user_value = a4->author;
1028 if ((stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr, B_TRUE))
1034 tmpattr.name.name = CSA_ENTRY_ATTR_STATUS;
1035 tmpattr.name.num = CSA_ENTRY_ATTR_STATUS_I;
1036 tmpval.type = CSA_VALUE_UINT32;
1037 tmpval.item.uint32_value = _DtCm_apptstatus4_to_status(a4->appt_status);
1038 if ((stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr, B_TRUE))
1043 /* classification */
1044 tmpattr.name.name = CSA_ENTRY_ATTR_CLASSIFICATION;
1045 tmpattr.name.num = CSA_ENTRY_ATTR_CLASSIFICATION_I;
1046 tmpval.type = CSA_VALUE_UINT32;
1047 tmpval.item.uint32_value = _DtCm_privacy4_to_classification(a4->privacy);
1048 if ((stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr, B_TRUE))
1054 tmpattr.name.name = CSA_X_DT_ENTRY_ATTR_REPEAT_TYPE;
1055 tmpattr.name.num = CSA_X_DT_ENTRY_ATTR_REPEAT_TYPE_I;
1056 tmpval.type = CSA_VALUE_SINT32;
1057 tmpval.item.sint32_value = _DtCm_interval4_to_rtype(a4->period.period);
1058 if ((stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr, B_TRUE))
1064 if (a4->period.period != single_4) {
1065 tmpattr.name.name = CSA_X_DT_ENTRY_ATTR_REPEAT_TIMES;
1066 tmpattr.name.num = CSA_X_DT_ENTRY_ATTR_REPEAT_TIMES_I;
1067 tmpval.type = CSA_VALUE_UINT32;
1068 tmpval.item.uint32_value = ntimes;
1069 if ((stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr,
1070 B_TRUE)) != CSA_SUCCESS) {
1075 /* occurrence number */
1076 if (a4->period.period == nthWeekday_4) {
1077 tmpattr.name.name = CSA_X_DT_ENTRY_ATTR_REPEAT_OCCURRENCE_NUM;
1078 tmpattr.name.num = CSA_X_DT_ENTRY_ATTR_REPEAT_OCCURRENCE_NUM_I;
1079 tmpval.type = CSA_VALUE_SINT32;
1080 tmpval.item.sint32_value = a4->period.nth;
1081 if ((stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr,
1082 B_TRUE)) != CSA_SUCCESS) {
1087 /* repeat interval */
1088 if (a4->period.period >= everyNthDay_4 &&
1089 a4->period.period <= everyNthMonth_4) {
1090 tmpattr.name.name = CSA_X_DT_ENTRY_ATTR_REPEAT_INTERVAL;
1091 tmpattr.name.num = CSA_X_DT_ENTRY_ATTR_REPEAT_INTERVAL_I;
1092 tmpval.type = CSA_VALUE_UINT32;
1093 tmpval.item.uint32_value = a4->period.nth;
1094 if ((stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr,
1095 B_TRUE)) != CSA_SUCCESS) {
1100 if (a4->period.enddate != 0) {
1101 tmpattr.name.name = CSA_X_DT_ENTRY_ATTR_SEQUENCE_END_DATE;
1102 tmpattr.name.num = CSA_X_DT_ENTRY_ATTR_SEQUENCE_END_DATE_I;
1103 tmpval.type = CSA_VALUE_DATE_TIME;
1104 tmpval.item.date_time_value = buf;
1105 if ((stat = _csa_tick_to_iso8601(a4->period.enddate, buf) ?
1106 CSA_E_INVALID_DATE_TIME : CSA_SUCCESS) != CSA_SUCCESS ||
1107 (stat = _DtCm_copy_cms_attribute(&attrs[count++], &tmpattr,
1108 B_TRUE)) != CSA_SUCCESS) {
1113 while (reminders != NULL) {
1114 if ((attrs[count].name.num = _DtCm_old_reminder_name_to_index(
1115 reminders->attr)) >= 0) {
1116 if ((attrs[count].name.name =
1117 strdup(_DtCm_old_reminder_name_to_name(
1118 reminders->attr))) == NULL) {
1122 if ((stat = _DtCmAttr4ToReminderValue(reminders,
1123 &attrs[count++].value)) != CSA_SUCCESS) {
1129 reminders = reminders->next;
1134 return (CSA_SUCCESS);
1137 _DtCm_free_cms_attributes(count--, attrs);