/
ui.c
68 lines (57 loc) · 1.86 KB
/
ui.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* Copyright (c) 2009-2010 Apple Inc. All rights reserved.
*/
#include <CoreFoundation/CoreFoundation.h>
#include <CoreFoundation/CFUserNotificationPriv.h>
#include "ui.h"
#define CS_NOT_INSTALLED_HEADER_KEY "CS_NOT_INSTALLED_HEADER_KEY"
#define CS_NOT_INSTALLED_MSG_KEY "CS_NOT_INSTALLED_MSG_KEY"
#define OK_KEY "OK"
SInt32
AlertCoreStorageNotInstalled(void)
{
CFMutableDictionaryRef noteDict;
CFUserNotificationRef noteRef = NULL;
SInt32 error = -1;
CFOptionFlags responseFlags = 0;
CFURLRef bundleURL = NULL;
noteDict = CFDictionaryCreateMutable(NULL,
10,
&kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
if (!noteDict)
goto out;
bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
CFSTR("/System/Library/Filesystems/nofs.fs"),
kCFURLPOSIXPathStyle,
true);
if (!bundleURL)
goto out;
CFDictionarySetValue(noteDict,
kCFUserNotificationLocalizationURLKey,
bundleURL);
CFDictionarySetValue(noteDict,
kCFUserNotificationAlertHeaderKey,
CFSTR(CS_NOT_INSTALLED_HEADER_KEY));
CFDictionarySetValue(noteDict,
kCFUserNotificationAlertMessageKey,
CFSTR(CS_NOT_INSTALLED_MSG_KEY));
CFDictionaryAddValue(noteDict,
kCFUserNotificationDefaultButtonTitleKey,
CFSTR(OK_KEY));
noteRef = CFUserNotificationCreate(NULL, 60,
kCFUserNotificationCautionAlertLevel,
&error,
noteDict);
if (!noteRef)
goto out;
error = CFUserNotificationReceiveResponse(noteRef, 0, &responseFlags);
out:
if (noteDict)
CFRelease(noteDict);
if (noteRef)
CFRelease(noteRef);
if (bundleURL)
CFRelease(bundleURL);
return error;
}