Commit e7d62ed1 authored by Anthony Léonard's avatar Anthony Léonard Committed by Olivier SOLDANO

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: default avatarOlivier Soldano <olivier.soldano@savoirfairelinux.com>
parent f79fd7ca
......@@ -313,7 +313,8 @@ ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/video.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_delete.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/qrcode.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_video.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/pending_contact_request.png)
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/pending_contact_request.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_file_upload.png)
SET_SOURCE_FILES_PROPERTIES(${ring_ICONS} PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
......
/*
* 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];
......
/*
* Copyright (C) 2015-2017 Savoir-faire Linux Inc.
* Copyright (C) 2015-2018 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
......@@ -29,7 +29,7 @@
@interface MessagesVC : NSViewController
-(void)setConversationUid:(const std::string)convUid model:(const lrc::api::ConversationModel*)model;
-(void)setConversationUid:(const std::string)convUid model:(lrc::api::ConversationModel*)model;
-(void)newMessageSent;
@property (retain, nonatomic) id <MessagesVCDelegate> delegate;
......
This diff is collapsed.
/*
* Copyright (C) 2016 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>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -25,8 +26,14 @@
@property (nonatomic, strong) IBOutlet NSImageView* photoView;
@property (nonatomic, strong) IBOutlet NSTextView* msgView;
@property (nonatomic, strong) IBOutlet MessageBubbleView* msgBackground;
@property (nonatomic, strong) IBOutlet NSButton* acceptButton;
@property (nonatomic, strong) IBOutlet NSButton* declineButton;
@property (nonatomic, strong) IBOutlet NSProgressIndicator* progressIndicator;
@property (nonatomic, strong) IBOutlet NSTextField* statusLabel;
- (void) setup;
- (uint64_t) interaction;
- (void) setupForInteraction:(uint64_t)inter;
- (void) updateWidthConstraint:(CGFloat) newWidth;
@end
/*
* Copyright (C) 2016 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>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -18,25 +19,35 @@
*/
#import "IMTableCellView.h"
#import "NSColor+RingTheme.h"
@implementation IMTableCellView
@implementation IMTableCellView {
uint64_t interaction;
}
@synthesize msgView;
@synthesize photoView;
@synthesize acceptButton;
@synthesize declineButton;
@synthesize progressIndicator;
@synthesize statusLabel;
- (void) setup
- (void) setupDirection
{
if ([self.identifier isEqualToString:@"RightMessageView"]) {
if ([self.identifier containsString:@"Right"]) {
self.msgBackground.pointerDirection = RIGHT;
self.msgBackground.bgColor = [NSColor ringLightBlue];
}
else {
self.msgBackground.pointerDirection = LEFT;
self.msgBackground.bgColor = [NSColor whiteColor];
}
}
- (void) setupForInteraction:(uint64_t)inter
{
interaction = inter;
[self setupDirection];
[self.msgView setBackgroundColor:[NSColor clearColor]];
[self.msgView setString:@""];
[self.msgView setAutoresizingMask:NSViewWidthSizable];
......@@ -45,11 +56,14 @@
[self.msgBackground setAutoresizingMask:NSViewHeightSizable];
[self.msgView setEnabledTextCheckingTypes:NSTextCheckingTypeLink];
[self.msgView setAutomaticLinkDetectionEnabled:YES];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-5-[msgView]"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(msgView)]];
}
[self.msgView setEditable:NO];
if ([self.identifier containsString:@"Message"]) {
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-5-[msgView]"
options:0
metrics:nil
views:NSDictionaryOfVariableBindings(msgView)]];
}
}
- (void) updateWidthConstraint:(CGFloat) newWidth
{
......@@ -66,4 +80,9 @@
[self.msgView addConstraint:constraint];
}
- (uint64_t)interaction
{
return interaction;
}
@end
This diff is collapsed.
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