Changeset 469 for trunk/ICeCoffEE/ICeCoffEE/APEMain.m
- Timestamp:
- 04/18/08 16:48:19 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ICeCoffEE/ICeCoffEE/APEMain.m
r456 r469 15 15 #import <ApplicationEnhancer/ApplicationEnhancer.h> 16 16 #import <ApplicationEnhancer/APETools.h> 17 #import <mach-o/dyld.h> 17 18 #import <objc/objc-runtime.h> 18 19 #import "ICeCoffEE.h" … … 66 67 67 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 background-only applications. 68 Boolean ICCF_shouldLoad;69 static Boolean ICCF_shouldLoad; 69 70 70 71 static Boolean ICCF_IsOne(CFTypeRef value) { … … 90 91 91 92 UInt32 icVersion = CFBundleGetVersionNumber(inBundle); 92 ICapeprintf(" ICeCoffEE APE:bundle version is %ld (0x%x)\n", icVersion, icVersion);93 ICapeprintf("bundle version is %ld (0x%x)\n", icVersion, icVersion); 93 94 CFNumberRef icVersionRef = CFNumberCreate(NULL, kCFNumberLongType, &icVersion); 94 95 CFPreferencesSetAppValue(kICLastLoadedVersion, icVersionRef, kICBundleIdentifier); … … 99 100 CFBundleRef appBundle = CFBundleGetMainBundle(); 100 101 if (appBundle == NULL) { 101 apeprintf(" ICeCoffEE APE: Can't get CFBundle for current process; not loading\n");102 apeprintf("can't get CFBundle for current process; not loading\n"); 102 103 return; 103 104 } … … 107 108 ICCF_IsOne(CFBundleGetValueForInfoDictionaryKey(appBundle, CFSTR("LSBackgroundOnly"))) || 108 109 ICCF_IsOne(CFBundleGetValueForInfoDictionaryKey(appBundle, CFSTR("NSBackgroundOnly")))) { 109 ICapeprintf(" ICeCoffEE APE:not loading as this application is background-only\n");110 ICapeprintf("not loading as this application is background-only\n"); 110 111 return; 111 112 } … … 115 116 static Boolean ICCF_CFBundleIDMatches(CFStringRef bundleID, CFStringRef test) { 116 117 return CFStringCompare(bundleID, test, kCFCompareCaseInsensitive) == kCFCompareEqualTo; 118 } 119 120 static Boolean ICCF_tryLoading = false; 121 static Boolean ICCF_loadedInWebKit = false; 122 static Boolean ICCF_loadedInPDFKit = false; 123 124 static void ICCF_OnAddImage(const struct mach_header *mh, intptr_t vmaddr_slide) { 125 if (!ICCF_tryLoading) // when initially registered, called a lot 126 return; 127 if (!ICCF_loadedInWebKit && 128 ICCF_PatchMethod("WebHTMLView", "ICeCoffEEWebKit", "ICeCoffEEWebKitSuper", "mouseUp:") && 129 ICCF_PatchMethod("WebHTMLView", "ICeCoffEEWebKit", "ICeCoffEEWebKitSuper", "mouseDown:") && 130 ICCF_PatchMethod("WebHTMLView", "ICeCoffEEWebKit", "ICeCoffEEWebKitSuper", "menuForEvent:") && 131 ICCF_PatchMethod("WebPDFView", "ICeCoffEEWebPDFView", "ICeCoffEEWebPDFViewSuper", "menuForEvent:")) { 132 ICapeprintf("loaded in WebHTMLView/WebPDFView for WebKit/Safari 3\n"); 133 ICCF_loadedInWebKit = true; 134 } 135 if (!ICCF_loadedInPDFKit && 136 ICCF_PatchMethod("PDFView", "ICeCoffEEPDFView", "ICeCoffEEPDFViewSuper", "menuForEvent:")) { 137 ICapeprintf("loaded in PDFView for PDFKit\n"); 138 ICCF_loadedInPDFKit = true; 139 } 117 140 } 118 141 … … 136 159 ICCF_PatchMethod("PBXTextView", "ICeCoffEEMenuOnly", "ICeCoffEEMenuSuper", "menuForEvent:"); 137 160 } 138 ICapeprintf(" ICeCoffEE APE:loaded in PBXTextView / XCTextView for Xcode\n");161 ICapeprintf("loaded in PBXTextView / XCTextView for Xcode\n"); 139 162 shouldLoadInNSTextView = NO; 140 163 } else if (ICCF_CFBundleIDMatches(bundleID, CFSTR("com.apple.terminal"))) { … … 143 166 ICCF_PatchMethod("TTView", "ICeCoffEETTView", "ICeCoffEETTViewSuper", "mouseUp:") && 144 167 ICCF_PatchMethod("TTView", "ICeCoffEETTView", "ICeCoffEETTViewSuper", "draggingEntered:"); 145 ICapeprintf(" ICeCoffEE APE:loaded in TTView for Terminal\n");168 ICapeprintf("loaded in TTView for Terminal\n"); 146 169 } else { 147 170 ICCF_PatchMethod("TermSubview", "ICeCoffEEMenuOnly", "ICeCoffEEMenuSuper", "menuForEvent:") && … … 152 175 ICCF_PatchMethod("TermSubview", "ICeCoffEETerminal", "ICeCoffEETermSubviewSuper", "draggingEntered:") && 153 176 ICCF_PatchMethod("TermSubview", "ICeCoffEETerminal", "ICeCoffEETermSubviewSuper", "_optionClickEvent:::"); 154 ICapeprintf(" ICeCoffEE APE:loaded in TermSubview for Terminal\n");177 ICapeprintf("loaded in TermSubview for Terminal\n"); 155 178 } 156 179 } else if (ICCF_CFBundleIDMatches(bundleID, CFSTR("org.mozilla.camino"))) { 157 180 ICCF_PatchMethod("ChildView", "ICeCoffEEMenuOnly", "ICeCoffEEMenuSuper", "menuForEvent:"); 158 ICapeprintf(" ICeCoffEE APE:loaded in ChildView for Camino\n");181 ICapeprintf("loaded in ChildView for Camino\n"); 159 182 } 160 183 } 161 184 162 ICCF_PatchMethod("WebHTMLView", "ICeCoffEEWebKit", "ICeCoffEEWebKitSuper", "mouseUp:") &&163 ICCF_PatchMethod("WebHTMLView", "ICeCoffEEWebKit", "ICeCoffEEWebKitSuper", "mouseDown:") &&164 ICCF_PatchMethod("WebHTMLView", "ICeCoffEEWebKit", "ICeCoffEEWebKitSuper", "menuForEvent:");165 ICapeprintf("ICeCoffEE APE: loaded in WebHTMLView for WebKit/Safari 3\n");166 167 185 if (shouldLoadInNSTextView) { 168 186 ICCF_PatchMethod("NSTextView", "ICeCoffEE", "ICeCoffEESuper", "mouseDown:") && 169 187 ICCF_PatchMethod("NSTextView", "ICeCoffEE", "ICeCoffEESuper", "clickedOnLink:atIndex:") && 170 188 ICCF_PatchMethod("NSTextView", "ICeCoffEE", "ICeCoffEESuper", "menuForEvent:"); 171 ICapeprintf("ICeCoffEE APE: loaded generic NSTextView support\n"); 172 } 173 174 ICCF_PatchMethod("PDFView", "ICeCoffEEMenuOnly", "ICeCoffEEMenuSuper", "menuForEvent:"); 175 ICapeprintf("ICeCoffEE APE: loaded in PDFView for PDFKit\n"); 189 ICapeprintf("loaded generic NSTextView support\n"); 190 } 191 192 _dyld_register_func_for_add_image(ICCF_OnAddImage); 193 ICCF_tryLoading = true; 194 ICCF_OnAddImage(NULL, 0L); 176 195 177 196 ICCF_ReloadPrefs(); … … 183 202 OSStatus APEBundleMessage(CFStringRef message,CFDataRef inData,CFDataRef *outData) 184 203 { 185 ICapeprintf(" ICeCoffEE APE:message '%@' (inData = %@)\n", message, inData);204 ICapeprintf("message '%@' (inData = %@)\n", message, inData); 186 205 187 206 if (CFStringCompare(message, kICPreferencesChanged, 0) == kCFCompareEqualTo)
Note:
See TracChangeset
for help on using the changeset viewer.