Skip to content

Commit

Permalink
Fixed "issues" reported by AppStore review team and version bump to 3…
Browse files Browse the repository at this point in the history
….5b73 #beagleim-190
  • Loading branch information
hantu85 committed Jan 25, 2020
1 parent cf06e52 commit 1879508
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 96 deletions.
4 changes: 2 additions & 2 deletions .xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 72;
CURRENT_PROJECT_VERSION = 73;
DEVELOPMENT_TEAM = YBEYW6E35C;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1208,7 +1208,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 72;
CURRENT_PROJECT_VERSION = 73;
DEVELOPMENT_TEAM = YBEYW6E35C;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
86 changes: 20 additions & 66 deletions BeagleIM/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
return;
}

// TODO: remove in the next version
switch id {
case "authentication-failure":
guard let _ = BareJID(userInfo["account"] as? String) else {
Expand Down Expand Up @@ -628,60 +629,33 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
return;
}

let id = "authenticationError.\(accountName.stringValue)";

if #available(OSX 10.14, *) {
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [id]);

let content = UNMutableNotificationContent();
content.title = accountName.stringValue;
content.subtitle = "Authentication failure";
DispatchQueue.main.async {
let alert = Alert();
alert.messageText = "Authentication failure for \(accountName.stringValue)";
switch error {
case .aborted, .temporary_auth_failure:
content.body = "Temporary authetnication failure, will retry..";
// those are temporary errors and we will retry, so there is no point in notifying user...
return;
case .invalid_mechanism:
content.body = "Required authentication mechanism not supported";
alert.informativeText = "Required authentication mechanism not supported";
case .mechanism_too_weak:
content.body = "Authentication mechanism is too weak for authentication";
alert.informativeText = "Authentication mechanism is too weak for authentication";
case .incorrect_encoding, .invalid_authzid, .not_authorized:
content.body = "Invalid password for account";
alert.informativeText = "Invalid password for account";
case .server_not_trusted:
content.body = "It was not possible to verify that server is trusted";
}
content.sound = UNNotificationSound.defaultCritical;
content.userInfo = ["account": accountName.stringValue, "id": "authentication-failure"];
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil);
UNUserNotificationCenter.current().add(request) { (error) in
print("could not show notification:", error as Any);
}
} else {
// invalidate old auth error notification if there is any
NSUserNotificationCenter.default.deliveredNotifications.filter { (n) -> Bool in
return n.identifier == id;
}.forEach { (n) in
NSUserNotificationCenter.default.removeDeliveredNotification(n);
alert.informativeText = "It was not possible to verify that server is trusted";
}

let notification = NSUserNotification();
notification.identifier = UUID().uuidString;
notification.title = accountName.stringValue;
notification.subtitle = "Authentication failure";
switch error {
case .aborted, .temporary_auth_failure:
notification.informativeText = "Temporary authetnication failure, will retry..";
case .invalid_mechanism:
notification.informativeText = "Required authentication mechanism not supported";
case .mechanism_too_weak:
notification.informativeText = "Authentication mechanism is too weak for authentication";
case .incorrect_encoding, .invalid_authzid, .not_authorized:
notification.informativeText = "Invalid password for account";
case .server_not_trusted:
notification.informativeText = "It was not possible to verify that server is trusted";
}
notification.soundName = NSUserNotificationDefaultSoundName;
notification.userInfo = ["account": accountName.stringValue, "id": "authentication-failure"];
NSUserNotificationCenter.default.deliver(notification);
}
alert.icon = NSImage(named: NSImage.cautionName);
alert.addButton(withTitle: "OK");
alert.run(completionHandler: { response in
guard let windowController = (NSApplication.shared.delegate as? AppDelegate)?.preferencesWindowController else {
return;
}
(windowController.contentViewController as? NSTabViewController)?.selectedTabViewItemIndex = 1;
windowController.showWindow(self);
})
}
}

@objc func chatUpdated(_ notification: Notification) {
Expand Down Expand Up @@ -822,26 +796,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
return;
}

if #available(OSX 10.14, *) {
let content = UNMutableNotificationContent();
content.title = "Unknown SSL certificate";
content.subtitle = "SSL certificate could not be verified.";
content.body = "Account \(accountName) was disabled.";
content.sound = UNNotificationSound.defaultCritical;
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil);
UNUserNotificationCenter.current().add(request) { (error) in
print("could not show notification:", error as Any);
}
} else {
let notification = NSUserNotification();
notification.identifier = UUID().uuidString;
notification.title = "Unknown SSL certificate";
notification.subtitle = "SSL certificate could not be verified.";
notification.informativeText = "Account \(accountName) was disabled.";
notification.soundName = NSUserNotificationDefaultSoundName;
NSUserNotificationCenter.default.deliver(notification);
}

DispatchQueue.main.async {
guard let windowController = NSStoryboard(name: "Main", bundle: nil).instantiateController(withIdentifier: "ServerCertificateErrorWindowController") as? NSWindowController else {
return;
Expand Down
11 changes: 6 additions & 5 deletions BeagleIM/chatslist/ChatCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ class ChatCellView: NSTableCellView {
self.avatar?.name = name;
}

func set(lastActivity: LastChatActivity?, ts: Date?) {
func set(lastActivity: LastChatActivity?, ts: Date?, chatState: ChatState) {
self.chatState = chatState;
if chatState != .composing {
self.lastMessage?.stopAnimating();
if let activity = lastActivity {
switch activity {
case .message(let lastMessage):
Expand All @@ -94,9 +96,11 @@ class ChatCellView: NSTableCellView {
self.lastMessage?.maximumNumberOfLines = 3;
} else {
self.lastMessage?.stringValue = "";
self.lastMessage?.startAnimating();
}
//self.lastMessage?.preferredMaxLayoutWidth = self.lastMessage!.frame.width;
self.lastMessageTs?.stringValue = ts != nil ? formatTimestamp(ts!) : "";
self.lastMessage?.invalidateIntrinsicContentSize();
}

func set(chatState: ChatState) {
Expand Down Expand Up @@ -139,10 +143,7 @@ class ChatCellView: NSTableCellView {
func update(from item: ChatItemProtocol) {
self.set(name: item.name);
self.set(unread: item.unread);
if let chat = item.chat as? DBChatStore.DBChat {
self.set(chatState: chat.remoteChatState ?? .active);
}
self.set(lastActivity: item.lastActivity, ts: item.lastMessageTs);
self.set(lastActivity: item.lastActivity, ts: item.lastMessageTs, chatState: (item.chat as? DBChatStore.DBChat)?.remoteChatState ?? .active);
if item.chat is Chat {
self.avatar.update(for: item.chat.jid.bareJid, on: item.chat.account);
} else if let room = item.chat as? Room {
Expand Down
50 changes: 27 additions & 23 deletions BeagleIM/service/MucEventHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,29 +128,33 @@ class MucEventHandler: XmppServiceEventHandler {
}
print("received error from room:", e.room as Any, ", error:", error)

if #available(OSX 10.14, *) {
let content = UNMutableNotificationContent();
content.title = "Room \(e.room.roomJid.stringValue)";
content.body = "Could not join room. Reason:\n\(error.reason)";
content.sound = UNNotificationSound.defaultCritical;
if error != .banned && error != .registrationRequired {
content.userInfo = ["account": e.sessionObject.userBareJid!.stringValue, "roomJid": e.room.roomJid.stringValue, "nickname": e.room.nickname, "id": "room-join-error"];
}
let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: nil);
UNUserNotificationCenter.current().add(request) { (error) in
print("could not show notification:", error as Any);
}
} else {
let notification = NSUserNotification();
notification.identifier = UUID().uuidString;
notification.title = "Room \(e.room.roomJid.stringValue)";
notification.informativeText = "Could not join room. Reason:\n\(error.reason)";
notification.soundName = NSUserNotificationDefaultSoundName;
notification.contentImage = NSImage(named: NSImage.userGroupName);
if error != .banned && error != .registrationRequired {
notification.userInfo = ["account": e.sessionObject.userBareJid!.stringValue, "roomJid": e.room.roomJid.stringValue, "nickname": e.room.nickname, "id": "room-join-error"];
}
NSUserNotificationCenter.default.deliver(notification);
DispatchQueue.main.async {
let alert = Alert();
alert.messageText = "Room \(e.room.roomJid.stringValue)";
alert.informativeText = "Could not join room. Reason:\n\(error.reason)";
alert.icon = NSImage(named: NSImage.userGroupName);
alert.addButton(withTitle: "OK");
alert.run(completionHandler: { response in
if error != .banned && error != .registrationRequired {
let storyboard = NSStoryboard(name: "Main", bundle: nil);
guard let windowController = storyboard.instantiateController(withIdentifier: "OpenGroupchatController") as? NSWindowController else {
return;
}
guard let openRoomController = windowController.contentViewController as? OpenGroupchatController else {
return;
}
let roomJid = e.room.roomJid;
openRoomController.searchField.stringValue = roomJid.stringValue;
openRoomController.mucJids = [BareJID(roomJid.domain)];
openRoomController.account = e.sessionObject.userBareJid!;
openRoomController.nicknameField.stringValue = e.room.nickname;
guard let window = (NSApplication.shared.delegate as? AppDelegate)?.mainWindowController?.window else {
return;
}
window.windowController?.showWindow(self);
window.beginSheet(windowController.window!, completionHandler: nil);
}
})
}

guard let mucModule: MucModule = XmppService.instance.getClient(for: e.sessionObject.userBareJid!)?.modulesManager.getModule(MucModule.ID) else {
Expand Down
3 changes: 3 additions & 0 deletions BeagleIM/ui/ChatCellViewMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ class ChatCellViewMessage: NSTextField {
}

func stopAnimating() {
guard !dotLayers.isEmpty else {
return;
}
dotLayers.forEach { (layer) in
layer.removeAllAnimations();
}
Expand Down

0 comments on commit 1879508

Please sign in to comment.