Plugins/Purple Service/AIPurpleOAuthJabberAccount.h
branchGTalkOAuth2Support
changeset 5089 a761745f82a1
equal deleted inserted replaced
5086:816c7d80c0e5 5089:a761745f82a1
       
     1 //
       
     2 //  AIPurpleOAuthJabberAccount.h
       
     3 //  Adium
       
     4 //
       
     5 //  Created by Thijs Alkemade on 18-09-12.
       
     6 //  Copyright (c) 2012 The Adium Team. All rights reserved.
       
     7 //
       
     8 
       
     9 #import "ESPurpleJabberAccount.h"
       
    10 #import "AIXMPPOAuthWebViewWindowController.h"
       
    11 
       
    12 #define AIXMPPAuthProgressNotification @"AIXMPPAuthProgressNotification"
       
    13 #define KEY_XMPP_OAUTH_STEP @"OAuthStep"
       
    14 
       
    15 typedef enum {
       
    16 	AIXMPPOAuthProgressPromptingUser,
       
    17 	AIXMPPOAuthProgressContactingServer,
       
    18 	AIXMPPOAuthProgressPromotingForChat,
       
    19 	AIXMPPOAuthProgressSuccess,
       
    20 	AIXMPPOAuthProgressFailure
       
    21 } AIXMPPOAuthProgressStep;
       
    22 
       
    23 enum {
       
    24     AINoNetworkState,
       
    25     AIMeGraphAPINetworkState,
       
    26     AIPromoteSessionNetworkState
       
    27 };
       
    28 
       
    29 @interface AIPurpleOAuthJabberAccount : ESPurpleJabberAccount {
       
    30 	AIXMPPOAuthWebViewWindowController *oAuthWC;
       
    31     
       
    32     NSString *oAuthToken;
       
    33     NSUInteger networkState;
       
    34     
       
    35     NSURLConnection *connection; // weak
       
    36     NSURLResponse *connectionResponse;
       
    37     NSMutableData *connectionData;
       
    38 }
       
    39 
       
    40 @property (nonatomic, retain) AIXMPPOAuthWebViewWindowController *oAuthWC;
       
    41 - (void)requestAuthorization;
       
    42 
       
    43 - (void)oAuthWebViewController:(AIXMPPOAuthWebViewWindowController *)wc didSucceedWithToken:(NSString *)token;
       
    44 - (void)oAuthWebViewControllerDidFail:(AIXMPPOAuthWebViewWindowController *)wc;
       
    45 
       
    46 - (void)didCompleteAuthorization;
       
    47 
       
    48 @property (nonatomic, copy) NSString *oAuthToken;
       
    49 @property (nonatomic, assign) NSUInteger networkState;
       
    50 @property (nonatomic, assign) NSURLConnection *connection; // assign because NSURLConnection retains its delegate.
       
    51 @property (nonatomic, retain) NSURLResponse *connectionResponse;
       
    52 @property (nonatomic, retain) NSMutableData *connectionData;
       
    53 
       
    54 - (void)meGraphAPIDidFinishLoading:(NSData *)graphAPIData response:(NSURLResponse *)response error:(NSError *)inError;
       
    55 - (void)promoteSessionDidFinishLoading:(NSData *)secretData response:(NSURLResponse *)response error:(NSError *)inError;
       
    56 
       
    57 + (BOOL)uidIsValid:(NSString *)inUID;
       
    58 
       
    59 // For subclasses
       
    60 - (NSString *)graphURLForToken:(NSString *)token;
       
    61 - (NSString *)promoteURLForToken:(NSString *)token;
       
    62 - (NSString *)authorizeURL;
       
    63 - (NSString *)frameURLHost;
       
    64 - (NSString *)frameURLPath;
       
    65 
       
    66 @end