mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 02:58:07 +00:00
merge view
This commit is contained in:
parent
cdf2e45403
commit
88341280b6
6 changed files with 220 additions and 251 deletions
|
|
@ -220,7 +220,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
||||||
|
|
||||||
NSDictionary *dict = [defaults valueForKey:@"img"];
|
NSDictionary *dict = [defaults valueForKey:@"img"];
|
||||||
NSDictionary *dictWeb = [defaults valueForKey:@"web"];
|
NSDictionary *dictWeb = [defaults valueForKey:@"web"];
|
||||||
NSDictionary *dictFile = [defaults valueForKey:@"file"];
|
NSDictionary *dictFile = [defaults valueForKey:@"mov"];
|
||||||
NSDictionary *dictText = [defaults valueForKey:@"text"];
|
NSDictionary *dictText = [defaults valueForKey:@"text"];
|
||||||
if (dict) {
|
if (dict) {
|
||||||
//share photo
|
//share photo
|
||||||
|
|
@ -247,7 +247,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
||||||
NSData *data = dictFile[@"nsData"];
|
NSData *data = dictFile[@"nsData"];
|
||||||
[self confirmShare:data url:[NSURL fileURLWithPath:dictFile[@"url"]]];
|
[self confirmShare:data url:[NSURL fileURLWithPath:dictFile[@"url"]]];
|
||||||
[self sendContentText:dictFile[@"name"]];
|
[self sendContentText:dictFile[@"name"]];
|
||||||
[defaults removeObjectForKey:@"file"];
|
[defaults removeObjectForKey:@"mov"];
|
||||||
}else if(dictText) {
|
}else if(dictText) {
|
||||||
//share text
|
//share text
|
||||||
[self sendContentText:dictText[@"name"]];
|
[self sendContentText:dictText[@"name"]];
|
||||||
|
|
@ -370,7 +370,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
||||||
DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"", nil)];
|
DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"", nil)];
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
|
|
||||||
[sheet addButtonWithTitle:@"send to him"
|
[sheet addButtonWithTitle:@"send to this friend"
|
||||||
block:^() {
|
block:^() {
|
||||||
[self startFileUpload:data withUrl:url];
|
[self startFileUpload:data withUrl:url];
|
||||||
}];
|
}];
|
||||||
|
|
@ -856,7 +856,6 @@ void on_chat_room_conference_left(LinphoneChatRoom *cr, const LinphoneEventLog *
|
||||||
|
|
||||||
- (void)openResults:(NSString *) filePath
|
- (void)openResults:(NSString *) filePath
|
||||||
{
|
{
|
||||||
//TODO: if file exist
|
|
||||||
// Open the controller.
|
// Open the controller.
|
||||||
_documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
|
_documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]];
|
||||||
_documentInteractionController.delegate = self;
|
_documentInteractionController.delegate = self;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<outlet property="cancelButton" destination="6dl-Nz-rdv" id="ygz-nv-omC"/>
|
<outlet property="cancelButton" destination="6dl-Nz-rdv" id="ygz-nv-omC"/>
|
||||||
<outlet property="contactDateLabel" destination="JyR-RQ-uwF" id="Tc4-9t-i5V"/>
|
<outlet property="contactDateLabel" destination="JyR-RQ-uwF" id="Tc4-9t-i5V"/>
|
||||||
<outlet property="downloadButton" destination="N75-gL-R6t" id="EgN-Ab-Ded"/>
|
<outlet property="downloadButton" destination="N75-gL-R6t" id="EgN-Ab-Ded"/>
|
||||||
<outlet property="fileName" destination="Dqi-dR-naZ" id="yvz-fI-THr"/>
|
<outlet property="fileName" destination="Dho-UV-6Ev" id="Iro-II-w8a"/>
|
||||||
<outlet property="fileTransferProgress" destination="USm-wC-GvG" id="POt-YD-NCG"/>
|
<outlet property="fileTransferProgress" destination="USm-wC-GvG" id="POt-YD-NCG"/>
|
||||||
<outlet property="finalImage" destination="gzv-K4-5OL" id="YIw-kM-Ld6"/>
|
<outlet property="finalImage" destination="gzv-K4-5OL" id="YIw-kM-Ld6"/>
|
||||||
<outlet property="imageGestureRecognizer" destination="aDF-hC-ddO" id="2jh-Rr-eKk"/>
|
<outlet property="imageGestureRecognizer" destination="aDF-hC-ddO" id="2jh-Rr-eKk"/>
|
||||||
|
|
@ -27,8 +27,8 @@
|
||||||
<outlet property="imdmIcon" destination="LPj-VT-0fH" id="yYh-pv-EJs"/>
|
<outlet property="imdmIcon" destination="LPj-VT-0fH" id="yYh-pv-EJs"/>
|
||||||
<outlet property="imdmLabel" destination="44j-me-Iqi" id="m5R-Dm-V8g"/>
|
<outlet property="imdmLabel" destination="44j-me-Iqi" id="m5R-Dm-V8g"/>
|
||||||
<outlet property="messageImageView" destination="yMW-cT-bpU" id="MNr-F2-abQ"/>
|
<outlet property="messageImageView" destination="yMW-cT-bpU" id="MNr-F2-abQ"/>
|
||||||
<outlet property="openRecognizer" destination="9ss-Qo-Kkt" id="sJZ-Fa-wFh"/>
|
<outlet property="openRecognizer" destination="NYA-II-xYn" id="pVM-vD-4Rg"/>
|
||||||
<outlet property="playButton" destination="Mna-y7-VAE" id="aOC-UN-xLJ"/>
|
<outlet property="playButton" destination="cvc-tl-Pcf" id="eKJ-2T-LUl"/>
|
||||||
<outlet property="resendRecognizer" destination="5ZI-Ip-lGl" id="G2r-On-6mV"/>
|
<outlet property="resendRecognizer" destination="5ZI-Ip-lGl" id="G2r-On-6mV"/>
|
||||||
<outlet property="statusInProgressSpinner" destination="Eab-ND-ix3" id="UuC-eY-MSf"/>
|
<outlet property="statusInProgressSpinner" destination="Eab-ND-ix3" id="UuC-eY-MSf"/>
|
||||||
<outlet property="totalView" destination="8I3-n2-0kS" id="aa8-j9-saW"/>
|
<outlet property="totalView" destination="8I3-n2-0kS" id="aa8-j9-saW"/>
|
||||||
|
|
@ -72,11 +72,11 @@
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||||
<gestureRecognizers/>
|
<gestureRecognizers/>
|
||||||
</imageView>
|
</imageView>
|
||||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="center" lineBreakMode="middleTruncation" adjustsFontSizeToFit="NO" id="Dqi-dR-naZ" userLabel="fileName">
|
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Label" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Dho-UV-6Ev" userLabel="fileName">
|
||||||
<rect key="frame" x="9" y="18" width="229" height="40"/>
|
<rect key="frame" x="0.0" y="0.0" width="200" height="50"/>
|
||||||
<autoresizingMask key="autoresizingMask"/>
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
<fontDescription key="fontDescription" type="system" pointSize="10"/>
|
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||||
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
<nil key="highlightedColor"/>
|
<nil key="highlightedColor"/>
|
||||||
</label>
|
</label>
|
||||||
|
|
@ -113,25 +113,9 @@
|
||||||
<action selector="onCancelClick:" destination="-1" eventType="touchUpInside" id="D9y-vf-I4Y"/>
|
<action selector="onCancelClick:" destination="-1" eventType="touchUpInside" id="D9y-vf-I4Y"/>
|
||||||
</connections>
|
</connections>
|
||||||
</button>
|
</button>
|
||||||
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="Mna-y7-VAE" userLabel="playButton" customClass="UIRoundBorderedButton">
|
|
||||||
<rect key="frame" x="66" y="5" width="115" height="27"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
|
|
||||||
<accessibility key="accessibilityConfiguration" label="PLAY"/>
|
|
||||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
|
||||||
<state key="normal" title="PLAY" backgroundImage="color_I.png">
|
|
||||||
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
|
||||||
</state>
|
|
||||||
<state key="highlighted" backgroundImage="color_M.png"/>
|
|
||||||
<connections>
|
|
||||||
<action selector="onPlayClick:" destination="-1" eventType="touchUpInside" id="72M-jV-kHF"/>
|
|
||||||
</connections>
|
|
||||||
</button>
|
|
||||||
</subviews>
|
</subviews>
|
||||||
</view>
|
</view>
|
||||||
</subviews>
|
</subviews>
|
||||||
<connections>
|
|
||||||
<outletCollection property="gestureRecognizers" destination="9ss-Qo-Kkt" appends="YES" id="fEu-Vc-75u"/>
|
|
||||||
</connections>
|
|
||||||
</view>
|
</view>
|
||||||
<view contentMode="scaleToFill" misplaced="YES" id="VYJ-RC-Jmg">
|
<view contentMode="scaleToFill" misplaced="YES" id="VYJ-RC-Jmg">
|
||||||
<rect key="frame" x="8" y="55" width="349" height="213"/>
|
<rect key="frame" x="8" y="55" width="349" height="213"/>
|
||||||
|
|
@ -142,9 +126,23 @@
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||||
<gestureRecognizers/>
|
<gestureRecognizers/>
|
||||||
</imageView>
|
</imageView>
|
||||||
|
<button opaque="NO" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="cvc-tl-Pcf" userLabel="playButton" customClass="UIRoundBorderedButton">
|
||||||
|
<rect key="frame" x="125" y="93" width="50" height="25"/>
|
||||||
|
<autoresizingMask key="autoresizingMask"/>
|
||||||
|
<accessibility key="accessibilityConfiguration" label="Cancel"/>
|
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||||
|
<state key="normal" title="PLAY" backgroundImage="color_I.png">
|
||||||
|
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||||
|
</state>
|
||||||
|
<state key="highlighted" backgroundImage="color_M.png"/>
|
||||||
|
<connections>
|
||||||
|
<action selector="onPlayClick:" destination="-1" eventType="touchUpInside" id="B4y-PJ-4tO"/>
|
||||||
|
</connections>
|
||||||
|
</button>
|
||||||
</subviews>
|
</subviews>
|
||||||
<connections>
|
<connections>
|
||||||
<outletCollection property="gestureRecognizers" destination="aDF-hC-ddO" appends="YES" id="lKJ-ra-dwR"/>
|
<outletCollection property="gestureRecognizers" destination="aDF-hC-ddO" appends="YES" id="lKJ-ra-dwR"/>
|
||||||
|
<outletCollection property="gestureRecognizers" destination="NYA-II-xYn" appends="YES" id="fK6-ld-zOX"/>
|
||||||
</connections>
|
</connections>
|
||||||
</view>
|
</view>
|
||||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="color_A.png" id="6dA-3U-OPW" userLabel="bottomBarColor">
|
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="color_A.png" id="6dA-3U-OPW" userLabel="bottomBarColor">
|
||||||
|
|
@ -193,9 +191,9 @@
|
||||||
<action selector="onImageClick:" destination="-1" id="feN-LT-89b"/>
|
<action selector="onImageClick:" destination="-1" id="feN-LT-89b"/>
|
||||||
</connections>
|
</connections>
|
||||||
</tapGestureRecognizer>
|
</tapGestureRecognizer>
|
||||||
<tapGestureRecognizer id="9ss-Qo-Kkt" userLabel="openClick">
|
<tapGestureRecognizer id="NYA-II-xYn" userLabel="openClick">
|
||||||
<connections>
|
<connections>
|
||||||
<action selector="onOpenClick:" destination="-1" id="JSH-cf-C7G"/>
|
<action selector="onOpenClick:" destination="-1" id="XaJ-Or-uQQ"/>
|
||||||
</connections>
|
</connections>
|
||||||
</tapGestureRecognizer>
|
</tapGestureRecognizer>
|
||||||
</objects>
|
</objects>
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
@implementation UIChatBubblePhotoCell {
|
@implementation UIChatBubblePhotoCell {
|
||||||
FileTransferDelegate *_ftd;
|
FileTransferDelegate *_ftd;
|
||||||
CGSize imageSize, bubbleSize;
|
CGSize imageSize, bubbleSize, videoDefaultSize;
|
||||||
int actualAvailableWidth;
|
int actualAvailableWidth;
|
||||||
ChatConversationTableView *chatTableView;
|
ChatConversationTableView *chatTableView;
|
||||||
//CGImageRef displayedImage;
|
//CGImageRef displayedImage;
|
||||||
|
|
@ -55,6 +55,7 @@
|
||||||
[self addSubview:sub];
|
[self addSubview:sub];
|
||||||
chatTableView = VIEW(ChatConversationView).tableController;
|
chatTableView = VIEW(ChatConversationView).tableController;
|
||||||
actualAvailableWidth = chatTableView.tableView.frame.size.width;
|
actualAvailableWidth = chatTableView.tableView.frame.size.width;
|
||||||
|
videoDefaultSize = CGSizeMake(320, 240);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +81,6 @@
|
||||||
if (amessage) {
|
if (amessage) {
|
||||||
const LinphoneContent *c = linphone_chat_message_get_file_transfer_information(amessage);
|
const LinphoneContent *c = linphone_chat_message_get_file_transfer_information(amessage);
|
||||||
if (c) {
|
if (c) {
|
||||||
|
|
||||||
const char *name = linphone_content_get_name(c);
|
const char *name = linphone_content_get_name(c);
|
||||||
for (FileTransferDelegate *aftd in [LinphoneManager.instance fileTransferDelegates]) {
|
for (FileTransferDelegate *aftd in [LinphoneManager.instance fileTransferDelegates]) {
|
||||||
if (linphone_chat_message_get_file_transfer_information(aftd.message) &&
|
if (linphone_chat_message_get_file_transfer_information(aftd.message) &&
|
||||||
|
|
@ -98,29 +98,31 @@
|
||||||
[super setChatMessage:amessage];
|
[super setChatMessage:amessage];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) loadImageAsset:(ALAsset*) asset thumb:(UIImage *)thumb image:(UIImage *)image {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[_finalImage setImage:image];
|
||||||
|
[_messageImageView setImage:thumb];
|
||||||
|
[_messageImageView setFullImageUrl:asset];
|
||||||
|
[_messageImageView stopLoading];
|
||||||
|
_messageImageView.hidden = YES;
|
||||||
|
_imageGestureRecognizer.enabled = YES;
|
||||||
|
_finalImage.hidden = NO;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
- (void) loadAsset:(ALAsset*) asset {
|
- (void) loadAsset:(ALAsset*) asset {
|
||||||
UIImage *thumb = [[UIImage alloc] initWithCGImage:[asset thumbnail]];
|
UIImage *thumb = [[UIImage alloc] initWithCGImage:[asset thumbnail]];
|
||||||
ALAssetRepresentation *representation = [asset defaultRepresentation];
|
ALAssetRepresentation *representation = [asset defaultRepresentation];
|
||||||
imageSize = [UIChatBubbleTextCell getMediaMessageSizefromOriginalSize:[representation dimensions] withWidth:chatTableView.tableView.frame.size.width];
|
imageSize = [UIChatBubbleTextCell getMediaMessageSizefromOriginalSize:[representation dimensions] withWidth:chatTableView.tableView.frame.size.width];
|
||||||
CGImageRef tmpImg = [self cropImageFromRepresentation:representation];
|
CGImageRef tmpImg = [self cropImageFromRepresentation:representation];
|
||||||
UIImage *image = [[UIImage alloc] initWithCGImage:tmpImg];
|
UIImage *image = [[UIImage alloc] initWithCGImage:tmpImg];
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
[self loadImageAsset:nil thumb:thumb image:image];
|
||||||
[_finalImage setImage:image];
|
|
||||||
[_messageImageView setImage:thumb];
|
|
||||||
[_messageImageView setFullImageUrl:asset];
|
|
||||||
[_messageImageView stopLoading];
|
|
||||||
_messageImageView.hidden = YES;
|
|
||||||
_imageGestureRecognizer.enabled = YES;
|
|
||||||
//_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = YES;
|
|
||||||
_finalImage.hidden = NO;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) loadVideoAsset: (AVAsset *) asset {
|
- (void) loadVideoAsset: (AVAsset *) asset {
|
||||||
// Calculate a time for the snapshot - I'm using the half way mark.
|
// Calculate a time for the snapshot - I'm using the half way mark.
|
||||||
CMTime duration = [asset duration];
|
CMTime duration = [asset duration];
|
||||||
CMTime snapshot = CMTimeMake(duration.value / 2, duration.timescale);
|
CMTime snapshot = CMTimeMake(duration.value / 2, duration.timescale);
|
||||||
|
|
||||||
// Create a generator and copy image at the time.
|
// Create a generator and copy image at the time.
|
||||||
// I'm not capturing the actual time or an error.
|
// I'm not capturing the actual time or an error.
|
||||||
AVAssetImageGenerator *generator =
|
AVAssetImageGenerator *generator =
|
||||||
|
|
@ -129,22 +131,28 @@
|
||||||
actualTime:nil
|
actualTime:nil
|
||||||
error:nil];
|
error:nil];
|
||||||
|
|
||||||
// Make a UIImage and release the CGImage.
|
UIImage *thumb = [UIImage imageWithCGImage:imageRef];
|
||||||
UIImage *image = [UIImage imageWithCGImage:imageRef];
|
|
||||||
CGImageRelease(imageRef);
|
CGImageRelease(imageRef);
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
|
||||||
[_messageImageView setImage:image];
|
UIGraphicsBeginImageContext(videoDefaultSize);
|
||||||
[_messageImageView stopLoading];
|
[thumb drawInRect:CGRectMake(0, 0, videoDefaultSize.width, videoDefaultSize.height)];
|
||||||
_messageImageView.hidden = NO;
|
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
|
||||||
});
|
UIGraphicsEndImageContext();
|
||||||
|
|
||||||
|
[self loadImageAsset:nil thumb:thumb image:image];
|
||||||
|
|
||||||
|
// put the play button in the top
|
||||||
|
CGRect newFrame = _playButton.frame;
|
||||||
|
newFrame.origin.x = _finalImage.frame.origin.x/2;
|
||||||
|
newFrame.origin.y = _finalImage.frame.origin.y/2;
|
||||||
|
_playButton.frame = newFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) loadFileAsset {
|
- (void) loadFileAsset {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
CGRect newFrame = _totalView.frame;
|
|
||||||
newFrame.origin.x = newFrame.origin.y = 0;
|
|
||||||
_fileName.frame = newFrame;
|
|
||||||
_fileName.hidden = NO;
|
_fileName.hidden = NO;
|
||||||
|
_imageGestureRecognizer.enabled = NO;
|
||||||
|
_openRecognizer.enabled = YES;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,7 +163,6 @@
|
||||||
}
|
}
|
||||||
[super update];
|
[super update];
|
||||||
|
|
||||||
LinphoneChatMessageState state = linphone_chat_message_get_state(self.message);
|
|
||||||
const char *url = linphone_chat_message_get_external_body_url(self.message);
|
const char *url = linphone_chat_message_get_external_body_url(self.message);
|
||||||
BOOL is_external =
|
BOOL is_external =
|
||||||
(url && (strstr(url, "http") == url)) || linphone_chat_message_get_file_transfer_information(self.message);
|
(url && (strstr(url, "http") == url)) || linphone_chat_message_get_file_transfer_information(self.message);
|
||||||
|
|
@ -164,123 +171,84 @@
|
||||||
NSString *localFile = [LinphoneManager getMessageAppDataForKey:@"localfile" inMessage:self.message];
|
NSString *localFile = [LinphoneManager getMessageAppDataForKey:@"localfile" inMessage:self.message];
|
||||||
BOOL fullScreenImage = NO;
|
BOOL fullScreenImage = NO;
|
||||||
assert(is_external || localImage || localVideo || localFile);
|
assert(is_external || localImage || localVideo || localFile);
|
||||||
|
|
||||||
if (localImage) {
|
if (!(localImage || localVideo || localFile)) {
|
||||||
// image is being saved on device - just wait for it
|
_playButton.hidden = YES;
|
||||||
if ([localImage isEqualToString:@"saving..."]) {
|
_fileName.hidden = YES;
|
||||||
_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = _playButton.hidden = _fileName.hidden = YES;
|
_messageImageView.hidden = _cancelButton.hidden = (_ftd.message == nil);
|
||||||
fullScreenImage = YES;
|
|
||||||
} else {
|
|
||||||
// we did not load the image yet, so start doing so
|
|
||||||
if (_messageImageView.image == nil) {
|
|
||||||
NSURL *imageUrl = [NSURL URLWithString:localImage];
|
|
||||||
[_messageImageView startLoading];
|
|
||||||
__block LinphoneChatMessage *achat = self.message;
|
|
||||||
[LinphoneManager.instance.photoLibrary assetForURL:imageUrl
|
|
||||||
resultBlock:^(ALAsset *asset) {
|
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL),
|
|
||||||
^(void) {
|
|
||||||
if (achat != self.message) // Avoid glitch and scrolling
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (asset) {
|
|
||||||
[self loadAsset:asset];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
[LinphoneManager.instance.photoLibrary
|
|
||||||
enumerateGroupsWithTypes:ALAssetsGroupAll
|
|
||||||
usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
|
|
||||||
[group enumerateAssetsWithOptions:NSEnumerationReverse
|
|
||||||
usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
|
|
||||||
if([result.defaultRepresentation.url isEqual:imageUrl]) {
|
|
||||||
[self loadAsset:result];
|
|
||||||
*stop = YES;
|
|
||||||
}
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
failureBlock:^(NSError *error) {
|
|
||||||
LOGE(@"Error: Cannot load asset from photo stream - %@", [error localizedDescription]);
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
failureBlock:^(NSError *error) {
|
|
||||||
LOGE(@"Can't read image");
|
|
||||||
}];
|
|
||||||
}
|
|
||||||
// we are uploading the image
|
|
||||||
if (_ftd.message != nil) {
|
|
||||||
_cancelButton.hidden = NO;
|
|
||||||
_fileTransferProgress.hidden = NO;
|
|
||||||
_downloadButton.hidden = YES;
|
|
||||||
_playButton.hidden = YES;
|
|
||||||
_fileName.hidden = YES;
|
|
||||||
} else {
|
|
||||||
_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = _playButton.hidden = _fileName.hidden = YES;
|
|
||||||
fullScreenImage = YES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// we must download the image: either it has already started (show cancel button) or not yet (show download
|
|
||||||
// button)
|
|
||||||
} else if(localVideo) {
|
|
||||||
if ([localVideo isEqualToString:@"saving..."]) {
|
|
||||||
_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = _playButton.hidden = _fileName.hidden = YES;
|
|
||||||
fullScreenImage = YES;
|
|
||||||
} else {
|
|
||||||
if (_messageImageView.image == nil) {
|
|
||||||
|
|
||||||
[_messageImageView startLoading];
|
|
||||||
NSURL *url = [NSURL fileURLWithPath:localVideo];
|
|
||||||
AVAsset *asset = [AVAsset assetWithURL:url];
|
|
||||||
if (asset)
|
|
||||||
[self loadVideoAsset:asset];
|
|
||||||
//TODO fail
|
|
||||||
else return;
|
|
||||||
}
|
|
||||||
// we did not load the video yet, so start doing so
|
|
||||||
// we are uploading the video
|
|
||||||
if (_ftd.message != nil && state != LinphoneChatMessageStateNotDelivered && state != LinphoneChatMessageStateDisplayed) {
|
|
||||||
_cancelButton.hidden = NO;
|
|
||||||
_fileTransferProgress.hidden = NO;
|
|
||||||
_downloadButton.hidden = YES;
|
|
||||||
_playButton.hidden = YES;
|
|
||||||
_fileName.hidden = YES;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = _fileName.hidden = YES;
|
|
||||||
_playButton.hidden = NO;
|
|
||||||
fullScreenImage = YES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if(localFile){
|
|
||||||
if ([localFile isEqualToString:@"saving..."]) {
|
|
||||||
_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = _playButton.hidden = _fileName.hidden = YES;
|
|
||||||
fullScreenImage = YES;
|
|
||||||
} else {
|
|
||||||
if (_ftd.message != nil && state != LinphoneChatMessageStateNotDelivered && state != LinphoneChatMessageStateDisplayed) {
|
|
||||||
_cancelButton.hidden = NO;
|
|
||||||
_fileTransferProgress.hidden = NO;
|
|
||||||
_downloadButton.hidden = YES;
|
|
||||||
_playButton.hidden = YES;
|
|
||||||
_fileName.hidden = YES;
|
|
||||||
} else {
|
|
||||||
NSString *text = [[NSURL fileURLWithPath:localFile] lastPathComponent];
|
|
||||||
_fileName.text = text;
|
|
||||||
_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden =
|
|
||||||
_playButton.hidden = YES;
|
|
||||||
fullScreenImage = YES;
|
|
||||||
[self loadFileAsset];
|
|
||||||
_openRecognizer.enabled = YES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
_playButton.hidden = _fileName.hidden = YES;
|
|
||||||
_messageImageView.hidden = _cancelButton.hidden = (_ftd.message == nil);
|
|
||||||
_downloadButton.hidden = !_cancelButton.hidden;
|
_downloadButton.hidden = !_cancelButton.hidden;
|
||||||
_fileTransferProgress.hidden = NO;
|
_fileTransferProgress.hidden = NO;
|
||||||
}
|
} else {
|
||||||
|
// file is being saved on device - just wait for it
|
||||||
|
if ([localImage isEqualToString:@"saving..."] || [localVideo isEqualToString:@"saving..."] || [localFile isEqualToString:@"saving..."]) {
|
||||||
|
_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = _playButton.hidden = _fileName.hidden = YES;
|
||||||
|
fullScreenImage = YES;
|
||||||
|
} else {
|
||||||
|
if (localImage) {
|
||||||
|
// we did not load the image yet, so start doing so
|
||||||
|
if (_messageImageView.image == nil) {
|
||||||
|
NSURL *imageUrl = [NSURL URLWithString:localImage];
|
||||||
|
[_messageImageView startLoading];
|
||||||
|
__block LinphoneChatMessage *achat = self.message;
|
||||||
|
[LinphoneManager.instance.photoLibrary assetForURL:imageUrl resultBlock:^(ALAsset *asset) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL), ^(void) {
|
||||||
|
if (achat != self.message) // Avoid glitch and scrolling
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (asset) {
|
||||||
|
[self loadAsset:asset];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
[LinphoneManager.instance.photoLibrary
|
||||||
|
enumerateGroupsWithTypes:ALAssetsGroupAll
|
||||||
|
usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
|
||||||
|
[group enumerateAssetsWithOptions:NSEnumerationReverse
|
||||||
|
usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
|
||||||
|
if([result.defaultRepresentation.url isEqual:imageUrl]) {
|
||||||
|
[self loadAsset:result];
|
||||||
|
*stop = YES;
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
failureBlock:^(NSError *error) {
|
||||||
|
LOGE(@"Error: Cannot load asset from photo stream - %@", [error localizedDescription]);
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} failureBlock:^(NSError *error) {
|
||||||
|
LOGE(@"Can't read image");
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
} else if (localVideo) {
|
||||||
|
if (_messageImageView.image == nil) {
|
||||||
|
[_messageImageView startLoading];
|
||||||
|
// read video from Documents
|
||||||
|
NSString *filePath = [LinphoneManager documentFile:localVideo];
|
||||||
|
NSURL *url = [NSURL fileURLWithPath:filePath];
|
||||||
|
AVAsset *asset = [AVAsset assetWithURL:url];
|
||||||
|
if (asset)
|
||||||
|
[self loadVideoAsset:asset];
|
||||||
|
}
|
||||||
|
} else if (localFile) {
|
||||||
|
NSString *text = [NSString stringWithFormat:@"📎 %@",localFile];
|
||||||
|
_fileName.text = text;
|
||||||
|
[self loadFileAsset];
|
||||||
|
}
|
||||||
|
|
||||||
|
// we are uploading the image
|
||||||
|
if (_ftd.message != nil) {
|
||||||
|
_cancelButton.hidden = NO;
|
||||||
|
_fileTransferProgress.hidden = NO;
|
||||||
|
_downloadButton.hidden = YES;
|
||||||
|
_playButton.hidden = YES;
|
||||||
|
_fileName.hidden = YES;
|
||||||
|
} else {
|
||||||
|
_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = YES;
|
||||||
|
fullScreenImage = YES;
|
||||||
|
_playButton.hidden = localVideo ? NO : YES;
|
||||||
|
_fileName.hidden = localFile ? NO : YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// resize image so that it take the full bubble space available
|
// resize image so that it take the full bubble space available
|
||||||
CGRect newFrame = _totalView.frame;
|
CGRect newFrame = _totalView.frame;
|
||||||
newFrame.origin.x = newFrame.origin.y = 0;
|
newFrame.origin.x = newFrame.origin.y = 0;
|
||||||
|
|
@ -290,6 +258,15 @@
|
||||||
_messageImageView.frame = newFrame;
|
_messageImageView.frame = newFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)fileErrorBlock {
|
||||||
|
DTActionSheet *sheet = [[DTActionSheet alloc] initWithTitle:NSLocalizedString(@"Can't open this file", nil)];
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
|
[sheet addCancelButtonWithTitle:NSLocalizedString(@"OK", nil) block:nil];
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[sheet showInView:PhoneMainView.instance.view];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
- (IBAction)onDownloadClick:(id)event {
|
- (IBAction)onDownloadClick:(id)event {
|
||||||
[_ftd cancel];
|
[_ftd cancel];
|
||||||
|
|
@ -304,28 +281,32 @@
|
||||||
|
|
||||||
- (IBAction)onPlayClick:(id)sender {
|
- (IBAction)onPlayClick:(id)sender {
|
||||||
NSString *localVideo = [LinphoneManager getMessageAppDataForKey:@"localvideo" inMessage:self.message];
|
NSString *localVideo = [LinphoneManager getMessageAppDataForKey:@"localvideo" inMessage:self.message];
|
||||||
|
NSString *filePath = [LinphoneManager documentFile:localVideo];
|
||||||
NSURL * fileURL= [[NSURL alloc] initFileURLWithPath:localVideo];
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
|
|
||||||
// create a player view controller
|
if ([fileManager fileExistsAtPath:filePath]) {
|
||||||
AVPlayer *player = [AVPlayer playerWithURL:fileURL];
|
// create a player view controller
|
||||||
AVPlayerViewController *controller = [[AVPlayerViewController alloc] init];
|
AVPlayer *player = [AVPlayer playerWithURL:[[NSURL alloc] initFileURLWithPath:filePath]];
|
||||||
[PhoneMainView.instance presentViewController:controller animated:YES completion:nil];
|
AVPlayerViewController *controller = [[AVPlayerViewController alloc] init];
|
||||||
controller.player = player;
|
[PhoneMainView.instance presentViewController:controller animated:YES completion:nil];
|
||||||
[player play];
|
controller.player = player;
|
||||||
|
[player play];
|
||||||
_cancelButton.hidden = YES;
|
} else {
|
||||||
_downloadButton.hidden = YES;
|
[self fileErrorBlock];
|
||||||
_playButton.hidden = NO;
|
}
|
||||||
_fileTransferProgress.hidden = YES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)onOpenClick:(id)event {
|
- (IBAction)onOpenClick:(id)event {
|
||||||
|
|
||||||
NSString *localFile = [LinphoneManager getMessageAppDataForKey:@"localfile" inMessage:self.message];
|
NSString *localFile = [LinphoneManager getMessageAppDataForKey:@"localfile" inMessage:self.message];
|
||||||
|
NSString *filePath = [LinphoneManager documentFile:localFile];
|
||||||
ChatConversationView *view = VIEW(ChatConversationView);
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||||
[view openResults:localFile];
|
|
||||||
|
if ([fileManager fileExistsAtPath:filePath]) {
|
||||||
|
ChatConversationView *view = VIEW(ChatConversationView);
|
||||||
|
[view openResults:filePath];
|
||||||
|
} else {
|
||||||
|
[self fileErrorBlock];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,7 @@
|
||||||
NSNumber *uploadQuality =[LinphoneManager getMessageAppDataForKey:@"uploadQuality" inMessage:_message];
|
NSNumber *uploadQuality =[LinphoneManager getMessageAppDataForKey:@"uploadQuality" inMessage:_message];
|
||||||
NSString *localVideo = [LinphoneManager getMessageAppDataForKey:@"localvideo" inMessage:_message];
|
NSString *localVideo = [LinphoneManager getMessageAppDataForKey:@"localvideo" inMessage:_message];
|
||||||
NSString *localFile = [LinphoneManager getMessageAppDataForKey:@"localfile" inMessage:_message];
|
NSString *localFile = [LinphoneManager getMessageAppDataForKey:@"localfile" inMessage:_message];
|
||||||
|
NSString *fileName = localVideo ? localVideo : localFile;
|
||||||
NSURL *imageUrl = [NSURL URLWithString:localImage];
|
NSURL *imageUrl = [NSURL URLWithString:localImage];
|
||||||
[self onDelete];
|
[self onDelete];
|
||||||
if(localImage){
|
if(localImage){
|
||||||
|
|
@ -248,12 +249,10 @@
|
||||||
failureBlock:^(NSError *error) {
|
failureBlock:^(NSError *error) {
|
||||||
LOGE(@"Can't read image");
|
LOGE(@"Can't read image");
|
||||||
}];
|
}];
|
||||||
} else if(localVideo) {
|
} else if(fileName) {
|
||||||
[_chatRoomDelegate startFileUpload:[NSData dataWithContentsOfFile:localVideo] withUrl:[NSURL URLWithString:localVideo]];
|
NSString *filePath = [LinphoneManager documentFile:fileName];
|
||||||
} else {
|
[_chatRoomDelegate startFileUpload:[NSData dataWithContentsOfFile:filePath] withUrl:[NSURL URLWithString:filePath]];
|
||||||
[_chatRoomDelegate startFileUpload:[NSData dataWithContentsOfFile:localFile] withUrl:[NSURL URLWithString:localFile]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
[self onDelete];
|
[self onDelete];
|
||||||
double delayInSeconds = 0.4;
|
double delayInSeconds = 0.4;
|
||||||
|
|
@ -319,6 +318,7 @@ static const CGFloat CELL_MESSAGE_Y_MARGIN = 52; // 44;
|
||||||
+ (CGSize)ViewHeightForMessage:(LinphoneChatMessage *)chat withWidth:(int)width {
|
+ (CGSize)ViewHeightForMessage:(LinphoneChatMessage *)chat withWidth:(int)width {
|
||||||
NSString *messageText = [UIChatBubbleTextCell TextMessageForChat:chat];
|
NSString *messageText = [UIChatBubbleTextCell TextMessageForChat:chat];
|
||||||
static UIFont *messageFont = nil;
|
static UIFont *messageFont = nil;
|
||||||
|
|
||||||
if (!messageFont) {
|
if (!messageFont) {
|
||||||
UIChatBubbleTextCell *cell =
|
UIChatBubbleTextCell *cell =
|
||||||
[[UIChatBubbleTextCell alloc] initWithIdentifier:NSStringFromClass(UIChatBubbleTextCell.class)];
|
[[UIChatBubbleTextCell alloc] initWithIdentifier:NSStringFromClass(UIChatBubbleTextCell.class)];
|
||||||
|
|
@ -335,14 +335,24 @@ static const CGFloat CELL_MESSAGE_Y_MARGIN = 52; // 44;
|
||||||
font:messageFont];
|
font:messageFont];
|
||||||
} else {
|
} else {
|
||||||
NSString *localImage = [LinphoneManager getMessageAppDataForKey:@"localimage" inMessage:chat];
|
NSString *localImage = [LinphoneManager getMessageAppDataForKey:@"localimage" inMessage:chat];
|
||||||
NSURL *imageUrl = [NSURL URLWithString:localImage];
|
NSString *localFile = [LinphoneManager getMessageAppDataForKey:@"localfile" inMessage:chat];
|
||||||
__block CGSize originalImageSize = CGSizeMake(0, 0);
|
NSString *localVideo = [LinphoneManager getMessageAppDataForKey:@"localvideo" inMessage:chat];
|
||||||
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
|
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
|
if(localFile) {
|
||||||
[LinphoneManager.instance.photoLibrary assetForURL:imageUrl
|
CGSize fileSize = CGSizeMake(200, 50);
|
||||||
resultBlock:^(ALAsset *asset) {
|
size = [self getMediaMessageSizefromOriginalSize:fileSize withWidth:width];
|
||||||
originalImageSize = [[asset defaultRepresentation] dimensions];
|
} else if (localVideo) {
|
||||||
dispatch_semaphore_signal(sema);
|
CGSize videoSize = CGSizeMake(320, 240);
|
||||||
|
size = [self getMediaMessageSizefromOriginalSize:videoSize withWidth:width];
|
||||||
|
} else {
|
||||||
|
NSURL *imageUrl = [NSURL URLWithString:localImage];
|
||||||
|
__block CGSize originalImageSize = CGSizeMake(0, 0);
|
||||||
|
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
|
||||||
|
[LinphoneManager.instance.photoLibrary assetForURL:imageUrl
|
||||||
|
resultBlock:^(ALAsset *asset) {
|
||||||
|
originalImageSize = [[asset defaultRepresentation] dimensions];
|
||||||
|
dispatch_semaphore_signal(sema);
|
||||||
}
|
}
|
||||||
failureBlock:^(NSError *error) {
|
failureBlock:^(NSError *error) {
|
||||||
LOGE(@"Can't read image");
|
LOGE(@"Can't read image");
|
||||||
|
|
@ -353,8 +363,10 @@ static const CGFloat CELL_MESSAGE_Y_MARGIN = 52; // 44;
|
||||||
|
|
||||||
size = [self getMediaMessageSizefromOriginalSize:originalImageSize withWidth:width];
|
size = [self getMediaMessageSizefromOriginalSize:originalImageSize withWidth:width];
|
||||||
//This fixes the image being too small. I think the issue comes form the fact that the display is retina. This should probably be changed in the future.
|
//This fixes the image being too small. I think the issue comes form the fact that the display is retina. This should probably be changed in the future.
|
||||||
|
}
|
||||||
size.height += CELL_MESSAGE_X_MARGIN;
|
size.height += CELL_MESSAGE_X_MARGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
size.width = MAX(size.width + CELL_MESSAGE_X_MARGIN, CELL_MIN_WIDTH);
|
size.width = MAX(size.width + CELL_MESSAGE_X_MARGIN, CELL_MIN_WIDTH);
|
||||||
size.height = MAX(size.height + CELL_MESSAGE_Y_MARGIN, CELL_MIN_HEIGHT);
|
size.height = MAX(size.height + CELL_MESSAGE_Y_MARGIN, CELL_MIN_HEIGHT);
|
||||||
return size;
|
return size;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ static void linphone_iphone_file_transfer_recv(LinphoneChatMessage *message, con
|
||||||
LOGI(@"Transfer of %s (%d bytes): download finished", linphone_content_get_name(content), size);
|
LOGI(@"Transfer of %s (%d bytes): download finished", linphone_content_get_name(content), size);
|
||||||
assert([thiz.data length] == linphone_content_get_file_size(content));
|
assert([thiz.data length] == linphone_content_get_file_size(content));
|
||||||
NSString *fileType = [NSString stringWithUTF8String:linphone_content_get_type(content)];
|
NSString *fileType = [NSString stringWithUTF8String:linphone_content_get_type(content)];
|
||||||
if([fileType isEqualToString:@"image"]) {
|
if ([fileType isEqualToString:@"image"]) {
|
||||||
// we're finished, save the image and update the message
|
// we're finished, save the image and update the message
|
||||||
UIImage *image = [UIImage imageWithData:thiz.data];
|
UIImage *image = [UIImage imageWithData:thiz.data];
|
||||||
if (!image) {
|
if (!image) {
|
||||||
|
|
@ -113,15 +113,12 @@ static void linphone_iphone_file_transfer_recv(LinphoneChatMessage *message, con
|
||||||
[thiz stopAndDestroy];
|
[thiz stopAndDestroy];
|
||||||
CFRelease((__bridge CFTypeRef)thiz);
|
CFRelease((__bridge CFTypeRef)thiz);
|
||||||
}];
|
}];
|
||||||
} else{
|
} else {
|
||||||
[[LinphoneManager.instance fileTransferDelegates] removeObject:thiz];
|
[[LinphoneManager.instance fileTransferDelegates] removeObject:thiz];
|
||||||
|
|
||||||
NSString *key = @"localvideo";
|
NSString *key = [fileType isEqualToString:@"file"] ? @"localfile" : @"localvideo";
|
||||||
NSString *name =[NSString stringWithUTF8String:linphone_content_get_name(content)];
|
NSString *name =[NSString stringWithUTF8String:linphone_content_get_name(content)];
|
||||||
|
|
||||||
if([fileType isEqualToString:@"file"]){
|
|
||||||
key = @"localfile";
|
|
||||||
}
|
|
||||||
[LinphoneManager setValueInMessageAppData:@"saving..." forKey:key inMessage:message];
|
[LinphoneManager setValueInMessageAppData:@"saving..." forKey:key inMessage:message];
|
||||||
|
|
||||||
//write file to path
|
//write file to path
|
||||||
|
|
@ -131,7 +128,7 @@ static void linphone_iphone_file_transfer_recv(LinphoneChatMessage *message, con
|
||||||
contents:thiz.data
|
contents:thiz.data
|
||||||
attributes:nil];
|
attributes:nil];
|
||||||
|
|
||||||
[LinphoneManager setValueInMessageAppData:filePath forKey:key inMessage:message];
|
[LinphoneManager setValueInMessageAppData:name forKey:key inMessage:message];
|
||||||
|
|
||||||
[NSNotificationCenter.defaultCenter
|
[NSNotificationCenter.defaultCenter
|
||||||
postNotificationName:kLinphoneFileTransferRecvUpdate
|
postNotificationName:kLinphoneFileTransferRecvUpdate
|
||||||
|
|
@ -199,56 +196,14 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)upload:(UIImage *)image withURL:(NSURL *)url forChatRoom:(LinphoneChatRoom *)chatRoom withQuality:(float)quality {
|
- (void)uploadData:(NSData *)data forChatRoom:(LinphoneChatRoom *)chatRoom type:(NSString *)type subtype:(NSString *)subtype name:(NSString *)name key:(NSString *)key keyData:(NSString *)keyData qualityData:(NSNumber *)qualityData {
|
||||||
[LinphoneManager.instance.fileTransferDelegates addObject:self];
|
|
||||||
|
|
||||||
LinphoneContent *content = linphone_core_create_content(linphone_chat_room_get_core(chatRoom));
|
|
||||||
_data = [NSMutableData dataWithData:UIImageJPEGRepresentation(image, quality)];
|
|
||||||
linphone_content_set_type(content, "image");
|
|
||||||
linphone_content_set_subtype(content, "jpeg");
|
|
||||||
linphone_content_set_name(
|
|
||||||
content, [[NSString stringWithFormat:@"%li-%f.jpg", (long)image.hash, [NSDate timeIntervalSinceReferenceDate]]
|
|
||||||
UTF8String]);
|
|
||||||
linphone_content_set_size(content, _data.length);
|
|
||||||
|
|
||||||
_message = linphone_chat_room_create_file_transfer_message(chatRoom, content);
|
|
||||||
linphone_content_unref(content);
|
|
||||||
|
|
||||||
linphone_chat_message_cbs_set_file_transfer_send(linphone_chat_message_get_callbacks(_message),
|
|
||||||
linphone_iphone_file_transfer_send);
|
|
||||||
|
|
||||||
if (url) {
|
|
||||||
// internal url is saved in the appdata for display and later save
|
|
||||||
[LinphoneManager setValueInMessageAppData:[url absoluteString] forKey:@"localimage" inMessage:_message];
|
|
||||||
[LinphoneManager setValueInMessageAppData:[NSNumber numberWithFloat:quality] forKey:@"uploadQuality" inMessage:_message];
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGI(@"%p Uploading content from message %p", self, _message);
|
|
||||||
linphone_chat_room_send_chat_message(chatRoom, _message);
|
|
||||||
|
|
||||||
if (linphone_core_lime_enabled(LC) == LinphoneLimeMandatory && !linphone_chat_room_lime_available(chatRoom)) {
|
|
||||||
[LinphoneManager.instance alertLIME:chatRoom];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)uploadFile:(NSData *)data forChatRoom:(LinphoneChatRoom *)chatRoom withUrl:(NSURL *)url {
|
|
||||||
[LinphoneManager.instance.fileTransferDelegates addObject:self];
|
[LinphoneManager.instance.fileTransferDelegates addObject:self];
|
||||||
|
|
||||||
LinphoneContent *content = linphone_core_create_content(linphone_chat_room_get_core(chatRoom));
|
LinphoneContent *content = linphone_core_create_content(linphone_chat_room_get_core(chatRoom));
|
||||||
_data = [NSMutableData dataWithData:data];
|
_data = [NSMutableData dataWithData:data];
|
||||||
|
linphone_content_set_type(content, [type UTF8String]);
|
||||||
NSString *filePath = [LinphoneManager documentFile:[url lastPathComponent]];
|
linphone_content_set_subtype(content, [subtype UTF8String]);
|
||||||
[[NSFileManager defaultManager] createFileAtPath:filePath
|
linphone_content_set_name(content, [name UTF8String]);
|
||||||
contents:_data
|
|
||||||
attributes:nil];
|
|
||||||
|
|
||||||
NSString *key = @"localvideo";
|
|
||||||
if(![[url pathExtension]isEqualToString:@"MOV"]) {
|
|
||||||
linphone_content_set_type(content, "file");
|
|
||||||
key = @"localfile";
|
|
||||||
}
|
|
||||||
|
|
||||||
linphone_content_set_name(content, [[url lastPathComponent] UTF8String]);
|
|
||||||
linphone_content_set_size(content, _data.length);
|
linphone_content_set_size(content, _data.length);
|
||||||
|
|
||||||
_message = linphone_chat_room_create_file_transfer_message(chatRoom, content);
|
_message = linphone_chat_room_create_file_transfer_message(chatRoom, content);
|
||||||
|
|
@ -257,7 +212,9 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
|
||||||
linphone_chat_message_cbs_set_file_transfer_send(linphone_chat_message_get_callbacks(_message),
|
linphone_chat_message_cbs_set_file_transfer_send(linphone_chat_message_get_callbacks(_message),
|
||||||
linphone_iphone_file_transfer_send);
|
linphone_iphone_file_transfer_send);
|
||||||
|
|
||||||
[LinphoneManager setValueInMessageAppData:filePath forKey:key inMessage:_message];
|
// internal url is saved in the appdata for display and later save
|
||||||
|
[LinphoneManager setValueInMessageAppData:keyData forKey:key inMessage:_message];
|
||||||
|
[LinphoneManager setValueInMessageAppData:qualityData forKey:@"uploadQuality" inMessage:_message];
|
||||||
|
|
||||||
LOGI(@"%p Uploading content from message %p", self, _message);
|
LOGI(@"%p Uploading content from message %p", self, _message);
|
||||||
linphone_chat_room_send_chat_message(chatRoom, _message);
|
linphone_chat_room_send_chat_message(chatRoom, _message);
|
||||||
|
|
@ -267,6 +224,28 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)upload:(UIImage *)image withURL:(NSURL *)url forChatRoom:(LinphoneChatRoom *)chatRoom withQuality:(float)quality {
|
||||||
|
NSString *name = [NSString stringWithFormat:@"%li-%f.jpg", (long)image.hash, [NSDate timeIntervalSinceReferenceDate]];
|
||||||
|
if (url)
|
||||||
|
[self uploadData:UIImageJPEGRepresentation(image, quality) forChatRoom:chatRoom type:@"image" subtype:@"jpeg" name:name key:@"localimage" keyData:[url absoluteString] qualityData:[NSNumber numberWithFloat:quality]];
|
||||||
|
else
|
||||||
|
[self uploadData:UIImageJPEGRepresentation(image, quality) forChatRoom:chatRoom type:@"image" subtype:@"jpeg" name:name key:@"localimage" keyData:nil qualityData:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)uploadFile:(NSData *)data forChatRoom:(LinphoneChatRoom *)chatRoom withUrl:(NSURL *)url {
|
||||||
|
NSString *name = [url lastPathComponent];
|
||||||
|
//save file to Documents
|
||||||
|
NSString *filePath = [LinphoneManager documentFile:name];
|
||||||
|
[[NSFileManager defaultManager] createFileAtPath:filePath
|
||||||
|
contents:[NSMutableData dataWithData:data]
|
||||||
|
attributes:nil];
|
||||||
|
|
||||||
|
if ([[url pathExtension]isEqualToString:@"MOV"])
|
||||||
|
[self uploadData:data forChatRoom:chatRoom type:nil subtype:nil name:name key:@"localvideo" keyData:name qualityData:nil];
|
||||||
|
else
|
||||||
|
[self uploadData:data forChatRoom:chatRoom type:@"file" subtype:nil name:name key:@"localfile" keyData:name qualityData:nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (BOOL)download:(LinphoneChatMessage *)message {
|
- (BOOL)download:(LinphoneChatMessage *)message {
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ static NSString* groupName = @"group.belledonne-communications.linphone";
|
||||||
} else if ([provider hasItemConformingToTypeIdentifier:@"public.url"]) {
|
} else if ([provider hasItemConformingToTypeIdentifier:@"public.url"]) {
|
||||||
[self loadItem:provider typeIdentifier:@"public.url" defaults:defaults key:@"web"];
|
[self loadItem:provider typeIdentifier:@"public.url" defaults:defaults key:@"web"];
|
||||||
} else if ([provider hasItemConformingToTypeIdentifier:@"public.movie"]) {
|
} else if ([provider hasItemConformingToTypeIdentifier:@"public.movie"]) {
|
||||||
[self loadItem:provider typeIdentifier:@"public.movie" defaults:defaults key:@"file"];
|
[self loadItem:provider typeIdentifier:@"public.movie" defaults:defaults key:@"mov"];
|
||||||
} else if ([provider hasItemConformingToTypeIdentifier:@"public.plain-text"]) {
|
} else if ([provider hasItemConformingToTypeIdentifier:@"public.plain-text"]) {
|
||||||
[self loadItem:provider typeIdentifier:@"public.plain-text" defaults:defaults key:@"text"];
|
[self loadItem:provider typeIdentifier:@"public.plain-text" defaults:defaults key:@"text"];
|
||||||
} else if ([provider hasItemConformingToTypeIdentifier:@"com.adobe.pdf"]) {
|
} else if ([provider hasItemConformingToTypeIdentifier:@"com.adobe.pdf"]) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue