Skip to content

Commit

Permalink
xmpp login works
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisballinger committed Sep 7, 2011
1 parent e5c137f commit ec331bf
Show file tree
Hide file tree
Showing 13 changed files with 1,494 additions and 92 deletions.
678 changes: 666 additions & 12 deletions Off the Record.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
2 changes: 1 addition & 1 deletion Off the Record/OTRBuddyListViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@property (nonatomic, retain) OTRProtocolManager *protocolManager;

-(void)enterConversation:(NSString*)buddyName;
-(void)aimLoggedInSuccessfully;
-(void)loggedInSuccessfully;
-(void)buddyListUpdate;
-(void)messageReceived:(NSNotification*)notification;

Expand Down
10 changes: 8 additions & 2 deletions Off the Record/OTRBuddyListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,16 @@ - (void)viewDidLoad

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(aimLoggedInSuccessfully)
selector:@selector(loggedInSuccessfully)
name:@"OscarLoginNotification"
object:nil ];

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(loggedInSuccessfully)
name:@"XMPPLoginNotification"
object:nil ];


[[NSNotificationCenter defaultCenter]
addObserver:self
Expand Down Expand Up @@ -96,7 +102,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(void)aimLoggedInSuccessfully
-(void)loggedInSuccessfully
{
[loginController dismissModalViewControllerAnimated:YES];
}
Expand Down
3 changes: 3 additions & 0 deletions Off the Record/OTRLoginViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@


- (IBAction)loginPressed:(id)sender;
- (IBAction)xmppLoginPressed:(id)sender;

-(BOOL)checkFields;

@end
43 changes: 41 additions & 2 deletions Off the Record/OTRLoginViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ - (void)dealloc {
}
- (IBAction)loginPressed:(id)sender
{
if(![usernameTextField.text isEqualToString:@""] && ![passwordTextField.text isEqualToString:@""])
BOOL fields = [self checkFields];
if(fields)
{
protocolManager.oscarManager.login = [[AIMLogin alloc] initWithUsername:usernameTextField.text password:passwordTextField.text];
protocolManager.oscarManager.accountName = usernameTextField.text;
Expand All @@ -87,12 +88,50 @@ - (IBAction)loginPressed:(id)sender
[alert release];
}
}
else
}

- (IBAction)xmppLoginPressed:(id)sender
{
BOOL fields = [self checkFields];
if(fields)
{
HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];

HUD.delegate = self;
HUD.labelText = @"Logging in...";

[HUD show:YES];

BOOL connect = [protocolManager.xmppManager connectWithJID:usernameTextField.text password:passwordTextField.text];

if(connect)
{
[[NSNotificationCenter defaultCenter]
postNotificationName:@"XMPPLoginNotification"
object:self];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" message:@"Failed to connect to XMPP server. Please check your login credentials and internet connection and try again." delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}
}
}

-(BOOL)checkFields
{
BOOL fields = ![usernameTextField.text isEqualToString:@""] && ![passwordTextField.text isEqualToString:@""];

if(!fields)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error!" message:@"You must enter a username and a password to login." delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}

return fields;
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField
Expand Down
124 changes: 51 additions & 73 deletions Off the Record/OTRLoginViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<data>
<int key="IBDocument.SystemTarget">1280</int>
<string key="IBDocument.SystemVersion">11B26</string>
<string key="IBDocument.InterfaceBuilderVersion">1910</string>
<string key="IBDocument.InterfaceBuilderVersion">1934</string>
<string key="IBDocument.AppKitVersion">1138</string>
<string key="IBDocument.HIToolboxVersion">566.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">911</string>
<string key="NS.object.0">931</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -46,7 +46,6 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{97, 108}, {203, 31}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="494290929"/>
<string key="NSReuseIdentifierKey">_NS:209</string>
<bool key="IBUIOpaque">NO</bool>
Expand Down Expand Up @@ -84,7 +83,6 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{118, 20}, {84, 21}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1031177398"/>
<string key="NSReuseIdentifierKey">_NS:121</string>
<bool key="IBUIOpaque">NO</bool>
Expand All @@ -108,7 +106,6 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{9, 112}, {80, 21}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1040179389"/>
<string key="NSReuseIdentifierKey">_NS:121</string>
<bool key="IBUIOpaque">NO</bool>
Expand All @@ -130,7 +127,6 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{9, 151}, {80, 21}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="782725272"/>
<string key="NSReuseIdentifierKey">_NS:121</string>
<bool key="IBUIOpaque">NO</bool>
Expand All @@ -152,7 +148,6 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{97, 147}, {203, 31}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="876653851"/>
<string key="NSReuseIdentifierKey">_NS:209</string>
<bool key="IBUIOpaque">NO</bool>
Expand Down Expand Up @@ -180,42 +175,63 @@
<object class="IBUIButton" id="876653851">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{124, 372}, {72, 37}}</string>
<string key="NSFrame">{{21, 372}, {116, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="265638582"/>
<string key="NSReuseIdentifierKey">_NS:186</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<int key="IBUIButtonType">1</int>
<string key="IBUINormalTitle">Log-in</string>
<object class="NSColor" key="IBUIHighlightedTitleColor">
<string key="IBUINormalTitle">Log-in to AIM</string>
<object class="NSColor" key="IBUIHighlightedTitleColor" id="437551555">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
</object>
<object class="NSColor" key="IBUINormalTitleShadowColor">
<object class="NSColor" key="IBUINormalTitleShadowColor" id="399879718">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC41AA</bytes>
</object>
<object class="IBUIFontDescription" key="IBUIFontDescription">
<object class="IBUIFontDescription" key="IBUIFontDescription" id="555479740">
<int key="type">1</int>
<double key="pointSize">15</double>
</object>
<object class="NSFont" key="IBUIFont">
<object class="NSFont" key="IBUIFont" id="373062546">
<string key="NSName">Helvetica</string>
<double key="NSSize">15</double>
<int key="NSfFlags">16</int>
</object>
</object>
<object class="IBUIButton" id="265638582">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">292</int>
<string key="NSFrame">{{169, 372}, {131, 37}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:225</string>
<bool key="IBUIOpaque">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIContentHorizontalAlignment">0</int>
<int key="IBUIContentVerticalAlignment">0</int>
<int key="IBUIButtonType">1</int>
<string key="IBUINormalTitle">Login to XMPP</string>
<reference key="IBUIHighlightedTitleColor" ref="437551555"/>
<object class="NSColor" key="IBUINormalTitleColor">
<int key="NSColorSpace">1</int>
<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
</object>
<reference key="IBUINormalTitleShadowColor" ref="399879718"/>
<reference key="IBUIFontDescription" ref="555479740"/>
<reference key="IBUIFont" ref="373062546"/>
</object>
</object>
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="249771835"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
Expand Down Expand Up @@ -278,6 +294,15 @@
</object>
<int key="connectionID">14</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchEventConnection" key="connection">
<string key="label">xmppLoginPressed:</string>
<reference key="source" ref="265638582"/>
<reference key="destination" ref="372490531"/>
<int key="IBEventType">7</int>
</object>
<int key="connectionID">16</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand All @@ -301,6 +326,7 @@
<reference ref="1031177398"/>
<reference ref="494290929"/>
<reference ref="876653851"/>
<reference ref="265638582"/>
</object>
<reference key="parent" ref="0"/>
</object>
Expand Down Expand Up @@ -345,6 +371,11 @@
<reference key="object" ref="876653851"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">15</int>
<reference key="object" ref="265638582"/>
<reference key="parent" ref="191373211"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
Expand All @@ -356,6 +387,7 @@
<string>-2.CustomClassName</string>
<string>-2.IBPluginDependency</string>
<string>1.IBPluginDependency</string>
<string>15.IBPluginDependency</string>
<string>4.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>6.IBPluginDependency</string>
Expand All @@ -376,6 +408,7 @@
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
Expand All @@ -390,64 +423,9 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">14</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">OTRLoginViewController</string>
<string key="superclassName">UIViewController</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">loginPressed:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">loginPressed:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">loginPressed:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>passwordTextField</string>
<string>usernameTextField</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UITextField</string>
<string>UITextField</string>
</object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>passwordTextField</string>
<string>usernameTextField</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">passwordTextField</string>
<string key="candidateClassName">UITextField</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">usernameTextField</string>
<string key="candidateClassName">UITextField</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/OTRLoginViewController.h</string>
</object>
</object>
</object>
<int key="maxID">16</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
Expand All @@ -456,6 +434,6 @@
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">911</string>
<string key="IBCocoaTouchPluginVersion">931</string>
</data>
</archive>
2 changes: 2 additions & 0 deletions Off the Record/OTRProtocolManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import <Foundation/Foundation.h>
#import "OTROscarManager.h"
#import "OTRXMPPManager.h"
#import "OTREncryptionManager.h"

@interface OTRProtocolManager : NSObject
Expand All @@ -16,6 +17,7 @@
}

@property (nonatomic, retain) OTROscarManager *oscarManager;
@property (nonatomic, retain) OTRXMPPManager *xmppManager;
@property (nonatomic, retain) OTREncryptionManager *encryptionManager;

+ (OTRProtocolManager*)sharedInstance; // Singleton method
Expand Down
2 changes: 2 additions & 0 deletions Off the Record/OTRProtocolManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ @implementation OTRProtocolManager

@synthesize oscarManager;
@synthesize encryptionManager;
@synthesize xmppManager;

-(id)init
{
self = [super init];
if(self)
{
oscarManager = [[OTROscarManager alloc] init];
xmppManager = [[OTRXMPPManager alloc] init];
encryptionManager = [[OTREncryptionManager alloc] init];
}
return self;
Expand Down
Loading

0 comments on commit ec331bf

Please sign in to comment.