Skip to content

Commit

Permalink
Merge pull request ChatSecure#596 from ChatSecure/missing-password-de…
Browse files Browse the repository at this point in the history
…velop

Attempt to fix missing password bug ChatSecure#594
  • Loading branch information
chrisballinger authored Nov 7, 2016
2 parents 885ee06 + be25aad commit 4b0c753
Show file tree
Hide file tree
Showing 30 changed files with 359 additions and 359 deletions.
16 changes: 8 additions & 8 deletions ChatSecure.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@
D93DDAF21BA79A2800CD8331 /* OTRXMPPServerListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 63039E971B0D43FE007C9978 /* OTRXMPPServerListViewController.m */; };
D93DDAF31BA79A2800CD8331 /* OTRXMPPLoginHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 634680821B0404CE00D9A1C5 /* OTRXMPPLoginHandler.m */; };
D93DDAF51BA79A2800CD8331 /* OTRGoolgeOAuthLoginHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 634680891B041F2F00D9A1C5 /* OTRGoolgeOAuthLoginHandler.m */; };
D93DDAF61BA79A2900CD8331 /* OTRChatSecureIDCreateAccountHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C7E64A1B20F5730085FA06 /* OTRChatSecureIDCreateAccountHandler.m */; };
D93DDAF71BA79A2900CD8331 /* OTRXMPPCreateAccountHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 6346808C1B04206400D9A1C5 /* OTRXMPPCreateAccountHandler.m */; };
D93DDAF81BA79A2900CD8331 /* OTRLoginHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BE425D1B320EE20017058C /* OTRLoginHandler.m */; };
D93DDAF91BA79A2900CD8331 /* OTRAboutViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 633106131A16D1A300C17BAE /* OTRAboutViewController.m */; };
Expand Down Expand Up @@ -298,7 +297,6 @@
D93DDBA81BA79AAA00CD8331 /* OTRXMPPServerListViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 63039E961B0D43FE007C9978 /* OTRXMPPServerListViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
D93DDBA91BA79AAB00CD8331 /* OTRXMPPLoginHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 634680811B0404CE00D9A1C5 /* OTRXMPPLoginHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
D93DDBAB1BA79AAE00CD8331 /* OTRGoolgeOAuthLoginHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 634680881B041F2F00D9A1C5 /* OTRGoolgeOAuthLoginHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
D93DDBAC1BA79AAF00CD8331 /* OTRChatSecureIDCreateAccountHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 63C7E6491B20F5730085FA06 /* OTRChatSecureIDCreateAccountHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
D93DDBAD1BA79AB000CD8331 /* OTRXMPPCreateAccountHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 6346808B1B04206400D9A1C5 /* OTRXMPPCreateAccountHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
D93DDBAE1BA79AB100CD8331 /* OTRLoginHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 63BE425C1B320EE20017058C /* OTRLoginHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
D93DDBAF1BA79AB200CD8331 /* OTRAboutViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 633106121A16D1A300C17BAE /* OTRAboutViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -374,6 +372,8 @@
D9AE3A331BA8D9AB00255537 /* OTRConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 633105EF1A16D1A300C17BAE /* OTRConstants.m */; };
D9AE3A341BA8DAB600255537 /* OTRLanguageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 6331051B1A16D1A300C17BAE /* OTRLanguageManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
D9AE3A351BA8DAB600255537 /* OTRLanguageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6331051C1A16D1A300C17BAE /* OTRLanguageManager.m */; };
D9B786AE1DD136280050CE38 /* OTRXMPPMessageStatusModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B786AD1DD136280050CE38 /* OTRXMPPMessageStatusModule.swift */; };
D9B786B01DD1363D0050CE38 /* OTRStreamManagementDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9B786AF1DD1363D0050CE38 /* OTRStreamManagementDelegate.swift */; };
D9CBBC581C642BAA005CD715 /* EnablePushViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9CBBC571C642BAA005CD715 /* EnablePushViewController.swift */; };
D9EEEDD31D2739A800B8BC54 /* OTRvCard.h in Headers */ = {isa = PBXBuildFile; fileRef = D9EEEDD11D27388600B8BC54 /* OTRvCard.h */; settings = {ATTRIBUTES = (Public, ); }; };
DDE1CAF4312DE1C724A33B72 /* Pods_ChatSecureCorePods_ChatSecureCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 31610826406FD0CB714045AD /* Pods_ChatSecureCorePods_ChatSecureCore.framework */; };
Expand Down Expand Up @@ -752,8 +752,6 @@
63C0C4441BE184910086B529 /* OTRRoomOccupantsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OTRRoomOccupantsViewController.swift; sourceTree = "<group>"; };
63C5B6681A82F3EE0011BEA8 /* OTRAudioPlaybackController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRAudioPlaybackController.h; sourceTree = "<group>"; };
63C5B6691A82F3EE0011BEA8 /* OTRAudioPlaybackController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRAudioPlaybackController.m; sourceTree = "<group>"; };
63C7E6491B20F5730085FA06 /* OTRChatSecureIDCreateAccountHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRChatSecureIDCreateAccountHandler.h; sourceTree = "<group>"; };
63C7E64A1B20F5730085FA06 /* OTRChatSecureIDCreateAccountHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRChatSecureIDCreateAccountHandler.m; sourceTree = "<group>"; };
63C7E64C1B20F69F0085FA06 /* OTRXMPPServerInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OTRXMPPServerInfo.h; path = ChatSecure/Classes/Model/OTRXMPPServerInfo.h; sourceTree = SOURCE_ROOT; };
63C7E64D1B20F69F0085FA06 /* OTRXMPPServerInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OTRXMPPServerInfo.m; path = ChatSecure/Classes/Model/OTRXMPPServerInfo.m; sourceTree = SOURCE_ROOT; };
63CBD68F1C642B9E00AC6D1F /* BuddyActions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BuddyActions.swift; path = YapActions/BuddyActions.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -837,6 +835,8 @@
D9AE3A261BA8D0DB00255537 /* OTRAssets.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRAssets.m; sourceTree = "<group>"; };
D9AE3A2E1BA8D84500255537 /* OTRBranding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OTRBranding.h; sourceTree = "<group>"; };
D9AE3A2F1BA8D84500255537 /* OTRBranding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OTRBranding.m; sourceTree = "<group>"; };
D9B786AD1DD136280050CE38 /* OTRXMPPMessageStatusModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OTRXMPPMessageStatusModule.swift; sourceTree = "<group>"; };
D9B786AF1DD1363D0050CE38 /* OTRStreamManagementDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OTRStreamManagementDelegate.swift; sourceTree = "<group>"; };
D9BE65431B6A08ED002D4136 /* XMPPServerInfoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMPPServerInfoCell.h; sourceTree = "<group>"; };
D9BE65441B6A08ED002D4136 /* XMPPServerInfoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XMPPServerInfoCell.m; sourceTree = "<group>"; };
D9BE65451B6A08ED002D4136 /* XMPPServerInfoCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = XMPPServerInfoCell.xib; path = Interface/XMPPServerInfoCell.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -952,6 +952,7 @@
6331050E1A16D1A300C17BAE /* Controllers */ = {
isa = PBXGroup;
children = (
D9B786AD1DD136280050CE38 /* OTRXMPPMessageStatusModule.swift */,
63CBD67F1C642B6B00AC6D1F /* YapExtensions */,
631098B01BD6FED000494A47 /* YapDatabse+ChatSecure.swift */,
63363FAD1CCAE29B00B0C720 /* OTRYapExtensions.swift */,
Expand Down Expand Up @@ -1006,6 +1007,7 @@
633105321A16D1A300C17BAE /* XMPP */ = {
isa = PBXGroup;
children = (
D9B786AF1DD1363D0050CE38 /* OTRStreamManagementDelegate.swift */,
63B916E01B743198003B778F /* OTRStreamManagementYapStorage.h */,
63B916E11B743198003B778F /* OTRStreamManagementYapStorage.m */,
637DBB1A1B7D5A23003845B7 /* OTRXMPPMessageYapStroage.h */,
Expand Down Expand Up @@ -1328,8 +1330,6 @@
634680821B0404CE00D9A1C5 /* OTRXMPPLoginHandler.m */,
634680881B041F2F00D9A1C5 /* OTRGoolgeOAuthLoginHandler.h */,
634680891B041F2F00D9A1C5 /* OTRGoolgeOAuthLoginHandler.m */,
63C7E6491B20F5730085FA06 /* OTRChatSecureIDCreateAccountHandler.h */,
63C7E64A1B20F5730085FA06 /* OTRChatSecureIDCreateAccountHandler.m */,
6346808B1B04206400D9A1C5 /* OTRXMPPCreateAccountHandler.h */,
6346808C1B04206400D9A1C5 /* OTRXMPPCreateAccountHandler.m */,
63BE425C1B320EE20017058C /* OTRLoginHandler.h */,
Expand Down Expand Up @@ -1674,7 +1674,6 @@
639C352A1C3DDDDE00132330 /* OTRXMPPBuddyManager.h in Headers */,
63D14F351C0FC7A60029F36B /* OTRThreadOwner.h in Headers */,
D93DDBAB1BA79AAE00CD8331 /* OTRGoolgeOAuthLoginHandler.h in Headers */,
D93DDBAC1BA79AAF00CD8331 /* OTRChatSecureIDCreateAccountHandler.h in Headers */,
D93DDBAD1BA79AB000CD8331 /* OTRXMPPCreateAccountHandler.h in Headers */,
D93DDBAE1BA79AB100CD8331 /* OTRLoginHandler.h in Headers */,
D93DDBAF1BA79AB200CD8331 /* OTRAboutViewController.h in Headers */,
Expand Down Expand Up @@ -2195,6 +2194,7 @@
D93DDA8A1BA79A2400CD8331 /* OTRSettingsManager.m in Sources */,
D93DDA8B1BA79A2400CD8331 /* OTRTorManager.m in Sources */,
D93DDA8C1BA79A2400CD8331 /* OTRNotificationController.m in Sources */,
D9B786AE1DD136280050CE38 /* OTRXMPPMessageStatusModule.swift in Sources */,
63E353B81BB9D83B005C54C3 /* OTRPushTLVHandler.m in Sources */,
D93DDA8D1BA79A2400CD8331 /* OTRAudioSessionManager.m in Sources */,
D93DDA8E1BA79A2400CD8331 /* OTRAudioPlaybackController.m in Sources */,
Expand Down Expand Up @@ -2230,6 +2230,7 @@
D93DDAC01BA79A2600CD8331 /* OTRBoolSetting.m in Sources */,
D93DDAC11BA79A2600CD8331 /* OTRCertificateSetting.m in Sources */,
D93DDAC21BA79A2600CD8331 /* OTRDonateSetting.m in Sources */,
D9B786B01DD1363D0050CE38 /* OTRStreamManagementDelegate.swift in Sources */,
D9CBBC581C642BAA005CD715 /* EnablePushViewController.swift in Sources */,
D93DDAC31BA79A2600CD8331 /* OTRDoubleSetting.m in Sources */,
D93DDAC41BA79A2600CD8331 /* OTRFeedbackSetting.m in Sources */,
Expand Down Expand Up @@ -2288,7 +2289,6 @@
D93DDAF21BA79A2800CD8331 /* OTRXMPPServerListViewController.m in Sources */,
D93DDAF31BA79A2800CD8331 /* OTRXMPPLoginHandler.m in Sources */,
D93DDAF51BA79A2800CD8331 /* OTRGoolgeOAuthLoginHandler.m in Sources */,
D93DDAF61BA79A2900CD8331 /* OTRChatSecureIDCreateAccountHandler.m in Sources */,
D93DDAF71BA79A2900CD8331 /* OTRXMPPCreateAccountHandler.m in Sources */,
D93DDAF81BA79A2900CD8331 /* OTRLoginHandler.m in Sources */,
D93DDAF91BA79A2900CD8331 /* OTRAboutViewController.m in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions ChatSecure/Classes/Controllers/OTRAccountsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ @implementation OTRAccountsManager

+ (void)removeAccount:(OTRAccount*)account
{
[account removeKeychainPassword:nil];
[[OTRDatabaseManager sharedInstance].readWriteDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {

[transaction setObject:nil forKey:account.uniqueId inCollection:[OTRAccount collection]];
[transaction removeObjectForKey:account.uniqueId inCollection:[OTRAccount collection]];
}];
}

Expand Down
37 changes: 0 additions & 37 deletions ChatSecure/Classes/Controllers/OTRNotificationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,47 +106,10 @@ - (UIViewController *)topViewController

- (void)showLoginSuccessNotification:(NSNotification *)notification
{
if (!self.enabled) {
return;
}
UIViewController *topViewController = [self topViewController];
if (![topViewController isKindOfClass:[OTRBaseLoginViewController class]]) {
OTRXMPPManager *xmppManager = notification.object;
NSString *accountName = nil;
if (xmppManager) {
accountName = [xmppManager accountName];
accountName = [XMPPJID jidWithString:accountName].bare;
}
//OTRToastOptions *options = [[OTRToastOptions alloc] initWithText:CONNECTED_STRING subtitleText:accountName optionType:OTRToastOptionTypeSuccess];
//[CRToastManager showNotificationWithOptions:[options dictionary] completionBlock:nil];
}
}

- (void)showLoginFailureNotification:(NSNotification *)notification
{
if (!self.enabled) {
return;
}
BOOL isUserInitiated = [[notification.userInfo objectForKey:kOTRProtocolLoginUserInitiated] boolValue];

UIViewController *topViewController = [self topViewController];
if ([topViewController isKindOfClass:[UINavigationController class]]) {
topViewController = ((UINavigationController *)topViewController).topViewController;
}

BOOL correctViewController = !([topViewController isKindOfClass:[OTRBaseLoginViewController class]] || [topViewController isKindOfClass:[OTRSettingsViewController class]]);


if (correctViewController && isUserInitiated) {
OTRXMPPManager *xmppManager = notification.object;
NSString *accountName = nil;
if (xmppManager) {
accountName = [xmppManager accountName];
accountName = [XMPPJID jidWithString:accountName].bare;
}
//OTRToastOptions *options = [[OTRToastOptions alloc] initWithText:ACCOUNT_DISCONNECTED_STRING subtitleText:accountName optionType:OTRToastOptionTypeFailure];
//[CRToastManager showNotificationWithOptions:[options dictionary] completionBlock:nil];
}
}

#pragma - mark Public Methods
Expand Down
12 changes: 5 additions & 7 deletions ChatSecure/Classes/Controllers/OTRProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ typedef NS_ENUM(NSInteger, OTRLoginStatus) {

- (void) sendMessage:(OTRMessage*)message;

- (void) connectWithPassword:(NSString *)password;
- (void) connectWithPassword:(NSString *)password userInitiated:(BOOL)userInitiated;
- (void) connect;
- (void) connectUserInitiated:(BOOL)userInitiated;

- (void) disconnect;
- (void) disconnectSocketOnly:(BOOL)socketOnly;
- (void) addBuddy:(OTRBuddy *)newBuddy;

- (void) removeBuddies:(NSArray *)buddies;
- (void) blockBuddies:(NSArray *)buddies;
- (void) removeBuddies:(NSArray<OTRBuddy*> *)buddies;
- (void) blockBuddies:(NSArray<OTRBuddy*> *)buddies;

- (id) initWithAccount:(OTRAccount*)account;

Expand All @@ -71,6 +71,4 @@ typedef NS_ENUM(NSInteger, OTRLoginStatus) {
@protocol OTRXMPPProtocol <OTRProtocol>
- (void)sendChatState:(int)chatState withBuddy:(OTRBuddy *)buddy;
- (void) setDisplayName:(NSString *) newDisplayName forBuddy:(OTRBuddy *)buddy;

- (void) teardownStream;
@end
@end
8 changes: 4 additions & 4 deletions ChatSecure/Classes/Controllers/OTRProtocolManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ - (void)removeProtocolForAccount:(OTRAccount *)account
@synchronized(self.protocolManagerDictionary) {
if (account) {
id protocol = [self.protocolManagerDictionary objectForKey:account.uniqueId];
if (protocol && [protocol respondsToSelector:@selector(teardownStream)]) {
[protocol teardownStream];
if (protocol && [protocol respondsToSelector:@selector(disconnect)]) {
[protocol disconnect];
}
[self.KVOController unobserve:protocol];
[self.protocolManagerDictionary removeObjectForKey:account.uniqueId];
Expand Down Expand Up @@ -156,7 +156,7 @@ - (void)loginAccount:(OTRAccount *)account userInitiated:(BOOL)userInitiated
[OTROAuthRefresher refreshAccount:(OTROAuthXMPPAccount *)account completion:^(id token, NSError *error) {
if (!error) {
((OTROAuthXMPPAccount *)account).accountSpecificToken = token;
[protocol connectWithPassword:account.password userInitiated:userInitiated];
[protocol connectUserInitiated:userInitiated];
}
else {
DDLogError(@"Error Refreshing Token");
Expand All @@ -165,7 +165,7 @@ - (void)loginAccount:(OTRAccount *)account userInitiated:(BOOL)userInitiated
}
else
{
[protocol connectWithPassword:account.password userInitiated:userInitiated];
[protocol connectUserInitiated:userInitiated];
}
}

Expand Down
68 changes: 68 additions & 0 deletions ChatSecure/Classes/Controllers/OTRXMPPMessageStatusModule.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// OTRXMPPMessageStatusModule.swift
// ChatSecure
//
// Created by David Chiles on 5/5/16.
// Copyright © 2016 Chris Ballinger. All rights reserved.
//

import Foundation
import XMPPFramework

@objc public protocol OTRXMPPMessageStatusModuleDelegate {
func didSendMessage(messageKey:String, messageCollection:String)
func didFailToSendMessage(messageKey:String, messageCollection:String, error:NSError?)
}

/**
This is a simple XMPP module that translates xmpp message events to OTRMessageEvents for the delegate.
Should be used in coordination with MessageQueueHandler.
*/
@objc public class OTRXMPPMessageStatusModule:XMPPModule,XMPPStreamDelegate {

let databaseConnection:YapDatabaseConnection
var delegate:OTRXMPPMessageStatusModuleDelegate?
var delegateQueue = dispatch_queue_create("OTRXMPPMessageStatusModuleDelegate", DISPATCH_QUEUE_SERIAL)

public init(databaseConnection:YapDatabaseConnection, delegate:OTRXMPPMessageStatusModuleDelegate?) {
self.delegate = delegate
self.databaseConnection = databaseConnection
super.init(dispatchQueue: nil)
}

//Mark: YapDatbase functions

private func fetchMessage(XMPPId:String) -> OTRMessageProtocol? {
var message:OTRMessageProtocol? = nil
self.databaseConnection.readWithBlock { (transaction) in
message = OTRMessage.messageForMessageId(XMPPId, incoming: false, transaction: transaction)
}
return message
}

//Mark: XMPPStream delegate functions
public func xmppStream(sender: XMPPStream!, didSendMessage message: XMPPMessage!) {

guard let messageId = message.attributeStringValueForName("id") where message.isChatMessage() else {
return
}

if let message = self.fetchMessage(messageId) {
self.delegate?.didSendMessage(message.messageKey(), messageCollection: message.messageCollection())
}
}

public func xmppStream(sender: XMPPStream!, didFailToSendMessage message: XMPPMessage!, error: NSError!) {

guard let messageId = message.attributeStringValueForName("id") where message.isChatMessage() else {
return
}

if let message = self.fetchMessage(messageId) {
self.delegate?.didFailToSendMessage(message.messageKey(), messageCollection: message.messageCollection(), error: error)
}

}


}
Loading

0 comments on commit 4b0c753

Please sign in to comment.