Commit edea29fd authored by DanmeiChen's avatar DanmeiChen
Browse files

fix vfs display

parent 9c27bcc0
Pipeline #29525 passed with stage
in 5 minutes and 4 seconds
......@@ -57,7 +57,6 @@
@property(nonatomic) NSInteger currentIndex;
@property(nonatomic, strong) id<ChatConversationDelegate> chatRoomDelegate;
@property NSMutableDictionary<NSString *, UIImage *> *imagesInChatroom;
@property(nonatomic) BOOL vfsEnabled;
- (void)addEventEntry:(LinphoneEventLog *)event;
- (void)scrollToBottom:(BOOL)animated;
......
......@@ -183,10 +183,6 @@
#pragma mark - Property Functions
- (void)setChatRoom:(LinphoneChatRoom *)room {
if (room) {
_vfsEnabled = [VFSUtil vfsEnabledWithGroupName:kLinphoneMsgNotificationAppGroupId] && (linphone_chat_room_get_capabilities(room) & LinphoneChatRoomCapabilitiesEncrypted);
}
_chatRoom = room;
[self reloadData];
}
......@@ -270,7 +266,7 @@ static const int BASIC_EVENT_LIST=15;
UIChatBubbleTextCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId];
cell = [[NSClassFromString(kCellId) alloc] initWithIdentifier:kCellId];
[cell setEvent:event vfsEnabled:_vfsEnabled];
[cell setEvent:event];
if (chat) {
cell.isFirst = [self isFirstIndexInTableView:indexPath chat:chat];
cell.isLast = [self isLastIndexInTableView:indexPath chat:chat];
......
......@@ -1492,7 +1492,7 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog
[LinphoneManager setValueInMessageAppData:name forKey:key inMessage:message];
dispatch_async(dispatch_get_main_queue(), ^{
[NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageReceived object:view];
if ([ConfigManager.instance lpConfigBoolForKeyWithKey:@"auto_write_to_gallery_preference"]) {
if (![VFSUtil vfsEnabledWithGroupName:kLinphoneMsgNotificationAppGroupId] && [ConfigManager.instance lpConfigBoolForKeyWithKey:@"auto_write_to_gallery_preference"]) {
[ChatConversationView writeMediaToGallery:name fileType:fileType];
}
});
......
......@@ -327,6 +327,11 @@
- (void)applicationWillTerminate:(UIApplication *)application {
LOGI(@"%@", NSStringFromSelector(_cmd));
if (PhoneMainView.instance.currentView == ChatConversationView.compositeViewDescription) {
ChatConversationView *view = VIEW(ChatConversationView);
[view.tableController setChatRoom:NULL];
}
LinphoneManager.instance.conf = TRUE;
linphone_core_terminate_all_calls(LC);
[CallManager.instance removeAllCallInfos];
......
......@@ -45,7 +45,7 @@
@property(strong, nonatomic) NSMutableArray<UIChatContentView *> *contentViews;
- (void)setEvent:(LinphoneEventLog *)event vfsEnabled:(BOOL)enabled;
- (void)setEvent:(LinphoneEventLog *)event;
- (void)setChatMessage:(LinphoneChatMessage *)message;
- (void)connectToFileDelegate:(FileTransferDelegate *)ftd;
- (IBAction)onDownloadClick:(id)event;
......
......@@ -63,11 +63,11 @@
}
#pragma mark -
- (void)setEvent:(LinphoneEventLog *)event vfsEnabled:(BOOL)enabled {
- (void)setEvent:(LinphoneEventLog *)event {
if (!event || !(linphone_event_log_get_type(event) == LinphoneEventLogTypeConferenceChatMessage))
return;
[super setEvent:event vfsEnabled:enabled];
[super setEvent:event];
[self setChatMessage:linphone_event_log_get_chat_message(event)];
}
......@@ -133,6 +133,7 @@
_fileName.hidden = _fileView.hidden = _fileButton.hidden = NO;
_imageGestureRecognizer.enabled = NO;
_plusLongGestureRecognizer.enabled = NO;
_playButton.hidden = YES;
});
}
......@@ -162,7 +163,7 @@
if (multiParts) {
if (!assetIsLoaded) {
NSMutableDictionary<NSString *, NSString *> *encrptedFilePaths = NULL;
if (self.vfsEnabled) {
if ([VFSUtil vfsEnabledWithGroupName:kLinphoneMsgNotificationAppGroupId]) {
encrptedFilePaths = [LinphoneManager getMessageAppDataForKey:@"encryptedfiles" inMessage:self.message];
if (!encrptedFilePaths) {
encrptedFilePaths = [NSMutableDictionary dictionary];
......@@ -178,7 +179,7 @@
LinphoneContent *content = (LinphoneContent *)it->data;
if (linphone_content_is_file_transfer(content) || linphone_content_is_file(content)){
UIChatContentView *contentView = [[UIChatContentView alloc] initWithFrame: CGRectMake(0,0,0,0)];
if(self.vfsEnabled && (linphone_chat_message_is_outgoing(self.message) || linphone_content_is_file(content))) {
if([VFSUtil vfsEnabledWithGroupName:kLinphoneMsgNotificationAppGroupId] && (linphone_chat_message_is_outgoing(self.message) || linphone_content_is_file(content))) {
// downloaded or ougoing message
NSString *name = [NSString stringWithUTF8String:linphone_content_get_name(content)];
NSString *filePath = [encrptedFilePaths valueForKey:name];
......@@ -187,7 +188,9 @@
if (cPath) {
if (strcmp(cPath, "") != 0) {
NSString *tempPath = [NSString stringWithUTF8String:cPath];
filePath = [tempPath stringByDeletingPathExtension];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
filePath = [paths objectAtIndex:0];
filePath = [filePath stringByAppendingPathComponent:name];
[[NSFileManager defaultManager] moveItemAtPath:tempPath toPath:filePath error:nil];
}
ms_free(cPath);
......@@ -202,7 +205,7 @@
i++;
}
}
if (self.vfsEnabled) {
if ([VFSUtil vfsEnabledWithGroupName:kLinphoneMsgNotificationAppGroupId]) {
[LinphoneManager setValueInMessageAppData:encrptedFilePaths forKey:@"encryptedfiles" inMessage:self.message];
}
assetIsLoaded = TRUE;
......@@ -251,11 +254,13 @@
NSString *fileName = [NSString stringWithUTF8String:linphone_content_get_name(fileContent)];
if (!filePath) {
char *cPath = self.vfsEnabled ? linphone_content_get_plain_file_path(fileContent) : NULL;
char *cPath = [VFSUtil vfsEnabledWithGroupName:kLinphoneMsgNotificationAppGroupId] ? linphone_content_get_plain_file_path(fileContent) : NULL;
if (cPath) {
if (strcmp(cPath, "") != 0) {
NSString *tempPath = [NSString stringWithUTF8String:cPath];
filePath = [tempPath stringByDeletingPathExtension];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
filePath = [paths objectAtIndex:0];
filePath = [filePath stringByAppendingPathComponent:fileName];
[[NSFileManager defaultManager] moveItemAtPath:tempPath toPath:filePath error:nil];
}
ms_free(cPath);
......@@ -312,7 +317,7 @@
// If the file has been downloaded in background, save it in the folders and display it.
[LinphoneManager setValueInMessageAppData:fileName forKey:key inMessage:self.message];
dispatch_async(dispatch_get_main_queue(), ^ {
if ([ConfigManager.instance lpConfigBoolForKeyWithKey:@"auto_write_to_gallery_preference"]) {
if (![VFSUtil vfsEnabledWithGroupName:kLinphoneMsgNotificationAppGroupId] && [ConfigManager.instance lpConfigBoolForKeyWithKey:@"auto_write_to_gallery_preference"]) {
[ChatConversationView writeMediaToGallery:fileName fileType:fileType];
}
});
......
......@@ -49,7 +49,6 @@
@property(nonatomic) BOOL isFirst;
@property(nonatomic) BOOL isLast;
@property(nonatomic) BOOL notDelivered;
@property(nonatomic) BOOL vfsEnabled;
+ (CGSize)ViewSizeForMessage:(LinphoneChatMessage *)chat withWidth:(int)width;
+ (CGSize)ViewHeightForMessageText:(LinphoneChatMessage *)chat withWidth:(int)width textForImdn:(NSString *)imdnText;
......@@ -57,7 +56,7 @@
+ (UIImage *)getImageFromVideoUrl:(NSURL *)url;
+ (UIImage *)getImageFromContent:(LinphoneContent *)content filePath:(NSString *)filePath;
- (void)setEvent:(LinphoneEventLog *)event vfsEnabled:(BOOL)enabled;
- (void)setEvent:(LinphoneEventLog *)event;
- (void)setChatMessageForCbs:(LinphoneChatMessage *)message;
- (void)clearEncryptedFiles;
......
......@@ -62,18 +62,20 @@
}
- (void)dealloc {
[self setEvent:NULL vfsEnabled:_vfsEnabled];
[self setEvent:NULL];
[self setChatMessageForCbs:NULL];
}
#pragma mark -
- (void)clearEncryptedFiles {
if (_vfsEnabled) {
if ([VFSUtil vfsEnabledWithGroupName:kLinphoneMsgNotificationAppGroupId]) {
NSMutableDictionary<NSString *, NSString *> *encrptedFilePaths = [LinphoneManager getMessageAppDataForKey:@"encryptedfiles" inMessage:_message];
if ([encrptedFilePaths count] > 0) {
for(NSString *path in [encrptedFilePaths allValues]) {
[[NSFileManager defaultManager] removeItemAtPath:path error:NULL];
if (![path isEqualToString:@""]) {
[[NSFileManager defaultManager] removeItemAtPath:path error:nil];
}
}
[LinphoneManager setValueInMessageAppData:NULL forKey:@"encryptedfiles" inMessage:_message];
return;
......@@ -81,19 +83,23 @@
NSString *filePath = [LinphoneManager getMessageAppDataForKey:@"encryptedfile" inMessage:_message];
if (filePath) {
if (![filePath isEqualToString:@""])
[[NSFileManager defaultManager] removeItemAtPath:filePath error:NULL];
if (![filePath isEqualToString:@""]) {
NSError *error = nil;
[[NSFileManager defaultManager] removeItemAtPath:filePath error:&error];
if (error) {
LOGI(@"clean failed %@", error.description);
}
}
[LinphoneManager setValueInMessageAppData:NULL forKey:@"encryptedfile" inMessage:_message];
}
}
}
- (void)setEvent:(LinphoneEventLog *)event vfsEnabled:(BOOL)enabled {
- (void)setEvent:(LinphoneEventLog *)event {
if(!event)
return;
_event = event;
_vfsEnabled = enabled;
if (!(linphone_event_log_get_type(event) == LinphoneEventLogTypeConferenceChatMessage)) {
LOGE(@"Impossible to create a ChatBubbleText whit a non message event");
return;
......
......@@ -57,7 +57,7 @@ static void file_transfer_progress_indication_recv(LinphoneChatMessage *message,
forKey:key
inMessage:message];
dispatch_async(dispatch_get_main_queue(), ^{
if ([ConfigManager.instance lpConfigBoolForKeyWithKey:@"auto_write_to_gallery_preference"]) {
if (![VFSUtil vfsEnabledWithGroupName:kLinphoneMsgNotificationAppGroupId] && [ConfigManager.instance lpConfigBoolForKeyWithKey:@"auto_write_to_gallery_preference"]) {
[ChatConversationView writeMediaToGallery:name fileType:fileType];
}
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment