Commits

Thijs Alkemade  committed 74a280f

Instead of (incorrectly) overwriting, swizzle the method

  • Participants
  • Parent commits 4ec03f6
  • Tags 0.1.0

Comments (0)

Files changed (4)

File AISFPlugin.h

 
 #import <Cocoa/Cocoa.h>
 #import <Adium/AIPlugin.h>
+#import <AdiumLibpurple/CBPurpleAccount.h>
 #import <Adium/AIContentControllerProtocol.h>
 #import <Adium/ESDebugAILog.h>
 

File AISFPlugin.m

 #import <Adium/AIContentMessage.h>
 
 #import <Adium/AIPreferenceControllerProtocol.h>
+#import </usr/include/objc/objc-class.h>
 
 @implementation AISFPlugin
 
 												 name:Content_WillReceiveContent
 											   object:nil];
 	
+	AILogWithSignature(@"Doing risky stuff: swizzling authorizationRequestWithDict:");
+	
+	Method orig_method = nil, alt_method = nil;
+	orig_method = class_getInstanceMethod([CBPurpleAccount class], @selector(authorizationRequestWithDict:));
+    alt_method = class_getInstanceMethod([CBPurpleAccount class], @selector(_authorizationRequestWithDict:));
+	
+	if ((orig_method != nil) && (alt_method != nil))
+	{
+        char *temp1;
+        IMP temp2;
+		
+        temp1 = orig_method->method_types;
+        orig_method->method_types = alt_method->method_types;
+        alt_method->method_types = temp1;
+		
+        temp2 = orig_method->method_imp;
+        orig_method->method_imp = alt_method->method_imp;
+        alt_method->method_imp = temp2;
+	}
+	
 	AILogWithSignature(@"Adium spamfilter plugin loaded: %@", [preferences view]);
 }
 
 
 - (NSString *)pluginVersion
 {
-	return @"0.0.2";
+	return @"0.1.0";
 }
 
 - (NSString *)pluginDescription

File CBPurpleAccount+AuthBlocker.m

 
 @implementation CBPurpleAccount (AuthBlocker)
 
-- (id)authorizationRequestWithDict:(NSDictionary*)dict {
+- (id)_authorizationRequestWithDict:(NSDictionary*)dict {
 	if ([AISFPreferences sharedInstance].shouldIgnoreAuthorizationRequests) {
 		NSString *reason = [dict valueForKey:@"Reason"];
 		
 		}
 	}
 	
-	return [super authorizationRequestWithDict:dict];
+	return [self _authorizationRequestWithDict:dict];
 }
 
 @end
 	<key>CFBundlePackageType</key>
 	<string>BNDL</string>
 	<key>CFBundleShortVersionString</key>
-	<string>1.0</string>
+	<string>0.1.0</string>
 	<key>CFBundleSignature</key>
 	<string>AdIM</string>
 	<key>CFBundleVersion</key>