]> 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 aec492ca7cc08c3f29b9f1bfa13482ef66431ecb..f3a831af54844d9656d3eb4b249fab28e1cb70ca 100644 (file)
@@ -1,34 +1,43 @@
 /*
- * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * 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. 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.
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * 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>
@@ -56,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)
@@ -70,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;
 }
 
@@ -108,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)
@@ -182,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,
@@ -229,7 +243,7 @@ kern_return_t KUNCUserNotificationCancel(
        }
 
        reply->inprogress = FALSE;
-       if (ulkey = reply->userLandNotificationKey) {
+       if ((ulkey = reply->userLandNotificationKey) != 0) {
                UNDServerRef UNDServer;
 
                reply->userLandNotificationKey = 0;
@@ -251,7 +265,7 @@ kern_return_t KUNCUserNotificationCancel(
 
 kern_return_t
 KUNCUserNotificationDisplayNotice(
-       int             timeout,
+       int             noticeTimeout,
        unsigned        flags,
        char            *iconPath,
        char            *soundPath,
@@ -266,7 +280,7 @@ KUNCUserNotificationDisplayNotice(
        if (IP_VALID(UNDServer)) {
                kern_return_t kr;
                kr = UNDDisplayNoticeSimple_rpc(UNDServer,
-                                       timeout,
+                                       noticeTimeout,
                                        flags,
                                        iconPath,
                                        soundPath,
@@ -282,7 +296,7 @@ KUNCUserNotificationDisplayNotice(
 
 kern_return_t
 KUNCUserNotificationDisplayAlert(
-       int             timeout,
+       int             alertTimeout,
        unsigned        flags,
        char            *iconPath,
        char            *soundPath,
@@ -300,7 +314,7 @@ KUNCUserNotificationDisplayAlert(
        if (IP_VALID(UNDServer)) {
                kern_return_t   kr;
                kr = UNDDisplayAlertSimple_rpc(UNDServer,
-                                      timeout,
+                                      alertTimeout,
                                       flags,
                                       iconPath,
                                       soundPath,
@@ -326,7 +340,7 @@ KUNCUserNotificationDisplayFromBundle(
        char                         *messageKey,
        char                         *tokenString,
        KUNCUserNotificationCallBack callback,
-       int                          contextKey)
+       __unused int                    contextKey)
 {
        UNDReplyRef reply = (UNDReplyRef)id;
        UNDServerRef UNDServer;
@@ -339,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);