diff --git a/CHANGES.rst b/CHANGES.rst index 50a63ae90..4f8c56c2a 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,10 @@ +Changes in MatrixKit in 0.7.16 () +========================================== + +Improvements: + * MXKRoomDataSource: Add send reply with text message (vector-im/riot-ios#1911). + + Changes in MatrixKit in 0.7.15 (2018-07-03) ========================================== diff --git a/MatrixKit.xcodeproj/project.pbxproj b/MatrixKit.xcodeproj/project.pbxproj index 4552f1d0b..f46895556 100644 --- a/MatrixKit.xcodeproj/project.pbxproj +++ b/MatrixKit.xcodeproj/project.pbxproj @@ -53,6 +53,8 @@ B12C470C20BECAF8004FBF96 /* MXKErrorViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = B12C470920BECAF7004FBF96 /* MXKErrorViewModel.m */; }; B12C470D20BECAF8004FBF96 /* MXKErrorAlertPresentation.m in Sources */ = {isa = PBXBuildFile; fileRef = B12C470A20BECAF7004FBF96 /* MXKErrorAlertPresentation.m */; }; B12C471020BED312004FBF96 /* MXKErrorPresentableBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = B12C470F20BED312004FBF96 /* MXKErrorPresentableBuilder.m */; }; + B164380C210603CD00DBB3FD /* MXKSendReplyEventStringLocalizations.m in Sources */ = {isa = PBXBuildFile; fileRef = B164380B210603CD00DBB3FD /* MXKSendReplyEventStringLocalizations.m */; }; + B1668AC021072F93002B14F1 /* MXKSlashCommands.m in Sources */ = {isa = PBXBuildFile; fileRef = B1668ABF21072F93002B14F1 /* MXKSlashCommands.m */; }; CE14CA661E80122600E329A3 /* MXKAttachmentAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = CE14CA631E80122600E329A3 /* MXKAttachmentAnimator.m */; }; CE14CA671E80122600E329A3 /* MXKAttachmentInteractionController.m in Sources */ = {isa = PBXBuildFile; fileRef = CE14CA651E80122600E329A3 /* MXKAttachmentInteractionController.m */; }; F0026B661C91EED1001D2C04 /* MXKWebViewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F0026B651C91EED1001D2C04 /* MXKWebViewViewController.m */; }; @@ -331,6 +333,10 @@ B12C470B20BECAF7004FBF96 /* MXKErrorPresentable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXKErrorPresentable.h; sourceTree = ""; }; B12C470E20BED312004FBF96 /* MXKErrorPresentableBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXKErrorPresentableBuilder.h; sourceTree = ""; }; B12C470F20BED312004FBF96 /* MXKErrorPresentableBuilder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXKErrorPresentableBuilder.m; sourceTree = ""; }; + B164380A210603CD00DBB3FD /* MXKSendReplyEventStringLocalizations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXKSendReplyEventStringLocalizations.h; sourceTree = ""; }; + B164380B210603CD00DBB3FD /* MXKSendReplyEventStringLocalizations.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXKSendReplyEventStringLocalizations.m; sourceTree = ""; }; + B1668ABE21072F93002B14F1 /* MXKSlashCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXKSlashCommands.h; sourceTree = ""; }; + B1668ABF21072F93002B14F1 /* MXKSlashCommands.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXKSlashCommands.m; sourceTree = ""; }; BFDF88630F521F8C5854F64F /* Pods-MatrixKitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MatrixKitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MatrixKitTests/Pods-MatrixKitTests.debug.xcconfig"; sourceTree = ""; }; C1C97E32A7F1D6C4B99A47EF /* Pods-MatrixKitSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MatrixKitSample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MatrixKitSample/Pods-MatrixKitSample.debug.xcconfig"; sourceTree = ""; }; CE14CA621E80122600E329A3 /* MXKAttachmentAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MXKAttachmentAnimator.h; sourceTree = ""; }; @@ -1148,6 +1154,10 @@ F07E180C1ABC2EDA00DE3766 /* MXKRoomDataSource.m */, 3230A3731ACADC1800CC57F5 /* MXKRoomDataSourceManager.h */, 3230A3741ACADC1800CC57F5 /* MXKRoomDataSourceManager.m */, + B164380A210603CD00DBB3FD /* MXKSendReplyEventStringLocalizations.h */, + B164380B210603CD00DBB3FD /* MXKSendReplyEventStringLocalizations.m */, + B1668ABE21072F93002B14F1 /* MXKSlashCommands.h */, + B1668ABF21072F93002B14F1 /* MXKSlashCommands.m */, ); path = Room; sourceTree = ""; @@ -1669,6 +1679,7 @@ F04356321B2EF6FD0096FA02 /* MXKRoomMemberDetailsViewController.m in Sources */, F095E5101B25899F009606CE /* MXKEmail.m in Sources */, 321313C91AEFC2D500A9B035 /* MXKRoomIOSOutgoingBubbleTableViewCell.m in Sources */, + B164380C210603CD00DBB3FD /* MXKSendReplyEventStringLocalizations.m in Sources */, F0FDF2671E53586A00D23C47 /* MXKCountryPickerViewController.m in Sources */, B12C471020BED312004FBF96 /* MXKErrorPresentableBuilder.m in Sources */, F00FA85C1C0867F900E25826 /* MXKRoomIncomingAttachmentBubbleCell.m in Sources */, @@ -1771,6 +1782,7 @@ F02528961C1092D300E1FE1B /* MXKCollectionViewCell.m in Sources */, F0F148A61AB08F48005F5D4A /* MXKSampleJSQRoomDataSource.m in Sources */, F096A3BF1B0B3DAA00AF1357 /* MXKAccountDetailsViewController.m in Sources */, + B1668AC021072F93002B14F1 /* MXKSlashCommands.m in Sources */, F0CF98FD1B0CDF6100EAE373 /* MXKTableViewCellWithButton.m in Sources */, F095E50D1B25899F009606CE /* MXKContact.m in Sources */, F0F148A51AB08F48005F5D4A /* MXKSampleJSQRoomBubbleCellData.m in Sources */, diff --git a/MatrixKit/Assets/MatrixKitAssets.bundle/en.lproj/MatrixKit.strings b/MatrixKit/Assets/MatrixKitAssets.bundle/en.lproj/MatrixKit.strings index 18be4f899..fa4e519c8 100644 --- a/MatrixKit/Assets/MatrixKitAssets.bundle/en.lproj/MatrixKit.strings +++ b/MatrixKit/Assets/MatrixKitAssets.bundle/en.lproj/MatrixKit.strings @@ -219,6 +219,13 @@ "room_no_power_to_create_conference_call" = "You need permission to invite to start a conference in this room"; "room_no_conference_call_in_encrypted_rooms" = "Conference calls are not supported in encrypted rooms"; +// Reply to message +"message_reply_to_sender_sent_an_image" = "sent an image."; +"message_reply_to_sender_sent_a_video" = "sent a video."; +"message_reply_to_sender_sent_an_audio_file" = "sent an audio file."; +"message_reply_to_sender_sent_a_file" = "sent a file."; +"message_reply_to_message_to_reply_to_prefix" = "In reply to"; + // Room members "room_member_ignore_prompt" = "Are you sure you want to hide all messages from this user?"; "room_member_power_level_prompt" = "You will not be able to undo this change as you are promoting the user to have the same power level as yourself.\nAre you sure?"; diff --git a/MatrixKit/Controllers/MXKRoomViewController.h b/MatrixKit/Controllers/MXKRoomViewController.h index 943a07987..cf1bd6525 100644 --- a/MatrixKit/Controllers/MXKRoomViewController.h +++ b/MatrixKit/Controllers/MXKRoomViewController.h @@ -26,18 +26,6 @@ limitations under the License. #import "MXKAttachmentsViewController.h" #import "MXKAttachmentAnimator.h" -extern NSString *const kCmdChangeDisplayName; -extern NSString *const kCmdEmote; -extern NSString *const kCmdJoinRoom; -extern NSString *const kCmdPartRoom; -extern NSString *const kCmdInviteUser; -extern NSString *const kCmdKickUser; -extern NSString *const kCmdBanUser; -extern NSString *const kCmdUnbanUser; -extern NSString *const kCmdSetUserPowerLevel; -extern NSString *const kCmdResetUserPowerLevel; -extern NSString *const kCmdChangeRoomTopic; - /** This view controller displays messages of a room. Only one matrix session is handled by this view controller. */ diff --git a/MatrixKit/Controllers/MXKRoomViewController.m b/MatrixKit/Controllers/MXKRoomViewController.m index 2a17bdf2c..5ff90076f 100644 --- a/MatrixKit/Controllers/MXKRoomViewController.m +++ b/MatrixKit/Controllers/MXKRoomViewController.m @@ -49,18 +49,7 @@ #import "NSBundle+MatrixKit.h" #import "UIScrollView+MatrixKit.h" - -NSString *const kCmdChangeDisplayName = @"/nick"; -NSString *const kCmdEmote = @"/me"; -NSString *const kCmdJoinRoom = @"/join"; -NSString *const kCmdPartRoom = @"/part"; -NSString *const kCmdInviteUser = @"/invite"; -NSString *const kCmdKickUser = @"/kick"; -NSString *const kCmdBanUser = @"/ban"; -NSString *const kCmdUnbanUser = @"/unban"; -NSString *const kCmdSetUserPowerLevel = @"/op"; -NSString *const kCmdResetUserPowerLevel = @"/deop"; -NSString *const kCmdChangeRoomTopic = @"/topic"; +#import "MXKSlashCommands.h" @interface MXKRoomViewController () { @@ -1313,20 +1302,20 @@ - (BOOL)isIRCStyleCommand:(NSString*)string // TODO: display an alert with the cmd usage in case of error or unrecognized cmd. NSString *cmdUsage; - if ([cmd isEqualToString:kCmdEmote]) + if ([cmd isEqualToString:kMXKSlashCmdEmote]) { // send message as an emote [self sendTextMessage:string]; } - else if ([string hasPrefix:kCmdChangeDisplayName]) + else if ([string hasPrefix:kMXKSlashCmdChangeDisplayName]) { // Change display name NSString *displayName; // Sanity check - if (string.length > kCmdChangeDisplayName.length) + if (string.length > kMXKSlashCmdChangeDisplayName.length) { - displayName = [string substringFromIndex:kCmdChangeDisplayName.length + 1]; + displayName = [string substringFromIndex:kMXKSlashCmdChangeDisplayName.length + 1]; // Remove white space from both ends displayName = [displayName stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; @@ -1351,15 +1340,15 @@ - (BOOL)isIRCStyleCommand:(NSString*)string cmdUsage = @"Usage: /nick "; } } - else if ([string hasPrefix:kCmdJoinRoom]) + else if ([string hasPrefix:kMXKSlashCmdJoinRoom]) { // Join a room NSString *roomAlias; // Sanity check - if (string.length > kCmdJoinRoom.length) + if (string.length > kMXKSlashCmdJoinRoom.length) { - roomAlias = [string substringFromIndex:kCmdJoinRoom.length + 1]; + roomAlias = [string substringFromIndex:kMXKSlashCmdJoinRoom.length + 1]; // Remove white space from both ends roomAlias = [roomAlias stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; @@ -1385,16 +1374,16 @@ - (BOOL)isIRCStyleCommand:(NSString*)string cmdUsage = @"Usage: /join "; } } - else if ([string hasPrefix:kCmdPartRoom]) + else if ([string hasPrefix:kMXKSlashCmdPartRoom]) { // Leave this room or another one NSString *roomId; NSString *roomIdOrAlias; // Sanity check - if (string.length > kCmdPartRoom.length) + if (string.length > kMXKSlashCmdPartRoom.length) { - roomIdOrAlias = [string substringFromIndex:kCmdPartRoom.length + 1]; + roomIdOrAlias = [string substringFromIndex:kMXKSlashCmdPartRoom.length + 1]; // Remove white space from both ends roomIdOrAlias = [roomIdOrAlias stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; @@ -1443,15 +1432,15 @@ - (BOOL)isIRCStyleCommand:(NSString*)string cmdUsage = @"Usage: /part []"; } } - else if ([string hasPrefix:kCmdChangeRoomTopic]) + else if ([string hasPrefix:kMXKSlashCmdChangeRoomTopic]) { // Change topic NSString *topic; // Sanity check - if (string.length > kCmdChangeRoomTopic.length) + if (string.length > kMXKSlashCmdChangeRoomTopic.length) { - topic = [string substringFromIndex:kCmdChangeRoomTopic.length + 1]; + topic = [string substringFromIndex:kMXKSlashCmdChangeRoomTopic.length + 1]; // Remove white space from both ends topic = [topic stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; } @@ -1491,7 +1480,7 @@ - (BOOL)isIRCStyleCommand:(NSString*)string userId = nil; } - if ([cmd isEqualToString:kCmdInviteUser]) + if ([cmd isEqualToString:kMXKSlashCmdInviteUser]) { if (userId) { @@ -1513,7 +1502,7 @@ - (BOOL)isIRCStyleCommand:(NSString*)string cmdUsage = @"Usage: /invite "; } } - else if ([cmd isEqualToString:kCmdKickUser]) + else if ([cmd isEqualToString:kMXKSlashCmdKickUser]) { if (userId) { @@ -1548,7 +1537,7 @@ - (BOOL)isIRCStyleCommand:(NSString*)string cmdUsage = @"Usage: /kick []"; } } - else if ([cmd isEqualToString:kCmdBanUser]) + else if ([cmd isEqualToString:kMXKSlashCmdBanUser]) { if (userId) { @@ -1583,7 +1572,7 @@ - (BOOL)isIRCStyleCommand:(NSString*)string cmdUsage = @"Usage: /ban []"; } } - else if ([cmd isEqualToString:kCmdUnbanUser]) + else if ([cmd isEqualToString:kMXKSlashCmdUnbanUser]) { if (userId) { @@ -1605,7 +1594,7 @@ - (BOOL)isIRCStyleCommand:(NSString*)string cmdUsage = @"Usage: /unban "; } } - else if ([cmd isEqualToString:kCmdSetUserPowerLevel]) + else if ([cmd isEqualToString:kMXKSlashCmdSetUserPowerLevel]) { // Retrieve power level NSString *powerLevel = nil; @@ -1641,7 +1630,7 @@ - (BOOL)isIRCStyleCommand:(NSString*)string cmdUsage = @"Usage: /op "; } } - else if ([cmd isEqualToString:kCmdResetUserPowerLevel]) + else if ([cmd isEqualToString:kMXKSlashCmdResetUserPowerLevel]) { if (userId) { diff --git a/MatrixKit/Models/Room/MXKRoomDataSource.h b/MatrixKit/Models/Room/MXKRoomDataSource.h index 755c16fa2..519d8d3f7 100644 --- a/MatrixKit/Models/Room/MXKRoomDataSource.h +++ b/MatrixKit/Models/Room/MXKRoomDataSource.h @@ -347,6 +347,25 @@ extern NSString *const kMXKRoomDataSourceTimelineErrorErrorKey; success:(void (^)(NSString *eventId))success failure:(void (^)(NSError *error))failure; +/** + Send a reply to an event with text message to the room. + + While sending, a fake event will be echoed in the messages list. + Once complete, this local echo will be replaced by the event saved by the homeserver. + + @param eventIdToReply the id of event to reply. + @param text the text to send. + @param success A block object called when the operation succeeds. It returns + the event id of the event generated on the home server + @param failure A block object called when the operation fails. + */ +- (void)sendReplyToEventWithId:(NSString*)eventIdToReply + withTextMessage:(NSString *)text + success:(void (^)(NSString *))success + failure:(void (^)(NSError *))failure; + +- (BOOL)canReplyToEventWithId:(NSString*)eventIdToReply; + /** Send an image to the room. diff --git a/MatrixKit/Models/Room/MXKRoomDataSource.m b/MatrixKit/Models/Room/MXKRoomDataSource.m index 133b76d1c..12d385329 100644 --- a/MatrixKit/Models/Room/MXKRoomDataSource.m +++ b/MatrixKit/Models/Room/MXKRoomDataSource.m @@ -29,6 +29,9 @@ #import "MXEncryptedAttachments.h" +#import "MXKSendReplyEventStringLocalizations.h" +#import "MXKSlashCommands.h" + #pragma mark - Constant definitions NSString *const kMXKRoomBubbleCellDataIdentifier = @"kMXKRoomBubbleCellDataIdentifier"; @@ -137,6 +140,11 @@ Current pagination request (if any) Observe kMXRoomDidUpdateUnreadNotification to refresh unread counters. */ id roomDidUpdateUnreadNotificationObserver; + + /** + Emote slash command prefix @"/me " + */ + NSString *emoteMessageSlashCommandPrefix; } @end @@ -159,6 +167,8 @@ - (instancetype)initWithRoomId:(NSString *)roomId andMatrixSession:(MXSession *) externalRelatedGroups = [NSMutableDictionary dictionary]; _filterMessagesWithURL = NO; + + emoteMessageSlashCommandPrefix = [NSString stringWithFormat:@"%@ ", kMXKSlashCmdEmote]; // Set default data and view classes // Cell data @@ -1175,6 +1185,63 @@ - (void)paginateToFillRect:(CGRect)rect direction:(MXTimelineDirection)direction #pragma mark - Sending - (void)sendTextMessage:(NSString *)text success:(void (^)(NSString *))success failure:(void (^)(NSError *))failure { + __block MXEvent *localEchoEvent = nil; + + BOOL isEmote = [self isMessageAnEmote:text]; + NSString *sanitizedText = [self sanitizedMessageText:text]; + NSString *html = [self htmlMessageFromSanitizedText:sanitizedText]; + + // Make the request to the homeserver + if (isEmote) + { + [_room sendEmote:sanitizedText formattedText:html localEcho:&localEchoEvent success:success failure:failure]; + } + else + { + [_room sendTextMessage:sanitizedText formattedText:html localEcho:&localEchoEvent success:success failure:failure]; + } + + if (localEchoEvent) + { + // Make the data source digest this fake local echo message + [self queueEventForProcessing:localEchoEvent withRoomState:_room.state direction:MXTimelineDirectionForwards]; + [self processQueuedEvents:nil]; + } +} + +- (void)sendReplyToEventWithId:(NSString*)eventIdToReply + withTextMessage:(NSString *)text + success:(void (^)(NSString *))success + failure:(void (^)(NSError *))failure +{ + MXEvent *eventToReply = [self eventWithEventId:eventIdToReply]; + + __block MXEvent *localEchoEvent = nil; + + NSString *sanitizedText = [self sanitizedMessageText:text]; + NSString *html = [self htmlMessageFromSanitizedText:sanitizedText]; + + id stringLocalizations = [MXKSendReplyEventStringLocalizations new]; + + [_room sendReplyToEvent:eventToReply withTextMessage:sanitizedText formattedTextMessage:html stringLocalizations:stringLocalizations localEcho:&localEchoEvent success:success failure:failure]; + + if (localEchoEvent) + { + // Make the data source digest this fake local echo message + [self queueEventForProcessing:localEchoEvent withRoomState:_room.state direction:MXTimelineDirectionForwards]; + [self processQueuedEvents:nil]; + } +} + +- (BOOL)isMessageAnEmote:(NSString*)text +{ + return [text hasPrefix:emoteMessageSlashCommandPrefix]; +} + +- (NSString*)sanitizedMessageText:(NSString*)rawText +{ + NSString *text; + //Remove NULL bytes from the string, as they are likely to trip up many things later, //including our own C-based Markdown-to-HTML convertor. // @@ -1187,44 +1254,36 @@ - (void)sendTextMessage:(NSString *)text success:(void (^)(NSString *))success f // //Even if a future iOS update fixes this, //we'd better be defensive and always remove occurrences of NULL bytes from text messages. - text = [text stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%C", 0x00000000] withString:@""]; - + text = [rawText stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%C", 0x00000000] withString:@""]; + // Check whether the message is an emote - BOOL isEmote = NO; - if ([text hasPrefix:@"/me "]) + if ([self isMessageAnEmote:text]) { - isEmote = YES; - // Remove "/me " string - text = [text substringFromIndex:4]; + text = [text substringFromIndex:emoteMessageSlashCommandPrefix.length]; } + return text; +} + +- (NSString*)htmlMessageFromSanitizedText:(NSString*)sanitizedText +{ + NSString *html; + // Did user use Markdown text? - NSString *html = [_eventFormatter htmlStringFromMarkdownString:text]; - if ([html isEqualToString:text]) + NSString *htmlStringFromMarkdown = [_eventFormatter htmlStringFromMarkdownString:sanitizedText]; + + if ([htmlStringFromMarkdown isEqualToString:sanitizedText]) { // No formatted string html = nil; } - - __block MXEvent *localEchoEvent = nil; - - // Make the request to the homeserver - if (isEmote) - { - [_room sendEmote:text formattedText:html localEcho:&localEchoEvent success:success failure:failure]; - } else { - [_room sendTextMessage:text formattedText:html localEcho:&localEchoEvent success:success failure:failure]; + html = htmlStringFromMarkdown; } - if (localEchoEvent) - { - // Make the data source digest this fake local echo message - [self queueEventForProcessing:localEchoEvent withRoomState:_room.state direction:MXTimelineDirectionForwards]; - [self processQueuedEvents:nil]; - } + return html; } - (void)sendImage:(UIImage *)image success:(void (^)(NSString *))success failure:(void (^)(NSError *))failure @@ -1251,6 +1310,12 @@ - (void)sendImage:(UIImage *)image success:(void (^)(NSString *))success failure [self sendImageData:imageData withImageSize:image.size mimeType:mimetype andThumbnail:thumbnail success:success failure:failure]; } +- (BOOL)canReplyToEventWithId:(NSString*)eventIdToReply +{ + MXEvent *eventToReply = [self eventWithEventId:eventIdToReply]; + return [self.room canReplyToEvent:eventToReply]; +} + - (void)sendImage:(NSData *)imageData mimeType:(NSString *)mimetype success:(void (^)(NSString *))success failure:(void (^)(NSError *))failure { UIImage *image = [UIImage imageWithData:imageData]; diff --git a/MatrixKit/Models/Room/MXKSendReplyEventStringLocalizations.h b/MatrixKit/Models/Room/MXKSendReplyEventStringLocalizations.h new file mode 100644 index 000000000..5ffa33dcd --- /dev/null +++ b/MatrixKit/Models/Room/MXKSendReplyEventStringLocalizations.h @@ -0,0 +1,31 @@ +/* + Copyright 2018 New Vector Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import +#import + +/** + A `MXKSendReplyEventStringLocalizations` instance represents string localizations used when send reply event to a message in a room. + */ +@interface MXKSendReplyEventStringLocalizations : NSObject + +@property (copy, readonly, nonnull) NSString *senderSentAnImage; +@property (copy, readonly, nonnull) NSString *senderSentAVideo; +@property (copy, readonly, nonnull) NSString *senderSentAnAudioFile; +@property (copy, readonly, nonnull) NSString *senderSentAFile; +@property (copy, readonly, nonnull) NSString *messageToReplyToPrefix; + +@end diff --git a/MatrixKit/Models/Room/MXKSendReplyEventStringLocalizations.m b/MatrixKit/Models/Room/MXKSendReplyEventStringLocalizations.m new file mode 100644 index 000000000..8eb5a9af8 --- /dev/null +++ b/MatrixKit/Models/Room/MXKSendReplyEventStringLocalizations.m @@ -0,0 +1,37 @@ +/* + Copyright 2018 New Vector Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + + +#import "MXKSendReplyEventStringLocalizations.h" + +#import "NSBundle+MatrixKit.h" + +@implementation MXKSendReplyEventStringLocalizations + +- (instancetype)init +{ + self = [super init]; + if (self) { + _senderSentAnImage = [NSBundle mxk_localizedStringForKey:@"message_reply_to_sender_sent_an_image"]; + _senderSentAVideo = [NSBundle mxk_localizedStringForKey:@"message_reply_to_sender_sent_a_video"]; + _senderSentAnAudioFile = [NSBundle mxk_localizedStringForKey:@"message_reply_to_sender_sent_an_audio_file"]; + _senderSentAFile = [NSBundle mxk_localizedStringForKey:@"message_reply_to_sender_sent_a_file"]; + _messageToReplyToPrefix = [NSBundle mxk_localizedStringForKey:@"message_reply_to_message_to_reply_to_prefix"]; + } + return self; +} + +@end diff --git a/MatrixKit/Models/Room/MXKSlashCommands.h b/MatrixKit/Models/Room/MXKSlashCommands.h new file mode 100644 index 000000000..d2791b9cf --- /dev/null +++ b/MatrixKit/Models/Room/MXKSlashCommands.h @@ -0,0 +1,33 @@ +/* + Copyright 2018 New Vector Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +@import Foundation; + +/** + Slash commands used to perform actions from a room. + */ + +FOUNDATION_EXPORT NSString *const kMXKSlashCmdChangeDisplayName; +FOUNDATION_EXPORT NSString *const kMXKSlashCmdEmote; +FOUNDATION_EXPORT NSString *const kMXKSlashCmdJoinRoom; +FOUNDATION_EXPORT NSString *const kMXKSlashCmdPartRoom; +FOUNDATION_EXPORT NSString *const kMXKSlashCmdInviteUser; +FOUNDATION_EXPORT NSString *const kMXKSlashCmdKickUser; +FOUNDATION_EXPORT NSString *const kMXKSlashCmdBanUser; +FOUNDATION_EXPORT NSString *const kMXKSlashCmdUnbanUser; +FOUNDATION_EXPORT NSString *const kMXKSlashCmdSetUserPowerLevel; +FOUNDATION_EXPORT NSString *const kMXKSlashCmdResetUserPowerLevel; +FOUNDATION_EXPORT NSString *const kMXKSlashCmdChangeRoomTopic; diff --git a/MatrixKit/Models/Room/MXKSlashCommands.m b/MatrixKit/Models/Room/MXKSlashCommands.m new file mode 100644 index 000000000..b83e42f3e --- /dev/null +++ b/MatrixKit/Models/Room/MXKSlashCommands.m @@ -0,0 +1,29 @@ +/* + Copyright 2018 New Vector Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "MXKSlashCommands.h" + +NSString *const kMXKSlashCmdChangeDisplayName = @"/nick"; +NSString *const kMXKSlashCmdEmote = @"/me"; +NSString *const kMXKSlashCmdJoinRoom = @"/join"; +NSString *const kMXKSlashCmdPartRoom = @"/part"; +NSString *const kMXKSlashCmdInviteUser = @"/invite"; +NSString *const kMXKSlashCmdKickUser = @"/kick"; +NSString *const kMXKSlashCmdBanUser = @"/ban"; +NSString *const kMXKSlashCmdUnbanUser = @"/unban"; +NSString *const kMXKSlashCmdSetUserPowerLevel = @"/op"; +NSString *const kMXKSlashCmdResetUserPowerLevel = @"/deop"; +NSString *const kMXKSlashCmdChangeRoomTopic = @"/topic";