Revision 9a71f7ed
ChatSecure/Classes/Categories/NSData+ChatSecure.swift | ||
---|---|---|
25 | 25 |
/// - returns: Data represented by this hexadecimal string. |
26 | 26 |
|
27 | 27 |
@objc public func dataFromHex() -> Data? { |
28 |
let characters = (self as String).characters
|
|
28 |
let characters = (self as String) |
|
29 | 29 |
var data = Data(capacity: characters.count / 2) |
30 | 30 |
|
31 | 31 |
let regex = try! NSRegularExpression(pattern: "[0-9a-f]{1,2}", options: .caseInsensitive) |
ChatSecure/Classes/Controllers/FileTransferManager.swift | ||
---|---|---|
512 | 512 |
/** creates downloadmessages and then downloads if needed. parent message should already be saved! @warn Do not call from within an existing db transaction! */ |
513 | 513 |
@objc public func createAndDownloadItemsIfNeeded(message: OTRMessageProtocol, readConnection: YapDatabaseConnection, force: Bool) { |
514 | 514 |
DispatchQueue.global(qos: .default).async { |
515 |
if message.messageMediaItemKey != nil || message.messageText?.characters.count == 0 || message.downloadableURLs.count == 0 {
|
|
515 |
if message.messageMediaItemKey != nil || message.messageText?.count == 0 || message.downloadableURLs.count == 0 { |
|
516 | 516 |
//DDLogVerbose("Download of message not needed \(message.messageKey)") |
517 | 517 |
return |
518 | 518 |
} |
... | ... | |
828 | 828 |
} |
829 | 829 |
var urls: [URL] = [] |
830 | 830 |
var ranges: [NSRange] = [] |
831 |
let matches = detector.matches(in: self, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, self.characters.count))
|
|
831 |
let matches = detector.matches(in: self, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, self.count)) |
|
832 | 832 |
for match in matches where match.resultType == .link { |
833 | 833 |
if let url = match.url { |
834 | 834 |
urls.append(url) |
... | ... | |
849 | 849 |
let (_, ranges) = urlRanges |
850 | 850 |
guard ranges.count == 1, |
851 | 851 |
let range = ranges.first, |
852 |
range.length == self.characters.count else {
|
|
852 |
range.length == self.count else { |
|
853 | 853 |
return false |
854 | 854 |
} |
855 | 855 |
return true |
ChatSecure/Classes/Controllers/MessageQueueHandler.swift | ||
---|---|---|
561 | 561 |
} |
562 | 562 |
|
563 | 563 |
func sendOMEMOMessage(message:OTROutgoingMessage, accountProtocol:OTRXMPPManager,completion:@escaping MessageQueueHandlerCompletion) { |
564 |
guard let text = message.text, text.characters.count > 0 else {
|
|
564 |
guard let text = message.text, text.count > 0 else { |
|
565 | 565 |
completion(true, 0.0) |
566 | 566 |
return |
567 | 567 |
} |
ChatSecure/Classes/View Controllers/UserProfileViewController.swift | ||
---|---|---|
446 | 446 |
fingerprint = (otrFingerprint.fingerprint as NSData).humanReadableFingerprint() |
447 | 447 |
username = otrFingerprint.username |
448 | 448 |
} |
449 |
if fingerprint.characters.count == 0 || username.characters.count == 0 || cryptoType.characters.count == 0 {
|
|
449 |
if fingerprint.count == 0 || username.count == 0 || cryptoType.count == 0 {
|
|
450 | 450 |
return |
451 | 451 |
} |
452 | 452 |
let stringToShare = "\(username): \(cryptoType) \(fingerprint)" |
ChatSecure/Classes/Views/Cells/OMEMODeviceFingerprintCell.swift | ||
---|---|---|
17 | 17 |
//http://stackoverflow.com/a/34454633/805882 |
18 | 18 |
func splitEvery(_ n: Int) -> [String] { |
19 | 19 |
var result: [String] = [] |
20 |
let chars = Array(characters)
|
|
20 |
let chars = Array(self)
|
|
21 | 21 |
for index in stride(from: 0, to: chars.count, by: n) { |
22 | 22 |
result.append(String(chars[index..<min(index+n, chars.count)])) |
23 | 23 |
} |
ChatSecure/Classes/Views/Cells/OTRUsernameCell.swift | ||
---|---|---|
16 | 16 |
var isValid = false |
17 | 17 |
if let value = row.value as? String { |
18 | 18 |
let (username, domain) = OTRUsernameCell.splitJID(value) |
19 |
if username.characters.count > 0 && domain.characters.count > 0 {
|
|
19 |
if username.count > 0 && domain.count > 0 {
|
|
20 | 20 |
isValid = true |
21 | 21 |
} |
22 | 22 |
} |
... | ... | |
67 | 67 |
|
68 | 68 |
if let value = self.rowDescriptor!.value as? NSString { |
69 | 69 |
let (username, domain) = OTRUsernameCell.splitJID(value as String) |
70 |
if username.characters.count > 0 {
|
|
70 |
if username.count > 0 { |
|
71 | 71 |
self.usernameField.typedText = username |
72 | 72 |
} |
73 |
if domain.characters.count > 0 {
|
|
73 |
if domain.count > 0 { |
|
74 | 74 |
self.usernameField.parkedText = "@" + domain |
75 | 75 |
} |
76 | 76 |
} |
Also available in: Unified diff