add file transfer in conversations
- Add a send file button in conversation view
- Add new message types in chat view with buttons to control file
transfer interactions (accept, cancel, status, etc.)
- When receiving a file, a dialog is presented to chose a location.
It is meant to be replaced by a settable default location.
- An animation is displayed during transfer. It will be replaced by a
progress bar when LRC side implemented.
Change-Id: I2ea0210823d697f4ada75a33b720d63288b36983
Reviewed-by: Olivier Soldano <olivier.soldano@savoirfairelinux.com>
diff --git a/src/ConversationVC.mm b/src/ConversationVC.mm
index f697506..1534901 100644
--- a/src/ConversationVC.mm
+++ b/src/ConversationVC.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2017 Savoir-faire Linux Inc.
+ * Copyright (C) 2016-2018 Savoir-faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
* Author: Anthony Léonard <anthony.leonard@savoirfairelinux.com>
*
@@ -52,6 +52,7 @@
__unsafe_unretained IBOutlet NSTextField* conversationTitle;
__unsafe_unretained IBOutlet NSTextField *conversationID;
__unsafe_unretained IBOutlet IconButton* sendButton;
+ __unsafe_unretained IBOutlet IconButton *sendFileButton;
__unsafe_unretained IBOutlet NSLayoutConstraint* sentContactRequestWidth;
__unsafe_unretained IBOutlet NSButton* sentContactRequestButton;
IBOutlet MessagesVC* messagesViewVC;
@@ -149,6 +150,7 @@
NSString* bestId = bestIDForConversation(*conv, *convModel_);
[conversationTitle setStringValue: bestName];
[conversationID setStringValue: bestId];
+ [sendFileButton setEnabled:(convModel_->owner.contactModel->getContact(conv->participants[0]).profileInfo.type != lrc::api::profile::Type::SIP)];
BOOL hideBestId = [bestNameForConversation(*conv, *convModel_) isEqualTo:bestIDForConversation(*conv, *convModel_)];
@@ -200,6 +202,25 @@
}
}
+- (IBAction)sendFile:(id)sender
+{
+ NSOpenPanel* filePicker = [NSOpenPanel openPanel];
+ [filePicker setCanChooseFiles:YES];
+ [filePicker setCanChooseDirectories:NO];
+ [filePicker setAllowsMultipleSelection:NO];
+
+ if ([filePicker runModal] == NSFileHandlingPanelOKButton) {
+ if ([[filePicker URLs] count] == 1) {
+ NSURL* url = [[filePicker URLs] objectAtIndex:0];
+ const char* fullPath = [url fileSystemRepresentation];
+ NSString* fileName = [url lastPathComponent];
+ if (convModel_) {
+ convModel_->sendFile(convUid_, std::string(fullPath), std::string([fileName UTF8String]));
+ }
+ }
+ }
+}
+
- (IBAction)placeCall:(id)sender
{
auto* conv = [self getCurrentConversation];