Filetransfer: temporary fix to display all upload photos in simultanous upload

This commit is contained in:
Gautier Pelloux-Prayer 2015-07-02 13:53:59 +02:00
parent a2cefd283b
commit 87b185f907
4 changed files with 24 additions and 8 deletions

View file

@ -444,9 +444,24 @@ static UIFont *CELL_FONT = nil;
}
}
}
#pragma mark - State changed handler
#pragma mark - State changed handling
static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState state) {
UIChatRoomCell *thiz = (__bridge UIChatRoomCell *)linphone_chat_message_get_user_data(msg);
LOGI(@"State for message [%p] changed to %s", msg, linphone_chat_message_state_to_string(state));
if (linphone_chat_message_get_file_transfer_information(msg) != NULL &&
(state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered)) {
// we need to refresh the tableview because the filetransfer delegate unreffed
// the chat message before state was LinphoneChatMessageStateFileTransferDone -
// if we are coming back from another view between unreffing and change of state,
// the transient message will not be found and it will not appear in the list of
// message, so we must refresh the table when we change to this state to ensure that
// all transient messages apppear
ChatRoomViewController *controller = DYNAMIC_CAST(
[[PhoneMainView instance] changeCurrentView:[ChatRoomViewController compositeViewDescription] push:TRUE],
ChatRoomViewController);
[controller.tableController setChatRoom:linphone_chat_message_get_chat_room(msg)];
// UGLY HACK, must be fixed in file transfer cb
}
[thiz update];
}

View file

@ -15,6 +15,7 @@
- (void)upload:(UIImage *)image withURL:(NSURL *)url forChatRoom:(LinphoneChatRoom *)chatRoom;
- (void)cancel;
- (BOOL)download:(LinphoneChatMessage *)message;
- (void)stopAndDestroy;
@property() LinphoneChatMessage *message;
@end

View file

@ -122,6 +122,7 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
// this is the last time we will be notified, so destroy ourselve
if (remaining <= size) {
LOGI(@"Upload ended, unreffing %p", thiz.message);
linphone_chat_message_unref(thiz.message);
thiz.message = NULL;
[thiz stopAndDestroy];
@ -187,8 +188,6 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
[[[LinphoneManager instance] fileTransferDelegates] removeObject:self];
if (_message != NULL) {
LOGI(@"%p Cancelling transferm from %p", self, _message);
linphone_chat_message_cbs_set_file_transfer_progress_indication(linphone_chat_message_get_callbacks(_message),
NULL);
linphone_chat_message_cbs_set_file_transfer_send(linphone_chat_message_get_callbacks(_message), NULL);
linphone_chat_message_cbs_set_file_transfer_recv(linphone_chat_message_get_callbacks(_message), NULL);
linphone_chat_message_cancel_file_transfer(_message);

View file

@ -154,7 +154,6 @@
UITableView *tv = [self findTableView:@"Chat list"];
long messagesCount = [tv numberOfRowsInSection:0];
long delegatesCount = [[[LinphoneManager instance] fileTransferDelegates] count];
[tester tapViewWithAccessibilityLabel:@"Send picture"];
[tester tapViewWithAccessibilityLabel:@"Photo library"];
// if popup "Linphone would access your photo" pops up, click OK.
@ -164,8 +163,8 @@
#endif
}
// select another photo if already uploading one
[tester choosePhotoInAlbum:@"Camera Roll" atRow:1 + delegatesCount column:1];
// select random photo to avoid having the same multiple times
[tester choosePhotoInAlbum:@"Camera Roll" atRow:1 + messagesCount column:1];
// wait for the quality popup to show up
[tester waitForTimeInterval:1];
@ -175,8 +174,6 @@
return [element.accessibilityLabel containsString:quality];
}];
[tester tapViewWithAccessibilityLabel:element.accessibilityLabel];
ASSERT_EQ([tv numberOfRowsInSection:0], messagesCount + 1);
}
- (void)testUploadImage {
@ -249,6 +246,7 @@
}
- (void)test3DownloadsSimultanously {
[self startChatWith:[self me]];
[self uploadImageWithQuality:@"Maximum"];
[self uploadImageWithQuality:@"Average"];
@ -261,10 +259,13 @@
break;
}
ASSERT_EQ([[LinphoneManager instance] fileTransferDelegates].count, 0);
[tester scrollViewWithAccessibilityIdentifier:@"Chat list" byFractionOfSizeHorizontal:0.f vertical:1];
for (int i = 0; i < 3; i++) {
[tester waitForViewWithAccessibilityLabel:@"Download"];
[tester tapViewWithAccessibilityLabel:@"Download"];
[tester waitForTimeInterval:.5f]; // just wait a few secs to start download
if (i != 2)
[tester scrollViewWithAccessibilityIdentifier:@"Chat list" byFractionOfSizeHorizontal:0.f vertical:-.5f];
}
}