X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/55e303ae13a4cf49d70f2294092726f2fffb9ef2..d41d1dae2cd00cc08c7982087d1c445180cad9f5:/osfmk/UserNotification/KUNCUserNotifications.c diff --git a/osfmk/UserNotification/KUNCUserNotifications.c b/osfmk/UserNotification/KUNCUserNotifications.c index b53ff7aa6..740b8f125 100644 --- a/osfmk/UserNotification/KUNCUserNotifications.c +++ b/osfmk/UserNotification/KUNCUserNotifications.c @@ -1,16 +1,19 @@ /* - * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2006 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ - * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER @@ -20,18 +23,21 @@ * Please see the License for the specific language governing rights and * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ #include #include #include -#include +#include +#include +#include #include -#include #include +#include + #include #include #include @@ -48,16 +54,20 @@ */ struct UNDReply { - decl_mutex_data(,lock) /* UNDReply lock */ + decl_lck_mtx_data(,lock) /* UNDReply lock */ int userLandNotificationKey; KUNCUserNotificationCallBack callback; boolean_t inprogress; ipc_port_t self_port; /* Our port */ }; -#define UNDReply_lock(reply) mutex_lock(&reply->lock) -#define UNDReply_lock_try(reply) mutex_lock_try(&(reply)->lock) -#define UNDReply_unlock(reply) mutex_unlock(&(reply)->lock) +#define UNDReply_lock(reply) lck_mtx_lock(&reply->lock) +#define UNDReply_unlock(reply) lck_mtx_lock(&reply->lock) + +/* forward declarations */ +void UNDReply_deallocate( + UNDReplyRef reply); + void UNDReply_deallocate( @@ -73,7 +83,7 @@ UNDReply_deallocate( UNDReply_unlock(reply); ipc_port_dealloc_kernel(port); - kfree((vm_offset_t)reply, sizeof(struct UNDReply)); + kfree(reply, sizeof(struct UNDReply)); return; } @@ -105,13 +115,17 @@ UNDAlertCompletedWithResult_rpc ( UNDReplyRef reply, int result, xmlData_t keyRef, /* raw XML bytes */ +#ifdef KERNEL_CF mach_msg_type_number_t keyLen) +#else + __unused mach_msg_type_number_t keyLen) +#endif { #ifdef KERNEL_CF CFStringRef xmlError = NULL; CFDictionaryRef dict = NULL; #else - void *dict = (void *)keyRef; + const void *dict = (const void *)keyRef; #endif if (reply == UND_REPLY_NULL || !reply->inprogress) @@ -134,7 +148,7 @@ UNDAlertCompletedWithResult_rpc ( #endif /* KERNEL_CF */ if (reply->callback) { - (reply->callback)((KUNCUserNotificationID) reply, result, dict); + (reply->callback)((int)(KUNCUserNotificationID)reply, result, dict); } UNDReply_lock(reply); @@ -175,9 +189,10 @@ UNDNotificationCreated_rpc ( * KUNC Functions */ +extern lck_grp_t LockCompatGroup; KUNCUserNotificationID -KUNCGetNotificationID() +KUNCGetNotificationID(void) { UNDReplyRef reply; @@ -185,10 +200,10 @@ KUNCGetNotificationID() if (reply != UND_REPLY_NULL) { reply->self_port = ipc_port_alloc_kernel(); if (reply->self_port == IP_NULL) { - kfree((vm_offset_t)reply, sizeof(struct UNDReply)); + kfree(reply, sizeof(struct UNDReply)); reply = UND_REPLY_NULL; } else { - mutex_init(&reply->lock, ETAP_IO_UNDREPLY); + lck_mtx_init(&reply->lock, &LockCompatGroup, LCK_ATTR_NULL); reply->userLandNotificationKey = -1; reply->inprogress = FALSE; ipc_kobject_set(reply->self_port, @@ -232,7 +247,7 @@ kern_return_t KUNCUserNotificationCancel( } reply->inprogress = FALSE; - if (ulkey = reply->userLandNotificationKey) { + if ((ulkey = reply->userLandNotificationKey) != 0) { UNDServerRef UNDServer; reply->userLandNotificationKey = 0; @@ -254,7 +269,7 @@ kern_return_t KUNCUserNotificationCancel( kern_return_t KUNCUserNotificationDisplayNotice( - int timeout, + int noticeTimeout, unsigned flags, char *iconPath, char *soundPath, @@ -269,7 +284,7 @@ KUNCUserNotificationDisplayNotice( if (IP_VALID(UNDServer)) { kern_return_t kr; kr = UNDDisplayNoticeSimple_rpc(UNDServer, - timeout, + noticeTimeout, flags, iconPath, soundPath, @@ -285,7 +300,7 @@ KUNCUserNotificationDisplayNotice( kern_return_t KUNCUserNotificationDisplayAlert( - int timeout, + int alertTimeout, unsigned flags, char *iconPath, char *soundPath, @@ -303,7 +318,7 @@ KUNCUserNotificationDisplayAlert( if (IP_VALID(UNDServer)) { kern_return_t kr; kr = UNDDisplayAlertSimple_rpc(UNDServer, - timeout, + alertTimeout, flags, iconPath, soundPath, @@ -329,7 +344,7 @@ KUNCUserNotificationDisplayFromBundle( char *messageKey, char *tokenString, KUNCUserNotificationCallBack callback, - int contextKey) + __unused int contextKey) { UNDReplyRef reply = (UNDReplyRef)id; UNDServerRef UNDServer; @@ -342,7 +357,7 @@ KUNCUserNotificationDisplayFromBundle( UNDReply_unlock(reply); return KERN_INVALID_ARGUMENT; } - reply->inprogress == TRUE; + reply->inprogress = TRUE; reply->callback = callback; reply_port = ipc_port_make_send(reply->self_port); UNDReply_unlock(reply);