Changeset 389 for trunk/ICeCoffEE/ICeCoffEE/APEMain.m
- Timestamp:
- 02/22/08 21:43:27 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ICeCoffEE/ICeCoffEE/APEMain.m
r388 r389 17 17 #import <objc/objc-runtime.h> 18 18 #import "ICeCoffEE.h" 19 #import "CPS.h"20 19 21 20 //¥¥¥ Our settings … … 66 65 CFBundleRef ICCF_bundle; 67 66 68 // With APE 1.3, if we're in the exclude list, APEBundleMainEarlyLoad doesn't get invoked; don't need to use APETools. But we need to do our own management to avoid loading in non-GUIapplications.67 // With APE 1.3, if we're in the exclude list, APEBundleMainEarlyLoad doesn't get invoked; don't need to use APETools. But we need to do our own management to avoid loading in background-only applications. 69 68 Boolean ICCF_shouldLoad; 69 70 static Boolean ICCF_IsOne(CFTypeRef value) { 71 if (value == NULL) 72 return false; 73 CFTypeID typeID = CFGetTypeID(value); 74 if (typeID == CFBooleanGetTypeID()) 75 return CFBooleanGetValue((CFBooleanRef)value); 76 else if (typeID == CFNumberGetTypeID()) { 77 static const int one = 1; 78 static CFNumberRef oneRef = NULL; 79 if (oneRef == NULL) oneRef = CFNumberCreate(NULL, kCFNumberIntType, &one); 80 return CFNumberCompare((CFNumberRef)value, oneRef, NULL) == kCFCompareEqualTo; 81 } else if (typeID == CFStringGetTypeID()) { 82 return CFStringCompare((CFStringRef)value, CFSTR("1"), 0) == kCFCompareEqualTo; 83 } 84 return false; 85 } 70 86 71 87 void APEBundleMainEarlyLoad(CFBundleRef inBundle, CFStringRef inAPEToolsApplicationID) … … 80 96 81 97 ICCF_shouldLoad = false; 82 83 CPSProcessSerNum psn; 84 OSStatus err = CPSGetCurrentProcess(&psn); 85 if (err != noErr) { 86 #if ICCF_DEBUG 87 apeprintf("ICeCoffEE APE: Can't get process serial number for current process (error %ld); still loading because of ICCF_DEBUG\n", err); 88 #else 89 apeprintf("ICeCoffEE APE: Can't get process serial number for current process (error %ld); not loading in this application\n", err); 90 return; 91 #endif 92 } 93 94 CPSProcessInfoRec info; 95 err = CPSGetProcessInfo(&psn, &info, NULL, 0, NULL, NULL, 0); 96 if (err != noErr) { 97 #if ICCF_DEBUG 98 apeprintf("ICeCoffEE APE: Can't get process information (error %ld); still loading because of ICCF_DEBUG\n", err); 99 #else 100 apeprintf("ICeCoffEE APE: Can't get process information (error %ld); not loading in this application\n", err); 101 return; 102 #endif 103 } else { 104 ICapeprintf("ICeCoffEE APE: got process attributes = 0x%lx\n", info.Attributes); 105 if (info.Attributes & (kCPSBGOnlyAttr | kCPSUIElementAttr | kCPSFullScreenAttr)) { 106 ICapeprintf("ICeCoffEE APE: not loading as this application is background-only\n"); 107 return; 108 } 98 99 CFBundleRef appBundle = CFBundleGetMainBundle(); 100 if (appBundle == NULL) { 101 apeprintf("ICeCoffEE APE: Can't get CFBundle for current process; not loading\n"); 102 return; 103 } 104 105 if (ICCF_IsOne(CFBundleGetValueForInfoDictionaryKey(appBundle, CFSTR("LSUIElement"))) || 106 ICCF_IsOne(CFBundleGetValueForInfoDictionaryKey(appBundle, CFSTR("NSUIElement"))) || 107 ICCF_IsOne(CFBundleGetValueForInfoDictionaryKey(appBundle, CFSTR("LSBackgroundOnly"))) || 108 ICCF_IsOne(CFBundleGetValueForInfoDictionaryKey(appBundle, CFSTR("NSBackgroundOnly")))) { 109 ICapeprintf("ICeCoffEE APE: not loading as this application is background-only\n"); 110 return; 109 111 } 110 112 ICCF_shouldLoad = true; 111 113 } 112 114 113 Boolean ICCF_CFBundleIDMatches(CFStringRef bundleID, CFStringRef test) {115 static Boolean ICCF_CFBundleIDMatches(CFStringRef bundleID, CFStringRef test) { 114 116 return CFStringCompare(bundleID, test, kCFCompareCaseInsensitive) == kCFCompareEqualTo; 115 117 } … … 119 121 if (!ICCF_shouldLoad) return; 120 122 121 ICCF_bundle = CFBundleGetBundleWithIdentifier(kICBundleIdentifier);123 ICCF_bundle = inBundle; 122 124 CFStringRef bundleID = CFBundleGetIdentifier(CFBundleGetMainBundle()); 123 125 BOOL shouldLoadInNSTextView = YES;
Note:
See TracChangeset
for help on using the changeset viewer.