2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: api.c /main/1 1996/04/21 19:21:31 drk $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company
26 * (c) Copyright 1993, 1994 International Business Machines Corp.
27 * (c) Copyright 1993, 1994 Novell, Inc.
28 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
32 * Implements the calendar manager API functions.
35 #include <EUSCompat.h>
47 #include "connection.h"
56 /******************************************************************************
57 * forward declaration of static functions used within the file
58 ******************************************************************************/
59 static CSA_return_code _handle_register_callback_ext(CSA_extension *ext);
60 static CSA_return_code _handle_logon_ext(CSA_extension *ext,
61 CSA_extension **pext);
62 static CSA_return_code _handle_query_config_ext(CSA_extension *ext);
63 static void _handle_com_support_ext(CSA_extension *ext);
65 /******************************************************************************
66 * Calendar Manager API
67 ******************************************************************************/
70 * List calendars supported by a server
72 extern CSA_return_code
74 CSA_service_reference calendar_service,
75 CSA_uint32 *number_names,
76 CSA_calendar_user **calendar_names,
77 CSA_extension *list_calendars_extensions)
79 DP(("api.c: csa_list_calendars\n"));
81 if (calendar_service == NULL || number_names == NULL ||
82 calendar_names == NULL)
83 return (CSA_E_INVALID_PARAMETER);
85 /* no function extension is supported */
86 if (list_calendars_extensions != NULL)
87 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
89 return (_DtCm_rpc_list_calendars(calendar_service, number_names,
94 * Logon to a calendar.
95 * Returns a calendar session handle.
97 * arguments not used by this implementation:
98 * calendar_servce, password, character_set, caller_csa_version,
101 * arguments ignored for now
102 * character_set, caller_csa_version
104 * user - only the calendar_address field is used, other fields are ignored
105 * - format is calendar_name@host
107 extern CSA_return_code
109 CSA_service_reference calendar_service,
110 CSA_calendar_user *user,
112 CSA_string character_set,
113 CSA_string caller_csa_version,
114 CSA_session_handle *session,
115 CSA_extension *logon_extensions)
117 CSA_return_code stat;
119 CSA_extension *pext = NULL;
121 DP(("api.c: csa_logon\n"));
123 /* check validity of arguments */
124 if (user == NULL || user->calendar_address == NULL || session == NULL
125 || strchr(user->calendar_address, '@') == NULL)
126 return (CSA_E_INVALID_PARAMETER);
128 /* create calendar object */
129 if ((cal = _DtCm_new_Calendar(user->calendar_address)) == NULL) {
130 return (CSA_E_INSUFFICIENT_MEMORY);
133 if (logon_extensions != NULL) {
134 if ((stat = _handle_logon_ext(logon_extensions, &pext))
140 if ((stat = _DtCm_rpc_open_calendar(cal)) == CSA_SUCCESS) {
142 if (pext) pext->item_data = cal->access;
144 *session = (CSA_session_handle)cal;
147 _DtCm_free_Calendar(cal);
156 * arguments not used by this implementation:
157 * session - always ignored
158 * add_calendar_extensions
160 * user - only the calendar_address field is used, other fields are ignored
161 * - format is calendar_name@host
163 extern CSA_return_code
165 CSA_session_handle session,
166 CSA_calendar_user *user,
167 CSA_uint32 number_attributes,
168 CSA_attribute *calendar_attributes,
169 CSA_extension *add_calendar_extensions)
171 CSA_return_code stat;
175 DP(("api.c: csa_add_calendar\n"));
177 /* check validity of arguments */
178 if (user == NULL || user->calendar_address == NULL ||
179 (host = strchr(user->calendar_address, '@')) == NULL)
180 return (CSA_E_INVALID_PARAMETER);
182 /* check add_calendar_extensions and return appropriate return code */
183 /* no function extension is supported */
184 if (add_calendar_extensions != NULL)
185 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
187 /* create calendar object */
188 if ((cal = _DtCm_new_Calendar(user->calendar_address)) == NULL) {
189 return (CSA_E_INSUFFICIENT_MEMORY);
193 if ((stat = _DtCm_get_server_rpc_version(host, &cal->rpc_version))
197 /* check validity of attributes */
198 if (number_attributes > 0 &&
199 (stat = _DtCm_check_cal_csa_attributes(cal->rpc_version - 1,
200 number_attributes, calendar_attributes, user->calendar_address,
201 B_TRUE, B_TRUE, B_FALSE)) != CSA_SUCCESS) {
205 /* create calendar */
206 stat = _DtCm_rpc_create_calendar(cal, number_attributes,
207 calendar_attributes);
209 _DtCm_free_Calendar(cal);
216 * The calendar handle becomes invalid
218 * argument not used by this implementation:
221 extern CSA_return_code
223 CSA_session_handle session,
224 CSA_extension *logoff_extensions)
228 DP(("api.c: csa_logoff\n"));
230 /* get calendar object */
231 if ((cal = _DtCm_get_Calendar(session)) == NULL)
232 return (CSA_E_INVALID_SESSION_HANDLE);
234 /* check logoff_extensions and return appropriate return code */
235 /* no function extension is supported */
236 if (logoff_extensions != NULL)
237 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
239 /* unregister with server */
240 if (cal->all_reasons)
241 (void) _DtCm_rpc_unregister_client(cal, cal->all_reasons);
244 _DtCm_free_Calendar(cal);
246 return (CSA_SUCCESS);
252 extern CSA_return_code
254 CSA_session_handle session,
255 CSA_extension *delete_calendar_extensions)
259 DP(("api.c: csa_delete_calendar\n"));
261 /* get calendar object */
262 if ((cal = _DtCm_get_Calendar(session)) == NULL)
263 return (CSA_E_INVALID_SESSION_HANDLE);
265 /* check extensions and return appropriate return code */
266 /* no function extension is supported */
267 if (delete_calendar_extensions != NULL)
268 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
270 if (cal->rpc_version < 5)
271 return (CSA_E_NOT_SUPPORTED);
273 return (_DtCm_rpc_delete_calendar(cal));
276 extern CSA_return_code
277 csa_list_calendar_attributes(
278 CSA_session_handle session,
279 CSA_uint32 *number_names,
280 CSA_attribute_reference **calendar_attributes_names,
281 CSA_extension *list_calendar_attributes_extensions)
285 DP(("api.c: csa_list_calendar_attributes\n"));
287 if (number_names == NULL || calendar_attributes_names == NULL)
288 return (CSA_E_INVALID_PARAMETER);
290 /* no function extension is supported */
291 if (list_calendar_attributes_extensions != NULL)
292 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
294 /* get calendar object */
295 if ((cal = _DtCm_get_Calendar(session)) == NULL)
296 return (CSA_E_INVALID_SESSION_HANDLE);
298 if (cal->rpc_version < _DtCM_FIRST_EXTENSIBLE_SERVER_VERSION) {
299 return (_DtCm_list_old_cal_attr_names(cal, number_names,
300 calendar_attributes_names));
302 return (_DtCm_rpc_list_calendar_attributes(cal, number_names,
303 calendar_attributes_names));
306 extern CSA_return_code
308 CSA_session_handle session,
309 CSA_string archive_name,
310 CSA_uint32 number_attributes,
311 CSA_attribute *attributes,
313 CSA_boolean delete_entry,
314 CSA_extension *save_extensions)
316 DP(("api.c: csa_save\n"));
318 return (CSA_E_NOT_SUPPORTED);
321 extern CSA_return_code
323 CSA_session_handle session,
324 CSA_string archive_name,
325 CSA_uint32 number_attributes,
326 CSA_attribute *attributes,
328 CSA_extension *restore_extensions)
330 DP(("api.c: csa_restore\n"));
332 return (CSA_E_NOT_SUPPORTED);
336 * If list_operators is NULL, the operator is default to be CSA_MATCH_EQUAL_TO
337 * for all attributes.
338 * *** might want to check operator for conflicts that won't result in no match
340 extern CSA_return_code
342 CSA_session_handle session,
343 CSA_uint32 number_attributes,
344 CSA_attribute *entry_attributes,
345 CSA_enum *list_operators,
346 CSA_uint32 *number_entries,
347 CSA_entry_handle **entries,
348 CSA_extension *list_entries_extensions)
350 CSA_return_code stat;
352 _DtCm_libentry *elist;
354 DP(("api.c: csa_list_entries\n"));
356 if (entries == NULL || number_entries == NULL)
357 return (CSA_E_INVALID_PARAMETER);
363 /* check list_entries_extensions
364 * and return appropriate return code
365 * no function extension is supported
367 if (list_entries_extensions != NULL)
368 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
370 /* get calendar object */
371 if ((cal = _DtCm_get_Calendar(session)) == NULL)
372 return (CSA_E_INVALID_SESSION_HANDLE);
374 if (list_operators && (stat = _DtCm_check_operator(number_attributes,
375 entry_attributes, NULL, list_operators)) != CSA_SUCCESS) {
380 /* check data type */
381 if ((stat = _DtCm_check_entry_attributes(cal->file_version,
382 number_attributes, entry_attributes, 0, B_FALSE)) != CSA_SUCCESS) {
384 * if attribute not supported by old backends
385 * are specified, just fail the match,
386 * i.e. return NULL and CSA_SUCCESS
388 if (stat == CSA_E_UNSUPPORTED_ATTRIBUTE)
395 if ((stat = _DtCm_rpc_lookup_entries(cal, number_attributes,
396 entry_attributes, list_operators, &elist)) == CSA_SUCCESS) {
399 *number_entries = _DtCm_add_to_entry_list(cal, (caddr_t)elist);
400 stat = _DtCm_libentry_to_entryh(elist, number_entries,
408 extern CSA_return_code
409 csa_list_entry_attributes(
410 CSA_session_handle session,
411 CSA_entry_handle entryh,
412 CSA_uint32 *number_names,
413 CSA_attribute_reference **entry_attribute_names,
414 CSA_extension *list_entry_attributes_extensions)
416 CSA_return_code stat;
417 _DtCm_libentry *entry;
419 DP(("api.c: csa_list_entry_attributes\n"));
421 if (number_names == NULL || entry_attribute_names == NULL)
422 return (CSA_E_INVALID_PARAMETER);
424 /* check list_entry_attributes_extensions
425 * and return appropriate return code
426 * no function extension is supported
428 if (list_entry_attributes_extensions != NULL)
429 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
431 /* get appointment */
432 if ((entry = _DtCm_get_libentry(entryh)) == NULL)
433 return (CSA_E_INVALID_ENTRY_HANDLE);
435 if ((stat = _DtCm_get_entry_detail(entry)) != CSA_SUCCESS)
438 return (_DtCm_get_entry_attr_names(entry, number_names,
439 entry_attribute_names));
443 extern CSA_return_code
444 csa_read_entry_attributes(
445 CSA_session_handle session,
446 CSA_entry_handle entryh,
447 CSA_uint32 number_names,
448 CSA_attribute_reference *attribute_names,
449 CSA_uint32 *number_attributes,
450 CSA_attribute **entry_attributes,
451 CSA_extension *read_entry_attributes_extensions)
453 CSA_return_code stat;
454 _DtCm_libentry *entry;
456 DP(("api.c: csa_read_entry_attributes\n"));
458 if (number_attributes == 0 || entry_attributes == NULL)
459 return (CSA_E_INVALID_PARAMETER);
461 /* check read_entry_attributes_extensions
462 * and return appropriate return code
463 * no function extension is supported
465 if (read_entry_attributes_extensions != NULL)
466 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
468 /* get entry object */
469 if ((entry = _DtCm_get_libentry(entryh)) == NULL)
470 return (CSA_E_INVALID_ENTRY_HANDLE);
472 if ((stat = _DtCm_get_entry_detail(entry)) != CSA_SUCCESS)
475 if (number_names > 0) {
476 return (_DtCm_get_entry_attrs_by_name(entry, number_names,
477 attribute_names, number_attributes, entry_attributes));
479 return (_DtCm_get_all_entry_attrs(entry, number_attributes,
484 extern CSA_return_code
485 csa_free(CSA_buffer memory)
487 DP(("api.c: csa_free\n"));
489 return (_DtCm_free(memory));
492 extern CSA_return_code
494 CSA_session_handle session,
495 CSA_calendar_user *users,
496 CSA_flags look_up_flags,
497 CSA_uint32 *number_users,
498 CSA_calendar_user **user_list,
499 CSA_extension *look_up_extensions)
501 DP(("api.c: csa_look_up\n"));
503 return (CSA_E_NOT_SUPPORTED);
506 extern CSA_return_code
507 csa_query_configuration(
508 CSA_session_handle session,
510 CSA_buffer *reference,
511 CSA_extension *query_configuration_extensions)
513 CSA_return_code stat = CSA_SUCCESS;
515 DP(("api.c: csa_query_configuration\n"));
517 /* get calendar object */
518 if ((cal = _DtCm_get_Calendar(session)) == NULL)
519 return (CSA_E_INVALID_SESSION_HANDLE);
521 if (item < CSA_CONFIG_CHARACTER_SET || item > CSA_CONFIG_VER_SPEC)
522 return (CSA_E_INVALID_ENUM);
524 if (reference == NULL)
525 return (CSA_E_INVALID_PARAMETER);
527 if (query_configuration_extensions) {
528 if ((stat = _handle_query_config_ext(
529 query_configuration_extensions)) != CSA_SUCCESS)
534 case CSA_CONFIG_DEFAULT_SERVICE:
535 case CSA_CONFIG_DEFAULT_USER:
539 case CSA_CONFIG_REQ_PASSWORD:
540 *reference = (CSA_buffer)CSA_REQUIRED_NO;
543 case CSA_CONFIG_REQ_SERVICE:
544 case CSA_CONFIG_REQ_USER:
545 *reference = (CSA_buffer)CSA_REQUIRED_YES;
548 case CSA_CONFIG_UI_AVAIL:
549 *reference = (CSA_buffer)CSA_FALSE;
552 case CSA_CONFIG_VER_SPEC:
553 *reference = (CSA_buffer)strdup(_DtCM_SPEC_VERSION_SUPPORTED);
556 case CSA_CONFIG_CHARACTER_SET:
557 case CSA_CONFIG_LINE_TERM:
558 case CSA_CONFIG_VER_IMPLEM:
559 stat = CSA_E_UNSUPPORTED_ENUM;
565 extern CSA_return_code
566 csa_read_calendar_attributes(
567 CSA_session_handle session,
568 CSA_uint32 number_names,
569 CSA_attribute_reference *attribute_names,
570 CSA_uint32 *number_attributes,
571 CSA_attribute **calendar_attributes,
572 CSA_extension *read_calendar_attributes_extensions)
576 DP(("api.c: csa_read_calendar_attributes\n"));
578 if (number_attributes == 0 || calendar_attributes == NULL)
579 return (CSA_E_INVALID_PARAMETER);
581 /* check read_calendar_attributes_extensions
582 * and return appropriate return code
583 * no function extension is supported
585 if (read_calendar_attributes_extensions != NULL)
586 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
588 /* get calendar object */
589 if ((cal = _DtCm_get_Calendar(session)) == NULL)
590 return (CSA_E_INVALID_SESSION_HANDLE);
592 _DtCm_reset_cal_attrs(cal);
593 if (number_names > 0) {
594 return (_DtCm_get_cal_attrs_by_name(cal, number_names,
595 attribute_names, number_attributes,
596 calendar_attributes));
598 return (_DtCm_get_all_cal_attrs(cal, number_attributes,
599 calendar_attributes));
603 extern CSA_return_code
604 csa_register_callback(
605 CSA_session_handle session,
607 CSA_callback callback,
608 CSA_buffer client_data,
609 CSA_extension *register_callback_extensions)
611 CSA_return_code stat = CSA_SUCCESS;
612 _DtCmCallbackEntry *cb_entry;
614 boolean_t async = B_FALSE;
616 /* get calendar object */
617 if ((cal = _DtCm_get_Calendar(session)) == NULL)
618 return (CSA_E_INVALID_SESSION_HANDLE);
620 /* make sure some valid flags are set
621 * and only entry added, deleted or updated is specified for
622 * servers support up to version 4 rpc protocol
624 if (reason == 0 || reason >= (CSA_CB_ENTRY_UPDATED << 1) ||
625 (cal->rpc_version < _DtCM_FIRST_EXTENSIBLE_SERVER_VERSION &&
626 (reason & ~(CSA_CB_ENTRY_ADDED|CSA_CB_ENTRY_DELETED|
627 CSA_CB_ENTRY_UPDATED))))
628 return (CSA_E_INVALID_FLAG);
630 /* must specify a callback function otherwise
631 * there is no point to make this call
633 if (callback == NULL)
634 return (CSA_E_INVALID_PARAMETER);
636 /* need to initialize agent before doing XtAppAddInput */
639 if (register_callback_extensions != NULL) {
640 if ((stat = _handle_register_callback_ext(
641 register_callback_extensions)) != CSA_SUCCESS)
648 * register interest only if we have a new flag
649 * NOTE: It's OK to register more than once, even if it's
650 * the same calendar, same reason. The customer is always right.
652 if (((cal->all_reasons | reason) ^ cal->all_reasons) &&
653 (stat = _DtCm_rpc_register_client(cal, reason)) != CSA_SUCCESS)
656 if ((cb_entry = (_DtCmCallbackEntry*)malloc(sizeof(_DtCmCallbackEntry)))
658 return (CSA_E_INSUFFICIENT_MEMORY);
660 /* update info in calendar structure */
661 cal->all_reasons |= reason;
663 /* don't just do cal->async_process = async, since cal->async_process
664 * might have been set to B_TRUE before.
667 cal->async_process = B_TRUE;
668 if (cal->async_process == B_TRUE)
669 cal->do_reasons = cal->all_reasons;
671 /* fill in the callback record */
672 cb_entry->reason = reason;
673 cb_entry->handler = callback;
674 cb_entry->client_data = client_data;
676 /* insert it at head of list */
677 cb_entry->next = cal->cb_list;
678 cb_entry->prev = (_DtCmCallbackEntry*) NULL;
679 if (cal->cb_list != (_DtCmCallbackEntry*) NULL)
680 cal->cb_list->prev = cb_entry;
681 cal->cb_list = cb_entry;
687 * csa_unregister_callback
689 * removes a previsouly registered callback from the callback list
690 * of the specified calendar.
692 extern CSA_return_code
693 csa_unregister_callback(
694 CSA_session_handle session,
696 CSA_callback handler,
697 CSA_buffer client_data,
698 CSA_extension *unregister_callback_extensions)
701 boolean_t match_one = B_FALSE;
702 boolean_t match_all = B_FALSE;
704 CSA_flags all = 0, unreg;
705 _DtCmCallbackEntry *cb, *ncb;
707 /* get calendar object */
708 if ((cal = _DtCm_get_Calendar(session)) == NULL)
709 return (CSA_E_INVALID_SESSION_HANDLE);
711 if (reason == 0 || reason >= (CSA_CB_ENTRY_UPDATED << 1))
712 return (CSA_E_INVALID_FLAG);
714 /* check unregister_callback_extensions
715 * and return appropriate return code
716 * no function extension is supported
718 if (unregister_callback_extensions != NULL)
719 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
721 if (handler == NULL && client_data == NULL)
723 else if (handler == NULL) /* but client data is not NULL */
724 return (CSA_E_INVALID_PARAMETER);
727 * Removal policy: If both handler and client data are NULL,
728 * match all callbacks for the specified reason.
729 * Otherwise, all of reason, handler and client data must
737 if (!(reason & cb->reason) ||
738 (match_all == B_FALSE && (handler != cb->handler ||
739 client_data != cb->client_data))) {
740 all = all | cb->reason;
747 if (cb->reason = (cb->reason | reason) ^ reason) {
748 all = all | cb->reason;
751 if (cb->prev != NULL)
752 cb->prev->next = cb->next;
753 if (cb->next != NULL)
754 cb->next->prev = cb->prev;
755 if (cb == cal->cb_list)
756 cal->cb_list = cb->next;
763 unreg = all ^ cal->all_reasons;
764 cal->all_reasons = all;
767 (void) _DtCm_rpc_unregister_client(cal, unreg);
769 if (match_one == B_TRUE)
770 return (CSA_SUCCESS);
772 return (CSA_E_CALLBACK_NOT_REGISTERED);
777 CSA_session_handle session,
779 CSA_extension *call_callbacks_extensions)
783 DP(("api.c: csa_call_callbacks\n"));
785 /* get calendar object */
786 if ((cal = _DtCm_get_Calendar(session)) == NULL)
787 return (CSA_E_INVALID_SESSION_HANDLE);
789 /* no function extension is supported */
790 if (call_callbacks_extensions != NULL)
791 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
793 /* set up information in calendar structure */
794 if (cal->async_process == B_FALSE)
795 cal->do_reasons = reason;
797 /* trigger callback mechanism */
798 _DtCm_process_updates();
800 if (cal->async_process == B_FALSE)
803 return (CSA_SUCCESS);
806 extern CSA_return_code
807 csa_update_calendar_attributes(
808 CSA_session_handle session,
809 CSA_uint32 num_attrs,
810 CSA_attribute *attrs,
811 CSA_extension *update_calendar_attributes_extensions)
813 CSA_return_code stat = CSA_SUCCESS;
816 DP(("api.c: csa_update_calendar_attributes\n"));
818 /* get calendar object */
819 if ((cal = _DtCm_get_Calendar(session)) == NULL)
820 return (CSA_E_INVALID_SESSION_HANDLE);
822 if (num_attrs == 0 || attrs == NULL)
823 return (CSA_E_INVALID_PARAMETER);
826 * check update_calendar_attributes_extensions
827 * return appropriate return code
828 * no function extension is supported
830 if (update_calendar_attributes_extensions != NULL)
831 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
833 /* check authority */
834 if ((cal->file_version >= _DtCM_FIRST_EXTENSIBLE_DATA_VERSION &&
835 !(cal->access & (CSA_OWNER_RIGHTS | CSA_INSERT_CALENDAR_ATTRIBUTES |
836 CSA_CHANGE_CALENDAR_ATTRIBUTES))) ||
837 (cal->file_version < _DtCM_FIRST_EXTENSIBLE_DATA_VERSION &&
838 !(cal->access & CSA_OWNER_RIGHTS)))
839 return (CSA_E_NO_AUTHORITY);
841 /* check data type */
842 if ((stat = _DtCm_check_cal_csa_attributes(cal->file_version,
843 num_attrs, attrs, cal->name, B_TRUE, B_FALSE, B_TRUE))
849 stat = _DtCm_rpc_set_cal_attrs(cal, num_attrs, attrs);
854 extern CSA_return_code
856 CSA_session_handle session,
857 CSA_uint32 num_attrs,
858 CSA_attribute *attrs,
859 CSA_entry_handle *entry_r,
860 CSA_extension *add_entry_extensions)
862 CSA_return_code stat;
864 _DtCm_libentry *entry;
866 DP(("api.c: csa_add_entry\n"));
868 if (num_attrs == 0 || attrs == NULL)
869 return (CSA_E_INVALID_PARAMETER);
871 /* get calendar object */
872 if ((cal = _DtCm_get_Calendar(session)) == NULL)
873 return (CSA_E_INVALID_SESSION_HANDLE);
875 /* check data type, readonly attributes, etc */
876 if ((stat = _DtCm_check_entry_attributes(cal->file_version,
877 num_attrs, attrs, CSA_CB_ENTRY_ADDED, B_TRUE)) != CSA_SUCCESS) {
881 /* no function extension is supported */
882 if (add_entry_extensions != NULL)
883 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
885 /* insert in calendar */
886 if ((stat = _DtCm_rpc_insert_entry(cal, num_attrs, attrs, &entry))
889 if (entry_r != NULL) {
890 if ((entry = _DtCm_convert_entry_wheader(entry))==NULL)
891 stat = CSA_E_INSUFFICIENT_MEMORY;
893 _DtCm_add_to_entry_list(cal, (caddr_t)entry);
894 *entry_r = (CSA_entry_handle)entry;
897 _DtCm_free_libentries(entry);
904 * The session argument is ignored in this implementation.
906 extern CSA_return_code
908 CSA_session_handle session,
909 CSA_entry_handle entryh,
910 CSA_enum delete_scope,
911 CSA_extension *delete_entry_extensions)
913 CSA_return_code stat;
914 _DtCm_libentry *entry;
916 DP(("api.c: csa_delete_entry\n"));
918 /* get entry object */
919 if ((entry = _DtCm_get_libentry(entryh)) == NULL)
920 return (CSA_E_INVALID_ENTRY_HANDLE);
922 if (delete_scope < CSA_SCOPE_ALL || delete_scope > CSA_SCOPE_FORWARD)
923 return (CSA_E_INVALID_ENUM);
925 /* check delete_entry_extensions and return appropriate return code */
926 /* no function extension is supported */
927 if (delete_entry_extensions != NULL)
928 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
930 /* delete entry from calendar */
931 stat = _DtCm_rpc_delete_entry(entry->cal, entry, delete_scope);
936 extern CSA_return_code
937 csa_free_time_search(
938 CSA_session_handle session,
939 CSA_date_time_range date_time_range,
940 CSA_time_duration time_duration,
941 CSA_uint32 number_users,
942 CSA_calendar_user *users,
943 CSA_free_time **free_time,
944 CSA_extension *free_time_search_extensions)
946 DP(("api.c: csa_free_time_search\n"));
948 return (CSA_E_NOT_SUPPORTED);
951 extern CSA_return_code
952 csa_list_entry_sequence(
953 CSA_session_handle session,
954 CSA_entry_handle entryh,
955 CSA_date_time_range time_range,
956 CSA_uint32 *number_entries,
957 CSA_entry_handle **entries,
958 CSA_extension *list_entry_sequence_extensions)
960 CSA_return_code stat;
961 _DtCm_libentry *entry, *elist;
962 cms_attribute *rtype;
963 cms_attribute *rtimes;
964 /* needed temporaryly */
965 time_t start = 0, end = 0;
967 DP(("api.c: csa_list_entry_sequence\n"));
969 /* get entry object */
970 if ((entry = _DtCm_get_libentry(entryh)) == NULL)
971 return (CSA_E_INVALID_ENTRY_HANDLE);
973 if (number_entries == NULL || entries == NULL)
974 return (CSA_E_INVALID_PARAMETER);
980 /* check whether this entry repeats */
981 /* fail it if it's not a repeating event */
982 if (entry->cal->file_version < _DtCM_FIRST_EXTENSIBLE_DATA_VERSION) {
983 rtype = &entry->e->attrs[CSA_X_DT_ENTRY_ATTR_REPEAT_TYPE_I];
984 if (rtype->value == NULL ||
985 rtype->value->item.sint32_value == CSA_X_DT_REPEAT_ONETIME)
987 return (CSA_E_INVALID_PARAMETER);
990 rtype = &entry->e->attrs[CSA_ENTRY_ATTR_RECURRENCE_RULE_I];
991 if (rtype->value == NULL ||
992 rtype->value->item.string_value == NULL ||
993 *(rtype->value->item.string_value) == '\0' ) {
994 return (CSA_E_INVALID_PARAMETER);
999 /* if this entry repeats indefinitely and time range is not
1000 * specified, fail it
1003 if (_csa_iso8601_to_range(time_range, &start, &end) != 0)
1004 return (CSA_E_INVALID_DATE_TIME);
1007 if (entry->cal->file_version < _DtCM_FIRST_EXTENSIBLE_DATA_VERSION)
1008 rtimes = &entry->e->attrs[CSA_X_DT_ENTRY_ATTR_REPEAT_TIMES_I];
1010 rtimes = &entry->e->attrs[CSA_ENTRY_ATTR_NUMBER_RECURRENCES_I];
1012 if (start == 0 && end == 0 &&
1013 (rtimes->value && rtimes->value->item.uint32_value
1014 == CSA_X_DT_DT_REPEAT_FOREVER))
1015 return (CSA_E_INVALID_PARAMETER);
1017 /* no function extension is supported */
1018 if (list_entry_sequence_extensions != NULL)
1019 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
1021 /* lookup sequence */
1022 if ((stat = _DtCm_rpc_enumerate_sequence(entry->cal, entry, start, end,
1023 &elist)) == CSA_SUCCESS) {
1026 *number_entries = _DtCm_add_to_entry_list(entry->cal,
1028 stat = _DtCm_libentry_to_entryh(elist, number_entries,
1037 * Due to the implementation of existing backends (versions 2-4)
1038 * which will unmanage any reminders that happens before the
1039 * the given tick, the user specified tick is ignore and
1040 * we will pass in the current time.
1042 extern CSA_return_code
1043 csa_read_next_reminder(
1044 CSA_session_handle session,
1045 CSA_uint32 number_names,
1046 CSA_attribute_reference *reminder_names,
1047 CSA_date_time given_time,
1048 CSA_uint32 *number_reminders,
1049 CSA_reminder_reference **reminders,
1050 CSA_extension *read_next_reminder_extensions)
1052 CSA_return_code stat;
1054 _DtCm_libentry *eptr, *prev = NULL, *head = NULL;
1058 DP(("api.c: csa_read_next_reminder\n"));
1060 /* get calendar object */
1061 if ((cal = _DtCm_get_Calendar(session)) == NULL)
1062 return (CSA_E_INVALID_SESSION_HANDLE);
1064 if (number_reminders == 0 || reminders == NULL)
1065 return (CSA_E_INVALID_PARAMETER);
1067 if (given_time == NULL || _csa_iso8601_to_tick(given_time, &timeval))
1068 return (CSA_E_INVALID_DATE_TIME);
1071 * check read_next_reminder_extensions and
1072 * return appropriate return code
1073 * no function extension is supported
1075 if (read_next_reminder_extensions != NULL)
1076 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
1078 /* lookup reminders */
1079 if ((stat = _DtCm_rpc_lookup_reminder(cal, timeval,
1080 number_names, reminder_names, number_reminders, reminders))
1084 * link up all associated entries
1085 * and add to calendar structure
1087 for (i = 0; i < *number_reminders; i++) {
1088 eptr = (_DtCm_libentry *)((*reminders)[i]).entry;
1090 /* link entry back to cal */
1093 /* link up entries in the same order as
1094 * the associated reminders
1106 (void)_DtCm_add_to_entry_list(cal, (caddr_t)head);
1113 * These arguments are ignored in this implementation:
1114 * session, update_propagation
1116 extern CSA_return_code
1117 csa_update_entry_attributes(
1118 CSA_session_handle session,
1119 CSA_entry_handle entry,
1121 CSA_boolean update_propagation,
1122 CSA_uint32 num_attrs,
1123 CSA_attribute *attrs,
1124 CSA_entry_handle *new_entry,
1125 CSA_extension *update_entry_attributes_extensions)
1127 CSA_return_code stat;
1128 _DtCm_libentry *oentry, *nentry;
1130 DP(("api.c: csa_update_entry_attributes\n"));
1132 /* get entry object */
1133 if ((oentry = _DtCm_get_libentry(entry)) == NULL)
1134 return (CSA_E_INVALID_ENTRY_HANDLE);
1136 if (scope < CSA_SCOPE_ALL || scope > CSA_SCOPE_FORWARD)
1137 return (CSA_E_INVALID_ENUM);
1139 if (num_attrs == 0 || attrs == NULL)
1140 return (CSA_E_INVALID_PARAMETER);
1143 * check update_entry_attributes_extensions and
1144 * return appropriate return code
1145 * no function extension is supported
1147 if (update_entry_attributes_extensions != NULL)
1148 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
1150 /* check data type, readonly attributes, etc */
1151 if ((stat = _DtCm_check_entry_attributes(oentry->cal->file_version,
1152 num_attrs, attrs, CSA_CB_ENTRY_UPDATED, B_TRUE)) != CSA_SUCCESS) {
1156 /* change entry in calendar */
1157 if ((stat = _DtCm_rpc_update_entry(oentry->cal, oentry, num_attrs,
1158 attrs, scope, &nentry)) == CSA_SUCCESS) {
1160 if ((nentry = _DtCm_convert_entry_wheader(nentry))
1162 stat = CSA_E_INSUFFICIENT_MEMORY;
1164 _DtCm_add_to_entry_list(oentry->cal,
1166 *new_entry = (CSA_entry_handle)nentry;
1169 _DtCm_free_libentries(nentry);
1176 extern CSA_return_code
1178 CSA_service_reference calendar_service,
1179 CSA_string calendar_address,
1180 CSA_string logon_user,
1181 CSA_string logon_password,
1182 CSA_string attendee,
1183 CSA_enum attendee_priority,
1184 CSA_enum attendee_status,
1185 CSA_boolean attendee_rsvp_requested,
1186 CSA_date_time start_date,
1187 CSA_date_time end_date,
1188 CSA_string organizer,
1191 CSA_string description,
1192 CSA_string recurrence_rule,
1193 CSA_string exception_rule,
1195 CSA_enum classification,
1196 CSA_string delimiters,
1197 CSA_string add_event_extensions)
1199 DP(("api.c: csa_add_event\n"));
1201 return (CSA_E_NOT_SUPPORTED);
1207 CSA_service_reference calendar_service,
1208 CSA_string calendar_address,
1209 CSA_string logon_user,
1210 CSA_string logon_password,
1211 CSA_enum attendee_priority,
1212 CSA_enum attendee_status,
1213 CSA_boolean attendee_rsvp_requested,
1214 CSA_date_time start_date,
1215 CSA_date_time due_date,
1216 CSA_uint32 priority,
1218 CSA_string description,
1219 CSA_enum classification,
1220 CSA_string delimiters,
1221 CSA_string add_todo_extensions)
1223 DP(("api.c: csa_add_todo\n"));
1225 return (CSA_E_NOT_SUPPORTED);
1231 CSA_service_reference calendar_service,
1232 CSA_string calendar_address,
1233 CSA_string logon_user,
1234 CSA_string logon_password,
1235 CSA_date_time start_date,
1237 CSA_string delimiters,
1238 CSA_string add_memo_extensions)
1240 DP(("api.c: csa_add_memo\n"));
1242 return (CSA_E_NOT_SUPPORTED);
1245 /******************************************************************************
1246 * static functions used within in the file
1247 ******************************************************************************/
1249 static CSA_return_code
1250 _handle_register_callback_ext(CSA_extension *ext)
1254 for (i = 0; ; i++) {
1255 if (ext[i].item_code == CSA_X_XT_APP_CONTEXT_EXT) {
1256 _DtCm_register_xtcallback(
1257 (XtAppContext)ext[i].item_data);
1259 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
1261 if (ext[i].extension_flags & CSA_EXT_LAST_ELEMENT)
1265 return (CSA_SUCCESS);
1268 static CSA_return_code
1269 _handle_logon_ext(CSA_extension *ext, CSA_extension **pext)
1272 int get_access_index = -1;
1273 int com_support_index = -1;
1275 for (i = 0; ; i++) {
1276 if (ext[i].item_code == CSA_X_DT_GET_USER_ACCESS_EXT)
1277 get_access_index = i;
1278 else if (ext[i].item_code == CSA_X_COM_SUPPORT_EXT)
1279 com_support_index = i;
1281 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
1283 if (ext[i].extension_flags & CSA_EXT_LAST_ELEMENT)
1287 if (get_access_index >= 0)
1288 *pext = &ext[get_access_index];
1290 if (com_support_index >= 0)
1291 _handle_com_support_ext(&ext[com_support_index]);
1293 return (CSA_SUCCESS);
1296 static CSA_return_code
1297 _handle_query_config_ext(CSA_extension *ext)
1300 int com_support_index = -1;
1302 for (i = 0; ; i++) {
1303 if (ext[i].item_code == CSA_X_COM_SUPPORT_EXT) {
1304 com_support_index = i;
1306 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
1308 if (ext[i].extension_flags & CSA_EXT_LAST_ELEMENT)
1312 if (com_support_index >= 0)
1313 _handle_com_support_ext(&ext[com_support_index]);
1315 return (CSA_SUCCESS);
1319 _handle_com_support_ext(CSA_extension *ext)
1322 CSA_X_COM_support *xcom;
1324 for (i = 0, xcom = ext->item_reference; i < ext->item_data; i++) {
1325 switch (xcom[i].item_code) {
1326 case CSA_X_COM_SUPPORT_EXT:
1327 case CSA_X_XT_APP_CONTEXT_EXT:
1329 case CSA_X_DT_GET_USER_ACCESS_EXT:
1330 xcom[i].flags = CSA_X_COM_SUPPORTED;
1334 case CSA_X_UI_ID_EXT:
1336 xcom[i].flags = CSA_X_COM_NOT_SUPPORTED;