mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
problem when receiving an image
This commit is contained in:
parent
0e9bd19b26
commit
5f2e5ea349
5 changed files with 43 additions and 15 deletions
|
|
@ -40,6 +40,15 @@
|
|||
[super viewWillAppear:animated];
|
||||
self.tableView.accessibilityIdentifier = @"ChatRoom list";
|
||||
_imagesInChatroom = [NSMutableDictionary dictionary];
|
||||
|
||||
[NSNotificationCenter.defaultCenter addObserver:self
|
||||
selector:@selector(updateData)
|
||||
name:kLinphoneMessageValueUpdated
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneMessageValueUpdated object:nil];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
|
@ -66,6 +75,8 @@
|
|||
while (chatRoomEvents) {
|
||||
LinphoneEventLog *event = (LinphoneEventLog *)chatRoomEvents->data;
|
||||
[eventList addObject:[NSValue valueWithPointer:linphone_event_log_ref(event)]];
|
||||
|
||||
LOGD([NSString stringWithFormat:@"adding event at adress: %p", [[eventList lastObject] pointerValue]]);
|
||||
chatRoomEvents = chatRoomEvents->next;
|
||||
}
|
||||
bctbx_list_free_with_data(head, (bctbx_list_free_func)linphone_event_log_unref);
|
||||
|
|
@ -88,6 +99,7 @@
|
|||
}
|
||||
|
||||
- (void)addEventEntry:(LinphoneEventLog *)event {
|
||||
LOGD([NSString stringWithFormat:@"adding event at adress: %p", event]);
|
||||
[eventList addObject:[NSValue valueWithPointer:linphone_event_log_ref(event)]];
|
||||
int pos = (int)eventList.count - 1;
|
||||
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:pos inSection:0];
|
||||
|
|
@ -97,6 +109,7 @@
|
|||
}
|
||||
|
||||
- (void)updateEventEntry:(LinphoneEventLog *)event {
|
||||
LOGD([NSString stringWithFormat:@"updating event at adress: %p", event]);
|
||||
NSInteger index = [eventList indexOfObject:[NSValue valueWithPointer:event]];
|
||||
if (index < 0) {
|
||||
LOGW(@"event entry doesn't exist");
|
||||
|
|
@ -104,7 +117,11 @@
|
|||
}
|
||||
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:index inSection:0]]
|
||||
withRowAnimation:FALSE]; // just reload
|
||||
return;
|
||||
[self.tableView reloadData];
|
||||
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:index inSection:0]
|
||||
atScrollPosition:UITableViewScrollPositionBottom
|
||||
animated:YES];
|
||||
return;
|
||||
}
|
||||
|
||||
- (void)scrollToBottom:(BOOL)animated {
|
||||
|
|
@ -189,6 +206,7 @@
|
|||
if (!cell) {
|
||||
cell = [[NSClassFromString(kCellId) alloc] initWithIdentifier:kCellId];
|
||||
}
|
||||
LOGD([NSString stringWithFormat:@"event adress: %p", event]);
|
||||
[cell setEvent:event];
|
||||
if (chat)
|
||||
[cell update];
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ extern NSString *const kLinphoneCallEncryptionChanged;
|
|||
extern NSString *const kLinphoneFileTransferSendUpdate;
|
||||
extern NSString *const kLinphoneFileTransferRecvUpdate;
|
||||
extern NSString *const kLinphoneQRCodeFound;
|
||||
extern NSString *const kLinphoneMessageValueUpdated;
|
||||
|
||||
typedef enum _NetworkType {
|
||||
network_none = 0,
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ NSString *const kLinphoneCallEncryptionChanged = @"LinphoneCallEncryptionChanged
|
|||
NSString *const kLinphoneFileTransferSendUpdate = @"LinphoneFileTransferSendUpdate";
|
||||
NSString *const kLinphoneFileTransferRecvUpdate = @"LinphoneFileTransferRecvUpdate";
|
||||
NSString *const kLinphoneQRCodeFound = @"LinphoneQRCodeFound";
|
||||
NSString *const kLinphoneMessageValueUpdated = @"LinphoneMessageValueUpdated";
|
||||
|
||||
const int kLinphoneAudioVbrCodecDefaultBitrate = 36; /*you can override this from linphonerc or linphonerc-factory*/
|
||||
|
||||
|
|
@ -2887,20 +2888,22 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
}
|
||||
|
||||
+ (void)setValueInMessageAppData:(id)value forKey:(NSString *)key inMessage:(LinphoneChatMessage *)msg {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSMutableDictionary *appDataDict = [NSMutableDictionary dictionary];
|
||||
const char *appData = linphone_chat_message_get_appdata(msg);
|
||||
if (appData) {
|
||||
appDataDict = [NSJSONSerialization JSONObjectWithData:[NSData dataWithBytes:appData length:strlen(appData)]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:nil];
|
||||
}
|
||||
|
||||
NSMutableDictionary *appDataDict = [NSMutableDictionary dictionary];
|
||||
const char *appData = linphone_chat_message_get_appdata(msg);
|
||||
if (appData) {
|
||||
appDataDict = [NSJSONSerialization JSONObjectWithData:[NSData dataWithBytes:appData length:strlen(appData)]
|
||||
options:NSJSONReadingMutableContainers
|
||||
error:nil];
|
||||
}
|
||||
[appDataDict setValue:value forKey:key];
|
||||
|
||||
[appDataDict setValue:value forKey:key];
|
||||
|
||||
NSData *data = [NSJSONSerialization dataWithJSONObject:appDataDict options:0 error:nil];
|
||||
NSString *appdataJSON = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
linphone_chat_message_set_appdata(msg, [appdataJSON UTF8String]);
|
||||
NSData *data = [NSJSONSerialization dataWithJSONObject:appDataDict options:0 error:nil];
|
||||
NSString *appdataJSON = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
linphone_chat_message_set_appdata(msg, [appdataJSON UTF8String]);
|
||||
[NSNotificationCenter.defaultCenter postNotificationName:kLinphoneMessageValueUpdated object:nil];
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - LPConfig Functions
|
||||
|
|
|
|||
|
|
@ -68,6 +68,10 @@
|
|||
return;
|
||||
|
||||
super.event = event;
|
||||
|
||||
//LOGD([NSString stringWithFormat:@"photo cell adress: %p", self]);
|
||||
//LOGD([NSString stringWithFormat:@"event adress: %p", event]);
|
||||
//LOGD([NSString stringWithFormat:@"message adress: %p", linphone_event_log_get_chat_message(event)]);
|
||||
[self setChatMessage:linphone_event_log_get_chat_message(event)];
|
||||
}
|
||||
|
||||
|
|
@ -109,6 +113,7 @@
|
|||
_messageImageView.hidden = YES;
|
||||
_imageGestureRecognizer.enabled = YES;
|
||||
_finalImage.hidden = NO;
|
||||
[self layoutSubviews];
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -363,7 +368,8 @@
|
|||
}
|
||||
|
||||
- (void)disconnectFromFileDelegate {
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self];
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneFileTransferSendUpdate object:_ftd];
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self name:kLinphoneFileTransferRecvUpdate object:_ftd];
|
||||
_ftd = nil;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ static void linphone_iphone_file_transfer_recv(LinphoneChatMessage *message, con
|
|||
userInfo:@{
|
||||
@"state" : @(LinphoneChatMessageStateDelivered),
|
||||
// we dont want to trigger FileTransferDone here
|
||||
@"image" : image,
|
||||
//@"image" : image,
|
||||
@"progress" : @(1.f),
|
||||
}];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue