mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Chat: file transfer fix again
This commit is contained in:
parent
a2097773ca
commit
9b72bf00ce
5 changed files with 84 additions and 77 deletions
|
|
@ -32,6 +32,7 @@
|
|||
@property(weak, nonatomic) IBOutlet UIProgressView *fileTransferProgress;
|
||||
@property(weak, nonatomic) IBOutlet UIButton *cancelButton;
|
||||
@property(weak, nonatomic) IBOutlet UIView *imageSubView;
|
||||
@property(weak, nonatomic) IBOutlet UIView *totalView;
|
||||
|
||||
- (void)setChatMessage:(LinphoneChatMessage *)message;
|
||||
- (void)connectToFileDelegate:(FileTransferDelegate *)ftd;
|
||||
|
|
|
|||
|
|
@ -57,11 +57,9 @@
|
|||
return;
|
||||
}
|
||||
|
||||
[self disconnectFromFileDelegate];
|
||||
_messageImageView.image = nil;
|
||||
_fileTransferProgress.progress = 0;
|
||||
|
||||
[super setChatMessage:amessage];
|
||||
[self disconnectFromFileDelegate];
|
||||
|
||||
if (amessage) {
|
||||
const LinphoneContent *c = linphone_chat_message_get_file_transfer_information(amessage);
|
||||
|
|
@ -70,15 +68,18 @@
|
|||
for (FileTransferDelegate *aftd in [[LinphoneManager instance] fileTransferDelegates]) {
|
||||
if (linphone_chat_message_get_file_transfer_information(aftd.message) &&
|
||||
strcmp(name, linphone_content_get_name(
|
||||
linphone_chat_message_get_file_transfer_information(amessage))) == 0) {
|
||||
LOGI(@"Chat message [%p] with file transfer delegate [%p], connecting to it!", amessage, aftd);
|
||||
[self connectToFileDelegate:aftd];
|
||||
linphone_chat_message_get_file_transfer_information(aftd.message))) == 0) {
|
||||
if (ftd != aftd) {
|
||||
LOGI(@"Chat message [%p] with file transfer delegate [%p], connecting to it!", amessage, aftd);
|
||||
[self connectToFileDelegate:aftd];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[self update];
|
||||
|
||||
[super setChatMessage:amessage];
|
||||
}
|
||||
|
||||
- (void)update {
|
||||
|
|
@ -88,19 +89,11 @@
|
|||
}
|
||||
[super update];
|
||||
|
||||
LinphoneChatMessageState state = linphone_chat_message_get_state(self.message);
|
||||
if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) {
|
||||
if (ftd) {
|
||||
[ftd stopAndDestroy];
|
||||
ftd = nil;
|
||||
}
|
||||
}
|
||||
|
||||
const char *url = linphone_chat_message_get_external_body_url(self.message);
|
||||
BOOL is_external =
|
||||
(url && (strstr(url, "http") == url)) || linphone_chat_message_get_file_transfer_information(self.message);
|
||||
NSString *localImage = [LinphoneManager getMessageAppDataForKey:@"localimage" inMessage:self.message];
|
||||
|
||||
BOOL fullScreenImage = NO;
|
||||
assert(is_external || localImage);
|
||||
if (localImage) {
|
||||
// we did not load the image yet, so start doing so
|
||||
|
|
@ -134,18 +127,23 @@
|
|||
_downloadButton.hidden = YES;
|
||||
} else {
|
||||
_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = YES;
|
||||
fullScreenImage = YES;
|
||||
}
|
||||
// we must download the image: either it has already started (show cancel button) or not yet (show download
|
||||
// button)
|
||||
} else {
|
||||
// CGRect newFrame = _imageSubView.frame;
|
||||
// newFrame.origin.y = _messageImageView.frame.origin.y + ((ftd.message == nil) ? 0 :
|
||||
//_messageImageView.frame.size.height);
|
||||
// _imageSubView.frame = newFrame;
|
||||
_messageImageView.hidden = _cancelButton.hidden = (ftd.message == nil);
|
||||
_downloadButton.hidden = !_cancelButton.hidden;
|
||||
_fileTransferProgress.hidden = NO;
|
||||
}
|
||||
|
||||
// resize image so that it take the full bubble space available
|
||||
CGRect newFrame = _totalView.frame;
|
||||
newFrame.origin.x = newFrame.origin.y = 0;
|
||||
if (!fullScreenImage) {
|
||||
newFrame.size.height -= _imageSubView.frame.size.height;
|
||||
}
|
||||
_messageImageView.frame = newFrame;
|
||||
}
|
||||
|
||||
- (IBAction)onDownloadClick:(id)event {
|
||||
|
|
@ -188,7 +186,6 @@
|
|||
|
||||
- (void)connectToFileDelegate:(FileTransferDelegate *)aftd {
|
||||
ftd = aftd;
|
||||
// assert(ftd.message == self.message);
|
||||
_fileTransferProgress.progress = 0;
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
|
|
@ -219,7 +216,8 @@
|
|||
_fileTransferProgress.progress = MAX(_fileTransferProgress.progress, progress);
|
||||
_fileTransferProgress.hidden = _cancelButton.hidden = (_fileTransferProgress.progress == 1.f);
|
||||
} else {
|
||||
[self update];
|
||||
ChatConversationView *view = VIEW(ChatConversationView);
|
||||
[view.tableController updateChatEntry:self.message];
|
||||
}
|
||||
}
|
||||
- (void)onFileTransferRecvUpdate:(NSNotification *)notif {
|
||||
|
|
@ -229,7 +227,8 @@
|
|||
_fileTransferProgress.progress = MAX(_fileTransferProgress.progress, progress);
|
||||
_fileTransferProgress.hidden = _cancelButton.hidden = (_fileTransferProgress.progress == 1.f);
|
||||
} else {
|
||||
[self update];
|
||||
ChatConversationView *view = VIEW(ChatConversationView);
|
||||
[view.tableController updateChatEntry:self.message];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
<outlet property="imageSubView" destination="GmN-7v-uuO" id="k9r-Xc-csv"/>
|
||||
<outlet property="messageImageView" destination="yMW-cT-bpU" id="MNr-F2-abQ"/>
|
||||
<outlet property="statusImage" destination="hSL-MF-B9b" id="cwm-bV-O3a"/>
|
||||
<outlet property="totalView" destination="8I3-n2-0kS" id="aa8-j9-saW"/>
|
||||
</connections>
|
||||
</placeholder>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
|
|
@ -52,57 +53,64 @@
|
|||
<color key="textColor" red="1" green="0.36862745099999999" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="splashscreen.png" id="yMW-cT-bpU" userLabel="image" customClass="UILoadingImageView">
|
||||
<rect key="frame" x="48" y="24" width="274" height="67"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<animations/>
|
||||
<gestureRecognizers/>
|
||||
<connections>
|
||||
<outletCollection property="gestureRecognizers" destination="aDF-hC-ddO" appends="YES" id="7kE-0j-s1g"/>
|
||||
</connections>
|
||||
</imageView>
|
||||
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="128 Ko / 172 Ko" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Aaa-MV-yvm" userLabel="fileSizeLabel">
|
||||
<rect key="frame" x="24" y="59" width="274" height="12"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<animations/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" id="GmN-7v-uuO" userLabel="imageSubView">
|
||||
<rect key="frame" x="48" y="91" width="274" height="32"/>
|
||||
<view contentMode="scaleToFill" id="8I3-n2-0kS" userLabel="view">
|
||||
<rect key="frame" x="48" y="24" width="266" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" id="USm-wC-GvG" userLabel="transferProgress">
|
||||
<rect key="frame" x="10" y="0.0" width="254" height="2"/>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="splashscreen.png" id="yMW-cT-bpU" userLabel="image" customClass="UILoadingImageView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="266" height="68"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxX="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<animations/>
|
||||
<gestureRecognizers/>
|
||||
<connections>
|
||||
<outletCollection property="gestureRecognizers" destination="aDF-hC-ddO" appends="YES" id="7kE-0j-s1g"/>
|
||||
</connections>
|
||||
</imageView>
|
||||
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="128 Ko / 172 Ko" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Aaa-MV-yvm" userLabel="fileSizeLabel">
|
||||
<rect key="frame" x="-7" y="44" width="265" height="12"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<animations/>
|
||||
</progressView>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="N75-gL-R6t" userLabel="transferButton" customClass="UIRoundBorderedButton">
|
||||
<rect key="frame" x="75" y="4" width="124" height="27"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<view contentMode="scaleToFill" id="GmN-7v-uuO" userLabel="imageSubView">
|
||||
<rect key="frame" x="0.0" y="68" width="265" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" widthSizable="YES" flexibleMaxX="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" id="USm-wC-GvG" userLabel="transferProgress">
|
||||
<rect key="frame" x="10" y="0.0" width="245" height="2"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
|
||||
<animations/>
|
||||
</progressView>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="N75-gL-R6t" userLabel="downloadButton" customClass="UIRoundBorderedButton">
|
||||
<rect key="frame" x="70" y="4" width="124" height="27"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<animations/>
|
||||
<state key="normal" title="DOWNLOAD" backgroundImage="color_G.png">
|
||||
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onDownloadClick:" destination="-1" eventType="touchUpInside" id="8BO-9E-iOX"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="6dl-Nz-rdv" userLabel="cancelButton" customClass="UIRoundBorderedButton">
|
||||
<rect key="frame" x="70" y="4" width="124" height="27"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<animations/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||
<state key="normal" title="CANCEL" backgroundImage="color_I.png">
|
||||
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<state key="highlighted" backgroundImage="color_M.png"/>
|
||||
<connections>
|
||||
<action selector="onCancelClick:" destination="-1" eventType="touchUpInside" id="D9y-vf-I4Y"/>
|
||||
</connections>
|
||||
</button>
|
||||
</subviews>
|
||||
<animations/>
|
||||
<state key="normal" title="DOWNLOAD" backgroundImage="color_G.png">
|
||||
<color key="titleColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<connections>
|
||||
<action selector="onDownloadClick:" destination="-1" eventType="touchUpInside" id="8BO-9E-iOX"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="6dl-Nz-rdv" userLabel="cancelButton" customClass="UIRoundBorderedButton">
|
||||
<rect key="frame" x="75" y="4" width="124" height="27"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<animations/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="15"/>
|
||||
<state key="normal" title="CANCEL" backgroundImage="color_I.png">
|
||||
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</state>
|
||||
<state key="highlighted" backgroundImage="color_M.png"/>
|
||||
<connections>
|
||||
<action selector="onCancelClick:" destination="-1" eventType="touchUpInside" id="D9y-vf-I4Y"/>
|
||||
</connections>
|
||||
</button>
|
||||
</view>
|
||||
</subviews>
|
||||
<animations/>
|
||||
</view>
|
||||
|
|
@ -128,12 +136,12 @@
|
|||
</view>
|
||||
<tapGestureRecognizer id="aDF-hC-ddO" userLabel="imageClick">
|
||||
<connections>
|
||||
<action selector="onImageClick:" destination="-2" id="yv0-9g-sye"/>
|
||||
<action selector="onImageClick:" destination="-1" id="feN-LT-89b"/>
|
||||
</connections>
|
||||
</tapGestureRecognizer>
|
||||
<tapGestureRecognizer id="5ZI-Ip-lGl" userLabel="resendClick">
|
||||
<connections>
|
||||
<action selector="onResendClick:" destination="-2" id="0Vh-VO-NZU"/>
|
||||
<action selector="onResendClick:" destination="-1" id="XOF-AF-Hes"/>
|
||||
<outlet property="delegate" destination="Y7i-Gm-AdY" id="Idp-Op-un2"/>
|
||||
</connections>
|
||||
</tapGestureRecognizer>
|
||||
|
|
|
|||
|
|
@ -202,10 +202,7 @@
|
|||
}
|
||||
#pragma mark - State changed handling
|
||||
static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState state) {
|
||||
UIChatBubbleTextCell *thiz = (__bridge UIChatBubbleTextCell *)linphone_chat_message_get_user_data(msg);
|
||||
LOGI(@"State for message [%p] changed to %s", msg, linphone_chat_message_state_to_string(state));
|
||||
[thiz update];
|
||||
|
||||
ChatConversationView *view = VIEW(ChatConversationView);
|
||||
[view.tableController updateChatEntry:msg];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,12 +75,14 @@ static void linphone_iphone_file_transfer_recv(LinphoneChatMessage *message, con
|
|||
postNotificationName:kLinphoneFileTransferRecvUpdate
|
||||
object:thiz
|
||||
userInfo:@{
|
||||
@"state" : @(linphone_chat_message_get_state(message)),
|
||||
@"state" : @(LinphoneChatMessageStateDelivered), // we dont want to
|
||||
// trigger
|
||||
// FileTransferDone here
|
||||
@"image" : image,
|
||||
@"progress" :
|
||||
@([thiz.data length] * 1.f / linphone_content_get_size(content)),
|
||||
@"progress" : @(1.f),
|
||||
}];
|
||||
|
||||
[thiz stopAndDestroy];
|
||||
CFRelease((__bridge CFTypeRef)thiz);
|
||||
}];
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue