]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/UserNotification/KUNCUserNotifications.c
xnu-792.17.14.tar.gz
[apple/xnu.git] / osfmk / UserNotification / KUNCUserNotifications.c
index b53ff7aa657de09238936bade126c6962e2758c9..f3a831af54844d9656d3eb4b249fab28e1cb70ca 100644 (file)
@@ -1,16 +1,19 @@
 /*
- * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2004 Apple Computer, 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
  * 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 <mach/port.h>
 #include <mach/message.h>
 #include <mach/kern_return.h>
-#include <mach/etap_events.h>
+#include <mach/host_priv.h>
 
+#include <kern/kern_types.h>
+#include <kern/kalloc.h>
 #include <kern/host.h>
-#include <ipc/ipc_port.h>
 #include <kern/ipc_kobject.h>
 
+#include <ipc/ipc_port.h>
+
 #include <UserNotification/UNDTypes.h>
 #include <UserNotification/UNDRequest.h>
 #include <UserNotification/UNDReplyServer.h>
@@ -59,6 +65,11 @@ struct UNDReply {
 #define UNDReply_lock_try(reply)       mutex_lock_try(&(reply)->lock)
 #define UNDReply_unlock(reply)         mutex_unlock(&(reply)->lock)
 
+/* forward declarations */
+void UNDReply_deallocate(
+       UNDReplyRef             reply);
+
+
 void
 UNDReply_deallocate(
        UNDReplyRef             reply)
@@ -73,7 +84,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;
 }
 
@@ -111,7 +122,7 @@ UNDAlertCompletedWithResult_rpc (
        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)
@@ -185,10 +196,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);
+                       mutex_init(&reply->lock, 0);
                        reply->userLandNotificationKey = -1;
                        reply->inprogress = FALSE;
                        ipc_kobject_set(reply->self_port,
@@ -232,7 +243,7 @@ kern_return_t KUNCUserNotificationCancel(
        }
 
        reply->inprogress = FALSE;
-       if (ulkey = reply->userLandNotificationKey) {
+       if ((ulkey = reply->userLandNotificationKey) != 0) {
                UNDServerRef UNDServer;
 
                reply->userLandNotificationKey = 0;
@@ -254,7 +265,7 @@ kern_return_t KUNCUserNotificationCancel(
 
 kern_return_t
 KUNCUserNotificationDisplayNotice(
-       int             timeout,
+       int             noticeTimeout,
        unsigned        flags,
        char            *iconPath,
        char            *soundPath,
@@ -269,7 +280,7 @@ KUNCUserNotificationDisplayNotice(
        if (IP_VALID(UNDServer)) {
                kern_return_t kr;
                kr = UNDDisplayNoticeSimple_rpc(UNDServer,
-                                       timeout,
+                                       noticeTimeout,
                                        flags,
                                        iconPath,
                                        soundPath,
@@ -285,7 +296,7 @@ KUNCUserNotificationDisplayNotice(
 
 kern_return_t
 KUNCUserNotificationDisplayAlert(
-       int             timeout,
+       int             alertTimeout,
        unsigned        flags,
        char            *iconPath,
        char            *soundPath,
@@ -303,7 +314,7 @@ KUNCUserNotificationDisplayAlert(
        if (IP_VALID(UNDServer)) {
                kern_return_t   kr;
                kr = UNDDisplayAlertSimple_rpc(UNDServer,
-                                      timeout,
+                                      alertTimeout,
                                       flags,
                                       iconPath,
                                       soundPath,
@@ -329,7 +340,7 @@ KUNCUserNotificationDisplayFromBundle(
        char                         *messageKey,
        char                         *tokenString,
        KUNCUserNotificationCallBack callback,
-       int                          contextKey)
+       __unused int                    contextKey)
 {
        UNDReplyRef reply = (UNDReplyRef)id;
        UNDServerRef UNDServer;
@@ -342,7 +353,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);