adium 4208:142be7010d8f: Starting with abstracting the OAuth2 st...
commits at adium.im
commits at adium.im
Thu Sep 15 09:20:15 UTC 2011
details: http://hg.adium.im/adium/rev/142be7010d8f
revision: 4208:142be7010d8f
branch: MSN-XMPP
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Thu Sep 15 11:07:10 2011 +0200
Starting with abstracting the OAuth2 stuff from Facebook into a way that can be shared with the new XMPP MSN method.
Subject: adium 4209:0a6571895693: Adding a new OAuth2-XMPP subclass'ed MSN account type.
details: http://hg.adium.im/adium/rev/0a6571895693
revision: 4209:0a6571895693
branch: MSN-XMPP
author: Thijs Alkemade <thijsalkemade at gmail.com>
date: Thu Sep 15 11:19:25 2011 +0200
Adding a new OAuth2-XMPP subclass'ed MSN account type.
diffs (689 lines):
diff -r 1a8f7e9b4cbf -r 0a6571895693 Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj Tue Sep 13 03:01:22 2011 +0200
+++ b/Adium.xcodeproj/project.pbxproj Thu Sep 15 11:19:25 2011 +0200
@@ -1425,6 +1425,13 @@
76889DEB12D3CA17007AEF00 /* GetInfo.png in Resources */ = {isa = PBXBuildFile; fileRef = 76889DEA12D3CA17007AEF00 /* GetInfo.png */; };
76889DEF12D3CA40007AEF00 /* Personal.png in Resources */ = {isa = PBXBuildFile; fileRef = 76889DEE12D3CA40007AEF00 /* Personal.png */; };
76C1AF9C125A906A00D269A9 /* AIAdiumURLProtocol.m in Sources */ = {isa = PBXBuildFile; fileRef = 76C1AF9B125A906A00D269A9 /* AIAdiumURLProtocol.m */; };
+ 76EDA7E31421F3080074F456 /* AIOAuth2XMPPAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EDA7E21421F3080074F456 /* AIOAuth2XMPPAccount.m */; };
+ 76EDA7E41421F3910074F456 /* AIOAuth2XMPPAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EDA7E21421F3080074F456 /* AIOAuth2XMPPAccount.m */; };
+ 76EDA7E51421F3A30074F456 /* AIOAuth2XMPPAccount.h in Headers */ = {isa = PBXBuildFile; fileRef = 76EDA7E11421F3080074F456 /* AIOAuth2XMPPAccount.h */; };
+ 76EDA7E81421F8070074F456 /* AIXMPPMSNService.h in Headers */ = {isa = PBXBuildFile; fileRef = 76EDA7E61421F8070074F456 /* AIXMPPMSNService.h */; };
+ 76EDA7E91421F8070074F456 /* AIXMPPMSNService.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EDA7E71421F8070074F456 /* AIXMPPMSNService.m */; };
+ 76EDA7EC1421F8EA0074F456 /* AIXMPPMSNAccount.h in Headers */ = {isa = PBXBuildFile; fileRef = 76EDA7EA1421F8E90074F456 /* AIXMPPMSNAccount.h */; };
+ 76EDA7ED1421F8EA0074F456 /* AIXMPPMSNAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = 76EDA7EB1421F8E90074F456 /* AIXMPPMSNAccount.m */; };
7E6F8A94105611B700C6D80D /* libotr.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E6F8A93105611B700C6D80D /* libotr.framework */; };
7E6F8ACD105613AD00C6D80D /* libotr.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 7E6F8A93105611B700C6D80D /* libotr.framework */; };
7E7CF7F11124B982001CFC73 /* libgstsdp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E7CF7F01124B982001CFC73 /* libgstsdp.framework */; };
@@ -4617,6 +4624,12 @@
76889DEE12D3CA40007AEF00 /* Personal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Personal.png; path = Resources/Personal.png; sourceTree = "<group>"; };
76C1AF9A125A906A00D269A9 /* AIAdiumURLProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIAdiumURLProtocol.h; path = "Plugins/WebKit Message View/AIAdiumURLProtocol.h"; sourceTree = "<group>"; };
76C1AF9B125A906A00D269A9 /* AIAdiumURLProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIAdiumURLProtocol.m; path = "Plugins/WebKit Message View/AIAdiumURLProtocol.m"; sourceTree = "<group>"; };
+ 76EDA7E11421F3080074F456 /* AIOAuth2XMPPAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIOAuth2XMPPAccount.h; path = "Plugins/Purple Service/AIOAuth2XMPPAccount.h"; sourceTree = "<group>"; };
+ 76EDA7E21421F3080074F456 /* AIOAuth2XMPPAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIOAuth2XMPPAccount.m; path = "Plugins/Purple Service/AIOAuth2XMPPAccount.m"; sourceTree = "<group>"; };
+ 76EDA7E61421F8070074F456 /* AIXMPPMSNService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIXMPPMSNService.h; path = "Plugins/Purple Service/AIXMPPMSNService.h"; sourceTree = "<group>"; };
+ 76EDA7E71421F8070074F456 /* AIXMPPMSNService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIXMPPMSNService.m; path = "Plugins/Purple Service/AIXMPPMSNService.m"; sourceTree = "<group>"; };
+ 76EDA7EA1421F8E90074F456 /* AIXMPPMSNAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AIXMPPMSNAccount.h; path = "Plugins/Purple Service/AIXMPPMSNAccount.h"; sourceTree = "<group>"; };
+ 76EDA7EB1421F8E90074F456 /* AIXMPPMSNAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AIXMPPMSNAccount.m; path = "Plugins/Purple Service/AIXMPPMSNAccount.m"; sourceTree = "<group>"; };
77D903500B78CF1000B86C42 /* zhm */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.executable"; name = zhm; path = "Plugins/Purple Service/zhm"; sourceTree = "<group>"; };
7E1E8176063A3EEC00EB00F7 /* AIContextMenuTextView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AIContextMenuTextView.h; path = "Frameworks/Adium Framework/Source/AIContextMenuTextView.h"; sourceTree = "<group>"; };
7E1E8177063A3EEC00EB00F7 /* AIContextMenuTextView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = AIContextMenuTextView.m; path = "Frameworks/Adium Framework/Source/AIContextMenuTextView.m"; sourceTree = "<group>"; };
@@ -5467,6 +5480,8 @@
34415A64059F9B9B0019246B /* PurpleService.m */,
4B7F278705440C8D00CDFC90 /* CBPurpleAccount.h */,
348FF83E09128BEB00A942A8 /* CBPurpleAccount.m */,
+ 76EDA7E11421F3080074F456 /* AIOAuth2XMPPAccount.h */,
+ 76EDA7E21421F3080074F456 /* AIOAuth2XMPPAccount.m */,
34B324780CE4CCF400158D5F /* PurpleAccountViewController.h */,
34B324790CE4CCF400158D5F /* PurpleAccountViewController.m */,
81DAE8700C261E8A00780E4C /* AMPurpleTuneTooltip.h */,
@@ -5526,6 +5541,10 @@
343EB40508086D9000E27095 /* ESPurpleMSNAccountView.nib */,
4B7644DD07A05E7E0021CCD7 /* PurpleDefaultsMSN.plist */,
4B388E080719C351004DE713 /* MSN Service Preferences */,
+ 76EDA7E61421F8070074F456 /* AIXMPPMSNService.h */,
+ 76EDA7E71421F8070074F456 /* AIXMPPMSNService.m */,
+ 76EDA7EA1421F8E90074F456 /* AIXMPPMSNAccount.h */,
+ 76EDA7EB1421F8E90074F456 /* AIXMPPMSNAccount.m */,
);
name = MSN;
sourceTree = "<group>";
@@ -8987,6 +9006,7 @@
3485DBC809EBCE7400232CC4 /* ESPurpleFileReceiveRequestController.h in Headers */,
3485DBCA09EBCE7400232CC4 /* ESPurpleRequestActionController.h in Headers */,
34C7C62809EC4E890060FB4A /* AILibpurplePlugin.h in Headers */,
+ 76EDA7E51421F3A30074F456 /* AIOAuth2XMPPAccount.h in Headers */,
34E036720A75AA4F00394F11 /* CBOscarService.h in Headers */,
34E036740A75AA4F00394F11 /* CBPurpleOscarAccount.h in Headers */,
34E036760A75AA4F00394F11 /* DCPurpleOscarJoinChatViewController.h in Headers */,
@@ -9043,6 +9063,8 @@
34D8154613B663700022C8C4 /* JSONKit.h in Headers */,
34D8154E13B663A80022C8C4 /* auth_fb.h in Headers */,
34D8155013B663A80022C8C4 /* fbapi.h in Headers */,
+ 76EDA7E81421F8070074F456 /* AIXMPPMSNService.h in Headers */,
+ 76EDA7EC1421F8EA0074F456 /* AIXMPPMSNAccount.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -10076,6 +10098,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 76EDA7E41421F3910074F456 /* AIOAuth2XMPPAccount.m in Sources */,
1181976810D0B0D2003E8ECA /* adiumPurpleMedia.m in Sources */,
1192E6DA0FD30578003CAEF5 /* AIAnnoyingIRCMessagesHiderPlugin.m in Sources */,
117009A70F7E7D720078D6AB /* AIIRCServicesPasswordPlugin.m in Sources */,
@@ -10193,6 +10216,8 @@
34D8154713B663700022C8C4 /* JSONKit.m in Sources */,
34D8154D13B663A80022C8C4 /* auth_fb.c in Sources */,
34D8154F13B663A80022C8C4 /* fbapi.c in Sources */,
+ 76EDA7E91421F8070074F456 /* AIXMPPMSNService.m in Sources */,
+ 76EDA7ED1421F8EA0074F456 /* AIXMPPMSNAccount.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -10561,6 +10586,7 @@
5A23E0CD13EDC2E50032EF52 /* AdiumVersion.applescript in Sources */,
5A23E0CE13EDC2E50032EF52 /* StatusMessage.applescript in Sources */,
5A23E0CF13EDC2E50032EF52 /* Uptime.applescript in Sources */,
+ 76EDA7E31421F3080074F456 /* AIOAuth2XMPPAccount.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff -r 1a8f7e9b4cbf -r 0a6571895693 Plugins/Purple Service/AIFacebookXMPPAccount.h
--- a/Plugins/Purple Service/AIFacebookXMPPAccount.h Tue Sep 13 03:01:22 2011 +0200
+++ b/Plugins/Purple Service/AIFacebookXMPPAccount.h Thu Sep 15 11:19:25 2011 +0200
@@ -7,6 +7,7 @@
//
#import "CBPurpleAccount.h"
+#import "AIOAuth2XMPPAccount.h"
@class AIFacebookXMPPOAuthWebViewWindowController;
@@ -16,22 +17,8 @@
/* deprecated? This is called the 'App Secret' on Facebook's developer page. */
#define ADIUM_API_SECRET "bb9d2d9771790e69a0e943771ddf33c8"
-#define AIFacebookXMPPAuthProgressNotification @"AIFacebookXMPPAuthProgressNotification"
-#define KEY_FB_XMPP_AUTH_STEP @"AuthStep"
-typedef enum {
- AIFacebookXMPPAuthProgressPromptingUser,
- AIFacebookXMPPAuthProgressContactingServer,
- AIFacebookXMPPAuthProgressPromotingForChat,
- AIFacebookXMPPAuthProgressSuccess,
- AIFacebookXMPPAuthProgressFailure
-} AIFacebookXMPPAuthProgressStep;
-
-
- at interface AIFacebookXMPPAccount : CBPurpleAccount {
- AIFacebookXMPPOAuthWebViewWindowController *oAuthWC;
-
- NSString *oAuthToken;
+ at interface AIFacebookXMPPAccount : AIOAuth2XMPPAccount {
NSUInteger networkState;
NSURLConnection *connection; // weak
@@ -43,9 +30,6 @@
+ (BOOL)uidIsValidForFacebook:(NSString *)inUID;
- at property (nonatomic, retain) AIFacebookXMPPOAuthWebViewWindowController *oAuthWC;
-- (void)requestFacebookAuthorization;
-
- (void)oAuthWebViewController:(AIFacebookXMPPOAuthWebViewWindowController *)wc didSucceedWithToken:(NSString *)token;
- (void)oAuthWebViewControllerDidFail:(AIFacebookXMPPOAuthWebViewWindowController *)wc;
diff -r 1a8f7e9b4cbf -r 0a6571895693 Plugins/Purple Service/AIFacebookXMPPAccount.m
--- a/Plugins/Purple Service/AIFacebookXMPPAccount.m Tue Sep 13 03:01:22 2011 +0200
+++ b/Plugins/Purple Service/AIFacebookXMPPAccount.m Thu Sep 15 11:19:25 2011 +0200
@@ -37,7 +37,6 @@
@interface AIFacebookXMPPAccount ()
- at property (nonatomic, copy) NSString *oAuthToken;
@property (nonatomic, assign) NSUInteger networkState;
@property (nonatomic, assign) NSURLConnection *connection; // assign because NSURLConnection retains its delegate.
@property (nonatomic, retain) NSURLResponse *connectionResponse;
@@ -49,9 +48,7 @@
@implementation AIFacebookXMPPAccount
- at synthesize oAuthWC;
@synthesize migrationData;
- at synthesize oAuthToken;
@synthesize networkState, connection, connectionResponse, connectionData;
+ (BOOL)uidIsValidForFacebook:(NSString *)inUID
@@ -275,66 +272,6 @@
#pragma mark Authorization
-- (void)requestFacebookAuthorization
-{
- self.oAuthWC = [[[AIFacebookXMPPOAuthWebViewWindowController alloc] init] autorelease];
- self.oAuthWC.account = self;
-
- [[NSNotificationCenter defaultCenter] postNotificationName:AIFacebookXMPPAuthProgressNotification
- object:self
- userInfo:
- [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:AIFacebookXMPPAuthProgressPromptingUser]
- forKey:KEY_FB_XMPP_AUTH_STEP]];
-
- if (![[self class] uidIsValidForFacebook:self.UID]) {
- /* We have a UID which isn't a Facebook numeric username. That can come from:
- * 1. The setup wizard
- * 2. Facebook-HTTP account from Adium <= 1.4.2
- */
- self.oAuthWC.autoFillUsername = self.UID;
- self.oAuthWC.autoFillPassword = [adium.accountController passwordForAccount:self];
- self.oAuthWC.isMigrating = ![self.service.serviceID isEqualToString:FACEBOOK_XMPP_SERVICE_ID];
-
- self.migrationData = [NSDictionary dictionaryWithObjectsAndKeys:
- self.UID, @"originalUID",
- self.service.serviceID, @"originalServiceID",
- nil];
- }
-
- [self.oAuthWC showWindow:self];
-}
-
-- (void)oAuthWebViewController:(AIFacebookXMPPOAuthWebViewWindowController *)wc didSucceedWithToken:(NSString *)token
-{
- [self setOAuthToken:token];
-
- NSString *urlstring = [NSString stringWithFormat:@"https://graph.facebook.com/me?access_token=%@", [self oAuthToken]];
- NSURL *url = [NSURL URLWithString:[urlstring stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
- NSURLRequest *request = [NSURLRequest requestWithURL:url];
-
- self.networkState = AIMeGraphAPINetworkState;
- self.connectionData = [NSMutableData data];
- self.connection = [NSURLConnection connectionWithRequest:request delegate:self];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:AIFacebookXMPPAuthProgressNotification
- object:self
- userInfo:
- [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:AIFacebookXMPPAuthProgressContactingServer]
- forKey:KEY_FB_XMPP_AUTH_STEP]];
-}
-
-- (void)oAuthWebViewControllerDidFail:(AIFacebookXMPPOAuthWebViewWindowController *)wc
-{
- [self setOAuthToken:nil];
-
- [[NSNotificationCenter defaultCenter] postNotificationName:AIFacebookXMPPAuthProgressNotification
- object:self
- userInfo:
- [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:AIFacebookXMPPAuthProgressFailure]
- forKey:KEY_FB_XMPP_AUTH_STEP]];
-
-}
-
- (void)meGraphAPIDidFinishLoading:(NSData *)graphAPIData response:(NSURLResponse *)inResponse error:(NSError *)inError
{
if (inError) {
@@ -365,11 +302,11 @@
self.connectionData = [NSMutableData data];
self.connection = [NSURLConnection connectionWithRequest:secretRequest delegate:self];
- [[NSNotificationCenter defaultCenter] postNotificationName:AIFacebookXMPPAuthProgressNotification
+ [[NSNotificationCenter defaultCenter] postNotificationName:AIOAuth2ProgressNotification
object:self
userInfo:
- [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:AIFacebookXMPPAuthProgressPromotingForChat]
- forKey:KEY_FB_XMPP_AUTH_STEP]];
+ [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:AIOAuth2ProgressPromotingForChat]
+ forKey:KEY_OAUTH2_STEP]];
}
- (void)didCompleteFacebookAuthorization
@@ -378,11 +315,11 @@
* isn't going to restart it for us. */
[self connect];
- [[NSNotificationCenter defaultCenter] postNotificationName:AIFacebookXMPPAuthProgressNotification
+ [[NSNotificationCenter defaultCenter] postNotificationName:AIOAuth2ProgressNotification
object:self
userInfo:
- [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:AIFacebookXMPPAuthProgressSuccess]
- forKey:KEY_FB_XMPP_AUTH_STEP]];
+ [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:AIOAuth2ProgressSuccess]
+ forKey:KEY_OAUTH2_STEP]];
}
- (void)promoteSessionDidFinishLoading:(NSData *)secretData response:(NSURLResponse *)response error:(NSError *)inError
diff -r 1a8f7e9b4cbf -r 0a6571895693 Plugins/Purple Service/AIFacebookXMPPAccountViewController.m
--- a/Plugins/Purple Service/AIFacebookXMPPAccountViewController.m Tue Sep 13 03:01:22 2011 +0200
+++ b/Plugins/Purple Service/AIFacebookXMPPAccountViewController.m Thu Sep 15 11:19:25 2011 +0200
@@ -6,7 +6,7 @@
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
-#import "AIFacebookXMPPAccount.h"
+#import "AIOAuth2XMPPAccount.h"
#import "AIFacebookXMPPAccountViewController.h"
#import <Adium/AIAccount.h>
#import <Adium/AIAccountControllerProtocol.h>
@@ -79,32 +79,32 @@
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(authProgressDidChange:)
- name: AIFacebookXMPPAuthProgressNotification
+ name: AIOAuth2ProgressNotification
object:inAccount];
}
- (void) authProgressDidChange:(NSNotification *)notification
{
- AIFacebookXMPPAuthProgressStep step = [[notification.userInfo objectForKey:KEY_FB_XMPP_AUTH_STEP] intValue];
+ AIOAuth2ProgressStep step = [[notification.userInfo objectForKey:KEY_OAUTH2_STEP] intValue];
switch (step) {
- case AIFacebookXMPPAuthProgressPromptingUser:
+ case AIOAuth2ProgressPromptingUser:
[textField_OAuthStatus setStringValue:[AILocalizedString(@"Requesting authorization", nil) stringByAppendingEllipsis]];
break;
- case AIFacebookXMPPAuthProgressContactingServer:
+ case AIOAuth2ProgressContactingServer:
[textField_OAuthStatus setStringValue:[AILocalizedString(@"Contacting authorization server", nil) stringByAppendingEllipsis]];
break;
- case AIFacebookXMPPAuthProgressPromotingForChat:
+ case AIOAuth2ProgressPromotingForChat:
[textField_OAuthStatus setStringValue:[AILocalizedString(@"Promoting authorization for chat", nil) stringByAppendingEllipsis]];
break;
- case AIFacebookXMPPAuthProgressSuccess:
+ case AIOAuth2ProgressSuccess:
[textField_OAuthStatus setStringValue:AILocalizedString(@"Adium is authorized for Facebook Chat.", nil)];
break;
- case AIFacebookXMPPAuthProgressFailure:
+ case AIOAuth2ProgressFailure:
[textField_OAuthStatus setStringValue:AILocalizedString(@"Could not complete authorization.", nil)];
[button_OAuthStart setEnabled:YES];
break;
@@ -119,7 +119,7 @@
- (IBAction)changedPreference:(id)sender
{
if (sender == button_OAuthStart) {
- [(AIFacebookXMPPAccount *)account requestFacebookAuthorization];
+ [(AIOAuth2XMPPAccount *)account requestAuthorization];
[button_OAuthStart setEnabled:NO];
} else
diff -r 1a8f7e9b4cbf -r 0a6571895693 Plugins/Purple Service/AIOAuth2XMPPAccount.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/Purple Service/AIOAuth2XMPPAccount.h Thu Sep 15 11:19:25 2011 +0200
@@ -0,0 +1,41 @@
+/*
+ * Adium is the legal property of its developers, whose names are listed in the copyright file included
+ * with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#import "CBPurpleAccount.h"
+#import "AIFacebookXMPPOAuthWebViewWindowController.h"
+
+#define AIOAuth2ProgressNotification @"AIOAuth2ProgressNotification"
+#define KEY_OAUTH2_STEP @"AuthStep"
+
+typedef enum {
+ AIOAuth2ProgressPromptingUser,
+ AIOAuth2ProgressContactingServer,
+ AIOAuth2ProgressPromotingForChat,
+ AIOAuth2ProgressSuccess,
+ AIOAuth2ProgressFailure
+} AIOAuth2ProgressStep;
+
+ at interface AIOAuth2XMPPAccount : CBPurpleAccount {
+ AIFacebookXMPPOAuthWebViewWindowController *oAuthWC;
+ NSString *oAuthToken;
+}
+
+- (void)requestAuthorization;
+
+ at property (nonatomic, retain) AIFacebookXMPPOAuthWebViewWindowController *oAuthWC;
+ at property (nonatomic, copy) NSString *oAuthToken;
+
+ at end
diff -r 1a8f7e9b4cbf -r 0a6571895693 Plugins/Purple Service/AIOAuth2XMPPAccount.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/Purple Service/AIOAuth2XMPPAccount.m Thu Sep 15 11:19:25 2011 +0200
@@ -0,0 +1,93 @@
+/*
+ * Adium is the legal property of its developers, whose names are listed in the copyright file included
+ * with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#import "AIOAuth2XMPPAccount.h"
+
+ at implementation AIOAuth2XMPPAccount
+
+ at synthesize oAuthWC, oAuthToken;
+
+- (id)init
+{
+ self = [super init];
+ if (self) {
+ // Initialization code here.
+ }
+
+ return self;
+}
+
+- (void)requestAuthorization
+{
+ self.oAuthWC = [[[AIFacebookXMPPOAuthWebViewWindowController alloc] init] autorelease];
+ self.oAuthWC.account = self;
+
+ [[NSNotificationCenter defaultCenter] postNotificationName:AIOAuth2ProgressNotification
+ object:self
+ userInfo:
+ [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:AIOAuth2ProgressPromptingUser]
+ forKey:KEY_OAUTH2_STEP]];
+
+// if (![[self class] uidIsValidForFacebook:self.UID]) {
+ /* We have a UID which isn't a Facebook numeric username. That can come from:
+ * 1. The setup wizard
+ * 2. Facebook-HTTP account from Adium <= 1.4.2
+ */
+// self.oAuthWC.autoFillUsername = self.UID;
+// self.oAuthWC.autoFillPassword = [adium.accountController passwordForAccount:self];
+// self.oAuthWC.isMigrating = ![self.service.serviceID isEqualToString:FACEBOOK_XMPP_SERVICE_ID];
+
+// self.migrationData = [NSDictionary dictionaryWithObjectsAndKeys:
+// self.UID, @"originalUID",
+// self.service.serviceID, @"originalServiceID",
+// nil];
+// }
+
+ [self.oAuthWC showWindow:self];
+}
+
+- (void)oAuthWebViewController:(AIFacebookXMPPOAuthWebViewWindowController *)wc didSucceedWithToken:(NSString *)token
+{
+ [self setOAuthToken:token];
+
+ NSString *urlstring = [NSString stringWithFormat:@"https://graph.facebook.com/me?access_token=%@", [self oAuthToken]];
+ NSURL *url = [NSURL URLWithString:[urlstring stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
+ NSURLRequest *request = [NSURLRequest requestWithURL:url];
+
+// self.networkState = AIMeGraphAPINetworkState;
+// self.connectionData = [NSMutableData data];
+// self.connection = [NSURLConnection connectionWithRequest:request delegate:self];
+
+ [[NSNotificationCenter defaultCenter] postNotificationName:AIOAuth2ProgressNotification
+ object:self
+ userInfo:
+ [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:AIOAuth2ProgressContactingServer]
+ forKey:KEY_OAUTH2_STEP]];
+}
+
+- (void)oAuthWebViewControllerDidFail:(AIFacebookXMPPOAuthWebViewWindowController *)wc
+{
+ [self setOAuthToken:nil];
+
+ [[NSNotificationCenter defaultCenter] postNotificationName:AIOAuth2ProgressNotification
+ object:self
+ userInfo:
+ [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:AIOAuth2ProgressFailure]
+ forKey:KEY_OAUTH2_STEP]];
+
+}
+
+ at end
diff -r 1a8f7e9b4cbf -r 0a6571895693 Plugins/Purple Service/AIXMPPMSNAccount.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/Purple Service/AIXMPPMSNAccount.h Thu Sep 15 11:19:25 2011 +0200
@@ -0,0 +1,21 @@
+/*
+ * Adium is the legal property of its developers, whose names are listed in the copyright file included
+ * with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#import "AIOAuth2XMPPAccount.h"
+
+ at interface AIXMPPMSNAccount : AIOAuth2XMPPAccount
+
+ at end
diff -r 1a8f7e9b4cbf -r 0a6571895693 Plugins/Purple Service/AIXMPPMSNAccount.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/Purple Service/AIXMPPMSNAccount.m Thu Sep 15 11:19:25 2011 +0200
@@ -0,0 +1,31 @@
+/*
+ * Adium is the legal property of its developers, whose names are listed in the copyright file included
+ * with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#import "AIXMPPMSNAccount.h"
+
+ at implementation AIXMPPMSNAccount
+
+- (id)init
+{
+ self = [super init];
+ if (self) {
+ // Initialization code here.
+ }
+
+ return self;
+}
+
+ at end
diff -r 1a8f7e9b4cbf -r 0a6571895693 Plugins/Purple Service/AIXMPPMSNService.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/Purple Service/AIXMPPMSNService.h Thu Sep 15 11:19:25 2011 +0200
@@ -0,0 +1,21 @@
+/*
+ * Adium is the legal property of its developers, whose names are listed in the copyright file included
+ * with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#import "PurpleService.h"
+
+ at interface AIXMPPMSNService : PurpleService
+
+ at end
diff -r 1a8f7e9b4cbf -r 0a6571895693 Plugins/Purple Service/AIXMPPMSNService.m
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/Purple Service/AIXMPPMSNService.m Thu Sep 15 11:19:25 2011 +0200
@@ -0,0 +1,118 @@
+/*
+ * Adium is the legal property of its developers, whose names are listed in the copyright file included
+ * with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#import "AIXMPPMSNService.h"
+
+#import <Adium/AIStatusControllerProtocol.h>
+#import "DCPurpleMSNJoinChatViewController.h"
+#import "AIXMPPMSNAccount.h"
+#import "AIFacebookXMPPAccountViewController.h"
+#import "AIXMPPMSNService.h"
+
+ at implementation AIXMPPMSNService
+
+//Account Creation
+- (Class)accountClass{
+ return [AIXMPPMSNAccount class];
+}
+
+- (AIAccountViewController *)accountViewController{
+ return [AIFacebookXMPPAccountViewController accountViewController];
+}
+
+- (DCJoinChatViewController *)joinChatView{
+ return nil; // [AIXMPPMSNJoinChatViewController joinChatView];
+}
+
+//Service Description
+- (NSString *)serviceCodeUniqueID{
+ return @"libpurple-MSN";
+}
+- (NSString *)serviceID{
+ return @"MSN";
+}
+- (NSString *)serviceClass{
+ return @"MSN";
+}
+- (NSString *)shortDescription{
+ return @"MSN";
+}
+- (NSString *)longDescription{
+ return @"MSN Messenger";
+}
+- (NSCharacterSet *)allowedCharacters{
+ return [NSCharacterSet characterSetWithCharactersInString:@"+abcdefghijklmnopqrstuvwxyz0123456789 at ._-"];
+}
+- (NSUInteger)allowedLength{
+ return 113;
+}
+- (BOOL)caseSensitive{
+ return NO;
+}
+- (AIServiceImportance)serviceImportance{
+ return AIServicePrimary;
+}
+- (NSString *)userNameLabel{
+ return AILocalizedString(@"MSN Passport",""); //Sign-in name
+}
+
+- (void)registerStatuses{
+ [adium.statusController registerStatus:STATUS_NAME_AVAILABLE
+ withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_AVAILABLE]
+ ofType:AIAvailableStatusType
+ forService:self];
+
+ [adium.statusController registerStatus:STATUS_NAME_AWAY
+ withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_AWAY]
+ ofType:AIAwayStatusType
+ forService:self];
+
+ [adium.statusController registerStatus:STATUS_NAME_BRB
+ withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_BRB]
+ ofType:AIAwayStatusType
+ forService:self];
+
+ [adium.statusController registerStatus:STATUS_NAME_BUSY
+ withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_BUSY]
+ ofType:AIAwayStatusType
+ forService:self];
+
+ [adium.statusController registerStatus:STATUS_NAME_PHONE
+ withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_PHONE]
+ ofType:AIAwayStatusType
+ forService:self];
+
+ [adium.statusController registerStatus:STATUS_NAME_LUNCH
+ withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_LUNCH]
+ ofType:AIAwayStatusType
+ forService:self];
+
+ [adium.statusController registerStatus:STATUS_NAME_INVISIBLE
+ withDescription:[adium.statusController localizedDescriptionForCoreStatusName:STATUS_NAME_INVISIBLE]
+ ofType:AIInvisibleStatusType
+ forService:self];
+ /*
+ m = g_list_append(m, _("Available"));
+ m = g_list_append(m, _("Away From Computer"));
+ m = g_list_append(m, _("Be Right Back"));
+ m = g_list_append(m, _("Busy"));
+ m = g_list_append(m, _("On The Phone"));
+ m = g_list_append(m, _("Out To Lunch"));
+ m = g_list_append(m, _("Hidden"));
+ */
+}
+
+ at end
diff -r 1a8f7e9b4cbf -r 0a6571895693 Plugins/Purple Service/CBPurpleServicePlugin.m
--- a/Plugins/Purple Service/CBPurpleServicePlugin.m Tue Sep 13 03:01:22 2011 +0200
+++ b/Plugins/Purple Service/CBPurpleServicePlugin.m Thu Sep 15 11:19:25 2011 +0200
@@ -49,7 +49,7 @@
[AIGTalkService registerService];
[ESIRCService registerService];
[AILiveJournalService registerService];
- [ESMSNService registerService];
+ [AIXMPPMSNService registerService];
[PurpleMySpaceService registerService];
/* TODO for release of 1.5: At the very least, present to users who had a QQ account
* a message that it's no longer supported.
diff -r 1a8f7e9b4cbf -r 0a6571895693 Plugins/Purple Service/PurpleServices.h
--- a/Plugins/Purple Service/PurpleServices.h Tue Sep 13 03:01:22 2011 +0200
+++ b/Plugins/Purple Service/PurpleServices.h Thu Sep 15 11:19:25 2011 +0200
@@ -27,7 +27,7 @@
#import "ESMeanwhileService.h"
#import "PurpleMySpaceService.h"
#import "ESNovellService.h"
-#import "ESMSNService.h"
+#import "AIXMPPMSNService.h"
#import "ESSimpleService.h"
#import "ESYahooService.h"
#import "ESYahooJapanService.h"
More information about the commits
mailing list