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 librararies 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;
355 DP(("api.c: csa_list_entries\n"));
357 if (entries == NULL || number_entries == NULL)
358 return (CSA_E_INVALID_PARAMETER);
364 /* check list_entries_extensions
365 * and return appropriate return code
366 * no function extension is supported
368 if (list_entries_extensions != NULL)
369 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
371 /* get calendar object */
372 if ((cal = _DtCm_get_Calendar(session)) == NULL)
373 return (CSA_E_INVALID_SESSION_HANDLE);
375 if (list_operators && (stat = _DtCm_check_operator(number_attributes,
376 entry_attributes, NULL, list_operators)) != CSA_SUCCESS) {
381 /* check data type */
382 if ((stat = _DtCm_check_entry_attributes(cal->file_version,
383 number_attributes, entry_attributes, 0, B_FALSE)) != CSA_SUCCESS) {
385 * if attribute not supported by old backends
386 * are specified, just fail the match,
387 * i.e. return NULL and CSA_SUCCESS
389 if (stat == CSA_E_UNSUPPORTED_ATTRIBUTE)
396 if ((stat = _DtCm_rpc_lookup_entries(cal, number_attributes,
397 entry_attributes, list_operators, &elist)) == CSA_SUCCESS) {
400 *number_entries = _DtCm_add_to_entry_list(cal, (caddr_t)elist);
401 stat = _DtCm_libentry_to_entryh(elist, number_entries,
409 extern CSA_return_code
410 csa_list_entry_attributes(
411 CSA_session_handle session,
412 CSA_entry_handle entryh,
413 CSA_uint32 *number_names,
414 CSA_attribute_reference **entry_attribute_names,
415 CSA_extension *list_entry_attributes_extensions)
417 CSA_return_code stat;
418 _DtCm_libentry *entry;
420 DP(("api.c: csa_list_entry_attributes\n"));
422 if (number_names == NULL || entry_attribute_names == NULL)
423 return (CSA_E_INVALID_PARAMETER);
425 /* check list_entry_attributes_extensions
426 * and return appropriate return code
427 * no function extension is supported
429 if (list_entry_attributes_extensions != NULL)
430 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
432 /* get appointment */
433 if ((entry = _DtCm_get_libentry(entryh)) == NULL)
434 return (CSA_E_INVALID_ENTRY_HANDLE);
436 if ((stat = _DtCm_get_entry_detail(entry)) != CSA_SUCCESS)
439 return (_DtCm_get_entry_attr_names(entry, number_names,
440 entry_attribute_names));
444 extern CSA_return_code
445 csa_read_entry_attributes(
446 CSA_session_handle session,
447 CSA_entry_handle entryh,
448 CSA_uint32 number_names,
449 CSA_attribute_reference *attribute_names,
450 CSA_uint32 *number_attributes,
451 CSA_attribute **entry_attributes,
452 CSA_extension *read_entry_attributes_extensions)
454 CSA_return_code stat;
455 _DtCm_libentry *entry;
458 DP(("api.c: csa_read_entry_attributes\n"));
460 if (number_attributes == 0 || entry_attributes == NULL)
461 return (CSA_E_INVALID_PARAMETER);
463 /* check read_entry_attributes_extensions
464 * and return appropriate return code
465 * no function extension is supported
467 if (read_entry_attributes_extensions != NULL)
468 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
470 /* get entry object */
471 if ((entry = _DtCm_get_libentry(entryh)) == NULL)
472 return (CSA_E_INVALID_ENTRY_HANDLE);
474 if ((stat = _DtCm_get_entry_detail(entry)) != CSA_SUCCESS)
477 if (number_names > 0) {
478 return (_DtCm_get_entry_attrs_by_name(entry, number_names,
479 attribute_names, number_attributes, entry_attributes));
481 return (_DtCm_get_all_entry_attrs(entry, number_attributes,
486 extern CSA_return_code
487 csa_free(CSA_buffer memory)
489 DP(("api.c: csa_free\n"));
491 return (_DtCm_free(memory));
494 extern CSA_return_code
496 CSA_session_handle session,
497 CSA_calendar_user *users,
498 CSA_flags look_up_flags,
499 CSA_uint32 *number_users,
500 CSA_calendar_user **user_list,
501 CSA_extension *look_up_extensions)
503 DP(("api.c: csa_look_up\n"));
505 return (CSA_E_NOT_SUPPORTED);
508 extern CSA_return_code
509 csa_query_configuration(
510 CSA_session_handle session,
512 CSA_buffer *reference,
513 CSA_extension *query_configuration_extensions)
515 CSA_return_code stat = CSA_SUCCESS;
517 DP(("api.c: csa_query_configuration\n"));
519 /* get calendar object */
520 if ((cal = _DtCm_get_Calendar(session)) == NULL)
521 return (CSA_E_INVALID_SESSION_HANDLE);
523 if (item < CSA_CONFIG_CHARACTER_SET || item > CSA_CONFIG_VER_SPEC)
524 return (CSA_E_INVALID_ENUM);
526 if (reference == NULL)
527 return (CSA_E_INVALID_PARAMETER);
529 if (query_configuration_extensions) {
530 if ((stat = _handle_query_config_ext(
531 query_configuration_extensions)) != CSA_SUCCESS)
536 case CSA_CONFIG_DEFAULT_SERVICE:
537 case CSA_CONFIG_DEFAULT_USER:
541 case CSA_CONFIG_REQ_PASSWORD:
542 *reference = (CSA_buffer)CSA_REQUIRED_NO;
545 case CSA_CONFIG_REQ_SERVICE:
546 case CSA_CONFIG_REQ_USER:
547 *reference = (CSA_buffer)CSA_REQUIRED_YES;
550 case CSA_CONFIG_UI_AVAIL:
551 *reference = (CSA_buffer)CSA_FALSE;
554 case CSA_CONFIG_VER_SPEC:
555 *reference = (CSA_buffer)strdup(_DtCM_SPEC_VERSION_SUPPORTED);
558 case CSA_CONFIG_CHARACTER_SET:
559 case CSA_CONFIG_LINE_TERM:
560 case CSA_CONFIG_VER_IMPLEM:
561 stat = CSA_E_UNSUPPORTED_ENUM;
567 extern CSA_return_code
568 csa_read_calendar_attributes(
569 CSA_session_handle session,
570 CSA_uint32 number_names,
571 CSA_attribute_reference *attribute_names,
572 CSA_uint32 *number_attributes,
573 CSA_attribute **calendar_attributes,
574 CSA_extension *read_calendar_attributes_extensions)
576 CSA_return_code stat;
580 DP(("api.c: csa_read_calendar_attributes\n"));
582 if (number_attributes == 0 || calendar_attributes == NULL)
583 return (CSA_E_INVALID_PARAMETER);
585 /* check read_calendar_attributes_extensions
586 * and return appropriate return code
587 * no function extension is supported
589 if (read_calendar_attributes_extensions != NULL)
590 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
592 /* get calendar object */
593 if ((cal = _DtCm_get_Calendar(session)) == NULL)
594 return (CSA_E_INVALID_SESSION_HANDLE);
596 _DtCm_reset_cal_attrs(cal);
597 if (number_names > 0) {
598 return (_DtCm_get_cal_attrs_by_name(cal, number_names,
599 attribute_names, number_attributes,
600 calendar_attributes));
602 return (_DtCm_get_all_cal_attrs(cal, number_attributes,
603 calendar_attributes));
607 extern CSA_return_code
608 csa_register_callback(
609 CSA_session_handle session,
611 CSA_callback callback,
612 CSA_buffer client_data,
613 CSA_extension *register_callback_extensions)
615 CSA_return_code stat = CSA_SUCCESS;
616 _DtCmCallbackEntry *cb_entry;
618 boolean_t async = B_FALSE;
620 /* get calendar object */
621 if ((cal = _DtCm_get_Calendar(session)) == NULL)
622 return (CSA_E_INVALID_SESSION_HANDLE);
624 /* make sure some valid flags are set
625 * and only entry added, deleted or updated is specified for
626 * servers support up to version 4 rpc protocol
628 if (reason == 0 || reason >= (CSA_CB_ENTRY_UPDATED << 1) ||
629 (cal->rpc_version < _DtCM_FIRST_EXTENSIBLE_SERVER_VERSION &&
630 (reason & ~(CSA_CB_ENTRY_ADDED|CSA_CB_ENTRY_DELETED|
631 CSA_CB_ENTRY_UPDATED))))
632 return (CSA_E_INVALID_FLAG);
634 /* must specify a callback function otherwise
635 * there is no point to make this call
637 if (callback == NULL)
638 return (CSA_E_INVALID_PARAMETER);
640 /* need to initialize agent before doing XtAppAddInput */
643 if (register_callback_extensions != NULL) {
644 if ((stat = _handle_register_callback_ext(
645 register_callback_extensions)) != CSA_SUCCESS)
652 * register interest only if we have a new flag
653 * NOTE: It's OK to register more than once, even if it's
654 * the same calendar, same reason. The customer is always right.
656 if (((cal->all_reasons | reason) ^ cal->all_reasons) &&
657 (stat = _DtCm_rpc_register_client(cal, reason)) != CSA_SUCCESS)
660 if ((cb_entry = (_DtCmCallbackEntry*)malloc(sizeof(_DtCmCallbackEntry)))
662 return (CSA_E_INSUFFICIENT_MEMORY);
664 /* update info in calendar structure */
665 cal->all_reasons |= reason;
667 /* don't just do cal->async_process = async, since cal->async_process
668 * might have been set to B_TRUE before.
671 cal->async_process = B_TRUE;
672 if (cal->async_process == B_TRUE)
673 cal->do_reasons = cal->all_reasons;
675 /* fill in the callback record */
676 cb_entry->reason = reason;
677 cb_entry->handler = callback;
678 cb_entry->client_data = client_data;
680 /* insert it at head of list */
681 cb_entry->next = cal->cb_list;
682 cb_entry->prev = (_DtCmCallbackEntry*) NULL;
683 if (cal->cb_list != (_DtCmCallbackEntry*) NULL)
684 cal->cb_list->prev = cb_entry;
685 cal->cb_list = cb_entry;
691 * csa_unregister_callback
693 * removes a previsouly registered callback from the callback list
694 * of the specified calendar.
696 extern CSA_return_code
697 csa_unregister_callback(
698 CSA_session_handle session,
700 CSA_callback handler,
701 CSA_buffer client_data,
702 CSA_extension *unregister_callback_extensions)
705 boolean_t match_one = B_FALSE;
706 boolean_t match_all = B_FALSE;
708 CSA_flags all = 0, unreg;
709 _DtCmCallbackEntry *cb, *ncb;
711 /* get calendar object */
712 if ((cal = _DtCm_get_Calendar(session)) == NULL)
713 return (CSA_E_INVALID_SESSION_HANDLE);
715 if (reason == 0 || reason >= (CSA_CB_ENTRY_UPDATED << 1))
716 return (CSA_E_INVALID_FLAG);
718 /* check unregister_callback_extensions
719 * and return appropriate return code
720 * no function extension is supported
722 if (unregister_callback_extensions != NULL)
723 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
725 if (handler == NULL && client_data == NULL)
727 else if (handler == NULL) /* but client data is not NULL */
728 return (CSA_E_INVALID_PARAMETER);
731 * Removal policy: If both handler and client data are NULL,
732 * match all callbacks for the specified reason.
733 * Otherwise, all of reason, handler and client data must
741 if (!(reason & cb->reason) ||
742 (match_all == B_FALSE && (handler != cb->handler ||
743 client_data != cb->client_data))) {
744 all = all | cb->reason;
751 if (cb->reason = (cb->reason | reason) ^ reason) {
752 all = all | cb->reason;
755 if (cb->prev != NULL)
756 cb->prev->next = cb->next;
757 if (cb->next != NULL)
758 cb->next->prev = cb->prev;
759 if (cb == cal->cb_list)
760 cal->cb_list = cb->next;
767 unreg = all ^ cal->all_reasons;
768 cal->all_reasons = all;
771 (void) _DtCm_rpc_unregister_client(cal, unreg);
773 if (match_one == B_TRUE)
774 return (CSA_SUCCESS);
776 return (CSA_E_CALLBACK_NOT_REGISTERED);
781 CSA_session_handle session,
783 CSA_extension *call_callbacks_extensions)
787 DP(("api.c: csa_call_callbacks\n"));
789 /* get calendar object */
790 if ((cal = _DtCm_get_Calendar(session)) == NULL)
791 return (CSA_E_INVALID_SESSION_HANDLE);
793 /* no function extension is supported */
794 if (call_callbacks_extensions != NULL)
795 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
797 /* set up information in calendar structure */
798 if (cal->async_process == B_FALSE)
799 cal->do_reasons = reason;
801 /* trigger callback mechanism */
802 _DtCm_process_updates();
804 if (cal->async_process == B_FALSE)
807 return (CSA_SUCCESS);
810 extern CSA_return_code
811 csa_update_calendar_attributes(
812 CSA_session_handle session,
813 CSA_uint32 num_attrs,
814 CSA_attribute *attrs,
815 CSA_extension *update_calendar_attributes_extensions)
817 CSA_return_code stat = CSA_SUCCESS;
821 DP(("api.c: csa_update_calendar_attributes\n"));
823 /* get calendar object */
824 if ((cal = _DtCm_get_Calendar(session)) == NULL)
825 return (CSA_E_INVALID_SESSION_HANDLE);
827 if (num_attrs == 0 || attrs == NULL)
828 return (CSA_E_INVALID_PARAMETER);
831 * check update_calendar_attributes_extensions
832 * return appropriate return code
833 * no function extension is supported
835 if (update_calendar_attributes_extensions != NULL)
836 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
838 /* check authority */
839 if ((cal->file_version >= _DtCM_FIRST_EXTENSIBLE_DATA_VERSION &&
840 !(cal->access & (CSA_OWNER_RIGHTS | CSA_INSERT_CALENDAR_ATTRIBUTES |
841 CSA_CHANGE_CALENDAR_ATTRIBUTES))) ||
842 (cal->file_version < _DtCM_FIRST_EXTENSIBLE_DATA_VERSION &&
843 !(cal->access & CSA_OWNER_RIGHTS)))
844 return (CSA_E_NO_AUTHORITY);
846 /* check data type */
847 if ((stat = _DtCm_check_cal_csa_attributes(cal->file_version,
848 num_attrs, attrs, cal->name, B_TRUE, B_FALSE, B_TRUE))
854 stat = _DtCm_rpc_set_cal_attrs(cal, num_attrs, attrs);
859 extern CSA_return_code
861 CSA_session_handle session,
862 CSA_uint32 num_attrs,
863 CSA_attribute *attrs,
864 CSA_entry_handle *entry_r,
865 CSA_extension *add_entry_extensions)
867 CSA_return_code stat;
869 _DtCm_libentry *entry;
871 DP(("api.c: csa_add_entry\n"));
873 if (num_attrs == 0 || attrs == NULL)
874 return (CSA_E_INVALID_PARAMETER);
876 /* get calendar object */
877 if ((cal = _DtCm_get_Calendar(session)) == NULL)
878 return (CSA_E_INVALID_SESSION_HANDLE);
880 /* check data type, readonly attributes, etc */
881 if ((stat = _DtCm_check_entry_attributes(cal->file_version,
882 num_attrs, attrs, CSA_CB_ENTRY_ADDED, B_TRUE)) != CSA_SUCCESS) {
886 /* no function extension is supported */
887 if (add_entry_extensions != NULL)
888 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
890 /* insert in calendar */
891 if ((stat = _DtCm_rpc_insert_entry(cal, num_attrs, attrs, &entry))
894 if (entry_r != NULL) {
895 if ((entry = _DtCm_convert_entry_wheader(entry))==NULL)
896 stat = CSA_E_INSUFFICIENT_MEMORY;
898 _DtCm_add_to_entry_list(cal, (caddr_t)entry);
899 *entry_r = (CSA_entry_handle)entry;
902 _DtCm_free_libentries(entry);
909 * The session argument is ignored in this implementation.
911 extern CSA_return_code
913 CSA_session_handle session,
914 CSA_entry_handle entryh,
915 CSA_enum delete_scope,
916 CSA_extension *delete_entry_extensions)
918 CSA_return_code stat;
919 _DtCm_libentry *entry;
922 DP(("api.c: csa_delete_entry\n"));
924 /* get entry object */
925 if ((entry = _DtCm_get_libentry(entryh)) == NULL)
926 return (CSA_E_INVALID_ENTRY_HANDLE);
928 if (delete_scope < CSA_SCOPE_ALL || delete_scope > CSA_SCOPE_FORWARD)
929 return (CSA_E_INVALID_ENUM);
931 /* check delete_entry_extensions and return appropriate return code */
932 /* no function extension is supported */
933 if (delete_entry_extensions != NULL)
934 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
936 /* delete entry from calendar */
937 stat = _DtCm_rpc_delete_entry(entry->cal, entry, delete_scope);
942 extern CSA_return_code
943 csa_free_time_search(
944 CSA_session_handle session,
945 CSA_date_time_range date_time_range,
946 CSA_time_duration time_duration,
947 CSA_uint32 number_users,
948 CSA_calendar_user *users,
949 CSA_free_time **free_time,
950 CSA_extension *free_time_search_extensions)
952 DP(("api.c: csa_free_time_search\n"));
954 return (CSA_E_NOT_SUPPORTED);
957 extern CSA_return_code
958 csa_list_entry_sequence(
959 CSA_session_handle session,
960 CSA_entry_handle entryh,
961 CSA_date_time_range time_range,
962 CSA_uint32 *number_entries,
963 CSA_entry_handle **entries,
964 CSA_extension *list_entry_sequence_extensions)
966 CSA_return_code stat;
967 _DtCm_libentry *entry, *elist;
968 cms_attribute *rtype;
969 cms_attribute *rtimes;
970 /* needed temporaryly */
971 time_t start = 0, end = 0;
974 DP(("api.c: csa_list_entry_sequence\n"));
976 /* get entry object */
977 if ((entry = _DtCm_get_libentry(entryh)) == NULL)
978 return (CSA_E_INVALID_ENTRY_HANDLE);
980 if (number_entries == NULL || entries == NULL)
981 return (CSA_E_INVALID_PARAMETER);
987 /* check whether this entry repeats */
988 /* fail it if it's not a repeating event */
989 if (entry->cal->file_version < _DtCM_FIRST_EXTENSIBLE_DATA_VERSION) {
990 rtype = &entry->e->attrs[CSA_X_DT_ENTRY_ATTR_REPEAT_TYPE_I];
991 if (rtype->value == NULL ||
992 rtype->value->item.sint32_value == CSA_X_DT_REPEAT_ONETIME)
994 return (CSA_E_INVALID_PARAMETER);
997 rtype = &entry->e->attrs[CSA_ENTRY_ATTR_RECURRENCE_RULE_I];
998 if (rtype->value == NULL ||
999 rtype->value->item.string_value == NULL ||
1000 *(rtype->value->item.string_value) == NULL) {
1001 return (CSA_E_INVALID_PARAMETER);
1006 /* if this entry repeats indefinitely and time range is not
1007 * specified, fail it
1010 if (_csa_iso8601_to_range(time_range, &start, &end) != 0)
1011 return (CSA_E_INVALID_DATE_TIME);
1014 if (entry->cal->file_version < _DtCM_FIRST_EXTENSIBLE_DATA_VERSION)
1015 rtimes = &entry->e->attrs[CSA_X_DT_ENTRY_ATTR_REPEAT_TIMES_I];
1017 rtimes = &entry->e->attrs[CSA_ENTRY_ATTR_NUMBER_RECURRENCES_I];
1019 if (start == 0 && end == 0 &&
1020 (rtimes->value && rtimes->value->item.uint32_value
1021 == CSA_X_DT_DT_REPEAT_FOREVER))
1022 return (CSA_E_INVALID_PARAMETER);
1024 /* no function extension is supported */
1025 if (list_entry_sequence_extensions != NULL)
1026 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
1028 /* lookup sequence */
1029 if ((stat = _DtCm_rpc_enumerate_sequence(entry->cal, entry, start, end,
1030 &elist)) == CSA_SUCCESS) {
1033 *number_entries = _DtCm_add_to_entry_list(entry->cal,
1035 stat = _DtCm_libentry_to_entryh(elist, number_entries,
1044 * Due to the implementation of existing backends (versions 2-4)
1045 * which will unmanage any reminders that happens before the
1046 * the given tick, the user specified tick is ignore and
1047 * we will pass in the current time.
1049 extern CSA_return_code
1050 csa_read_next_reminder(
1051 CSA_session_handle session,
1052 CSA_uint32 number_names,
1053 CSA_attribute_reference *reminder_names,
1054 CSA_date_time given_time,
1055 CSA_uint32 *number_reminders,
1056 CSA_reminder_reference **reminders,
1057 CSA_extension *read_next_reminder_extensions)
1059 CSA_return_code stat;
1061 _DtCm_libentry *eptr, *prev = NULL, *head = NULL;
1062 CSA_reminder_reference * rlist;
1066 DP(("api.c: csa_read_next_reminder\n"));
1068 /* get calendar object */
1069 if ((cal = _DtCm_get_Calendar(session)) == NULL)
1070 return (CSA_E_INVALID_SESSION_HANDLE);
1072 if (number_reminders == 0 || reminders == NULL)
1073 return (CSA_E_INVALID_PARAMETER);
1075 if (given_time == NULL || _csa_iso8601_to_tick(given_time, &timeval))
1076 return (CSA_E_INVALID_DATE_TIME);
1079 * check read_next_reminder_extensions and
1080 * return appropriate return code
1081 * no function extension is supported
1083 if (read_next_reminder_extensions != NULL)
1084 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
1086 /* lookup reminders */
1087 if ((stat = _DtCm_rpc_lookup_reminder(cal, timeval,
1088 number_names, reminder_names, number_reminders, reminders))
1092 * link up all associated entries
1093 * and add to calendar structure
1095 for (i = 0; i < *number_reminders; i++) {
1096 eptr = (_DtCm_libentry *)((*reminders)[i]).entry;
1098 /* link entry back to cal */
1101 /* link up entries in the same order as
1102 * the associated reminders
1114 (void)_DtCm_add_to_entry_list(cal, (caddr_t)head);
1121 * These arguments are ignored in this implementation:
1122 * session, update_propagation
1124 extern CSA_return_code
1125 csa_update_entry_attributes(
1126 CSA_session_handle session,
1127 CSA_entry_handle entry,
1129 CSA_boolean update_propagation,
1130 CSA_uint32 num_attrs,
1131 CSA_attribute *attrs,
1132 CSA_entry_handle *new_entry,
1133 CSA_extension *update_entry_attributes_extensions)
1135 CSA_return_code stat;
1136 _DtCm_libentry *oentry, *tptr, *nentry;
1138 DP(("api.c: csa_update_entry_attributes\n"));
1140 /* get entry object */
1141 if ((oentry = _DtCm_get_libentry(entry)) == NULL)
1142 return (CSA_E_INVALID_ENTRY_HANDLE);
1144 if (scope < CSA_SCOPE_ALL || scope > CSA_SCOPE_FORWARD)
1145 return (CSA_E_INVALID_ENUM);
1147 if (num_attrs == 0 || attrs == NULL)
1148 return (CSA_E_INVALID_PARAMETER);
1151 * check update_entry_attributes_extensions and
1152 * return appropriate return code
1153 * no function extension is supported
1155 if (update_entry_attributes_extensions != NULL)
1156 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
1158 /* check data type, readonly attributes, etc */
1159 if ((stat = _DtCm_check_entry_attributes(oentry->cal->file_version,
1160 num_attrs, attrs, CSA_CB_ENTRY_UPDATED, B_TRUE)) != CSA_SUCCESS) {
1164 /* change entry in calendar */
1165 if ((stat = _DtCm_rpc_update_entry(oentry->cal, oentry, num_attrs,
1166 attrs, scope, &nentry)) == CSA_SUCCESS) {
1168 if ((nentry = _DtCm_convert_entry_wheader(nentry))
1170 stat = CSA_E_INSUFFICIENT_MEMORY;
1172 _DtCm_add_to_entry_list(oentry->cal,
1174 *new_entry = (CSA_entry_handle)nentry;
1177 _DtCm_free_libentries(nentry);
1184 extern CSA_return_code
1186 CSA_service_reference calendar_service,
1187 CSA_string calendar_address,
1188 CSA_string logon_user,
1189 CSA_string logon_password,
1190 CSA_string attendee,
1191 CSA_enum attendee_priority,
1192 CSA_enum attendee_status,
1193 CSA_boolean attendee_rsvp_requested,
1194 CSA_date_time start_date,
1195 CSA_date_time end_date,
1196 CSA_string organizer,
1199 CSA_string description,
1200 CSA_string recurrence_rule,
1201 CSA_string exception_rule,
1203 CSA_enum classification,
1204 CSA_string delimiters,
1205 CSA_string add_event_extensions)
1207 DP(("api.c: csa_add_event\n"));
1209 return (CSA_E_NOT_SUPPORTED);
1215 CSA_service_reference calendar_service,
1216 CSA_string calendar_address,
1217 CSA_string logon_user,
1218 CSA_string logon_password,
1219 CSA_enum attendee_priority,
1220 CSA_enum attendee_status,
1221 CSA_boolean attendee_rsvp_requested,
1222 CSA_date_time start_date,
1223 CSA_date_time due_date,
1224 CSA_uint32 priority,
1226 CSA_string description,
1227 CSA_enum classification,
1228 CSA_string delimiters,
1229 CSA_string add_todo_extensions)
1231 DP(("api.c: csa_add_todo\n"));
1233 return (CSA_E_NOT_SUPPORTED);
1239 CSA_service_reference calendar_service,
1240 CSA_string calendar_address,
1241 CSA_string logon_user,
1242 CSA_string logon_password,
1243 CSA_date_time start_date,
1245 CSA_string delimiters,
1246 CSA_string add_memo_extensions)
1248 DP(("api.c: csa_add_memo\n"));
1250 return (CSA_E_NOT_SUPPORTED);
1253 /******************************************************************************
1254 * static functions used within in the file
1255 ******************************************************************************/
1257 static CSA_return_code
1258 _handle_register_callback_ext(CSA_extension *ext)
1262 for (i = 0; ; i++) {
1263 if (ext[i].item_code == CSA_X_XT_APP_CONTEXT_EXT) {
1264 _DtCm_register_xtcallback(
1265 (XtAppContext)ext[i].item_data);
1267 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
1269 if (ext[i].extension_flags & CSA_EXT_LAST_ELEMENT)
1273 return (CSA_SUCCESS);
1276 static CSA_return_code
1277 _handle_logon_ext(CSA_extension *ext, CSA_extension **pext)
1280 int get_access_index = -1;
1281 int com_support_index = -1;
1283 for (i = 0; ; i++) {
1284 if (ext[i].item_code == CSA_X_DT_GET_USER_ACCESS_EXT)
1285 get_access_index = i;
1286 else if (ext[i].item_code == CSA_X_COM_SUPPORT_EXT)
1287 com_support_index = i;
1289 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
1291 if (ext[i].extension_flags & CSA_EXT_LAST_ELEMENT)
1295 if (get_access_index >= 0)
1296 *pext = &ext[get_access_index];
1298 if (com_support_index >= 0)
1299 _handle_com_support_ext(&ext[com_support_index]);
1301 return (CSA_SUCCESS);
1304 static CSA_return_code
1305 _handle_query_config_ext(CSA_extension *ext)
1308 int com_support_index = -1;
1310 for (i = 0; ; i++) {
1311 if (ext[i].item_code == CSA_X_COM_SUPPORT_EXT) {
1312 com_support_index = i;
1314 return (CSA_E_UNSUPPORTED_FUNCTION_EXT);
1316 if (ext[i].extension_flags & CSA_EXT_LAST_ELEMENT)
1320 if (com_support_index >= 0)
1321 _handle_com_support_ext(&ext[com_support_index]);
1323 return (CSA_SUCCESS);
1327 _handle_com_support_ext(CSA_extension *ext)
1330 CSA_X_COM_support *xcom;
1332 for (i = 0, xcom = ext->item_reference; i < ext->item_data; i++) {
1333 switch (xcom[i].item_code) {
1334 case CSA_X_COM_SUPPORT_EXT:
1335 case CSA_X_XT_APP_CONTEXT_EXT:
1337 case CSA_X_DT_GET_USER_ACCESS_EXT:
1338 xcom[i].flags = CSA_X_COM_SUPPORTED;
1342 case CSA_X_UI_ID_EXT:
1344 xcom[i].flags = CSA_X_COM_NOT_SUPPORTED;