public static void SendEncryptedMultiMediaInternal(TLEncryptedChat chat, TLDecryptedMessage message, IMTProtoService mtProtoService, ICacheService cacheService) { Execute.BeginOnUIThread(() => { var chat17 = chat as TLEncryptedChat17; if (chat17 == null) { return; } var randomId = new TLVector <TLLong>(); var data = new TLVector <TLString>(); var inputFile = new TLVector <TLInputEncryptedFileBase>(); var mediaGroup = message.Media as TLDecryptedMessageMediaGroup; if (mediaGroup != null) { for (var i = 0; i < mediaGroup.Group.Count; i++) { var message73 = mediaGroup.Group[i] as TLDecryptedMessage73; if (message73 == null) { return; } if (message73.InputFile == null) { return; } randomId.Add(message73.RandomId); var messageLayer = TLUtils.GetDecryptedMessageLayer(chat17.Layer, message73.InSeqNo, message73.OutSeqNo, message73) as TLDecryptedMessageLayer17; if (message73.InSeqNo.Value == -1 && message73.OutSeqNo.Value == -1) { var inSeqNo = TLUtils.GetInSeqNo(mtProtoService.CurrentUserId, chat17); var outSeqNo = TLUtils.GetOutSeqNo(mtProtoService.CurrentUserId, chat17); message73.InSeqNo = inSeqNo; message73.OutSeqNo = outSeqNo; message73.NotifyOfPropertyChange(() => message73.InSeqNo); message73.NotifyOfPropertyChange(() => message73.OutSeqNo); messageLayer.InSeqNo = inSeqNo; messageLayer.OutSeqNo = outSeqNo; chat17.RawOutSeqNo = new TLInt(chat17.RawOutSeqNo.Value + 1); } data.Add(TLUtils.EncryptMessage(messageLayer, mtProtoService.CurrentUserId, chat)); inputFile.Add(message73.InputFile); System.Diagnostics.Debug.WriteLine("Send photo random_id={0} in_seq_no={1} out_seq_no={2}", message73.RandomId, message73.InSeqNo, message73.OutSeqNo); } } if (randomId.Count == 0) { return; } System.Diagnostics.Debug.WriteLine("Send photo random_id=[{0}]", string.Join(",", randomId)); mtProtoService.SendEncryptedMultiMediaAsync( new TLInputEncryptedChat { AccessHash = chat.AccessHash, ChatId = chat.Id }, randomId, data, inputFile, result => Execute.BeginOnUIThread(() => { message.Media.UploadingProgress = 0.0; message.Status = MessageStatus.Confirmed; message.NotifyOfPropertyChange(() => message.Status); if (mediaGroup != null) { for (var i = mediaGroup.Group.Count - 1; i >= 0; i--) { var item = mediaGroup.Group[i] as TLDecryptedMessage; if (item != null) { item.Media.UploadingProgress = 0.0; item.Status = MessageStatus.Confirmed; item.NotifyOfPropertyChange(() => message.Status); ProcessSentEncryptedFile(item, result[i]); cacheService.SyncSendingDecryptedMessage(chat.Id, result[i].Date, mediaGroup.Group[i].RandomId, m => { }); } } } }), () => { message.Status = MessageStatus.Confirmed; message.NotifyOfPropertyChange(() => message.Status); }, error => { message.Status = MessageStatus.Failed; message.NotifyOfPropertyChange(() => message.Status); Execute.ShowDebugMessage("messages.sendEncryptedFile error " + error); }); }); }
public void Resend(TLDecryptedMessage message) #endif { if (message == null) { return; } var chat = Chat as TLEncryptedChat; if (chat == null) { return; } TLObject obj = message; var decryptedMessage17 = message as TLDecryptedMessage17; if (decryptedMessage17 != null) { var encryptedChat17 = chat as TLEncryptedChat17; if (encryptedChat17 == null) { return; } var messageLayer17 = new TLDecryptedMessageLayer17(); messageLayer17.RandomBytes = TLString.Empty; messageLayer17.InSeqNo = decryptedMessage17.InSeqNo; messageLayer17.OutSeqNo = decryptedMessage17.OutSeqNo; messageLayer17.Layer = encryptedChat17.Layer; messageLayer17.Message = decryptedMessage17; obj = messageLayer17; } message.Status = MessageStatus.Sending; if (message.Media is TLDecryptedMessageMediaEmpty) { SendEncrypted(chat, obj, MTProtoService, CacheService); } else { message.Media.UploadingProgress = 0.001; if (message.Media is TLDecryptedMessageMediaPhoto) { SendPhotoInternal(null, obj); } else if (message.Media is TLDecryptedMessageMediaVideo) { SendVideoInternal(null, obj); } else if (message.Media is TLDecryptedMessageMediaDocument) { #if WP81 var file = await GetStorageFile(message.Media); if (file != null) { SendDocumentInternal(file, message); } else { MessageBox.Show(AppResources.UnableToAccessDocument, AppResources.Error, MessageBoxButton.OK); message.Status = MessageStatus.Failed; DeleteMessage(message); return; } #else SendDocumentInternal(null, message); #endif } else if (message.Media is TLDecryptedMessageMediaAudio) { #if WP8 SendAudioInternal(obj); #endif } else if (message.Media is TLDecryptedMessageMediaContact) { } } message.NotifyOfPropertyChange(() => message.Status); }