private void OnDataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) { var m = this.DataContext as MessageRecord; if (m != null) { this.MessageRecord = m; VisualStateManager.GoToState(this, m.IsOutgoing ? "Outgoing" : "Incoming", true); if (m.IsFailed) { VisualStateManager.GoToState(this, "Failed", true); } else { if (!m.IsOutgoing) VisualStateManager.GoToState(this, "None", true); else if (m.IsPending) VisualStateManager.GoToState(this, "Pending", true); else if (m.IsDelivered) VisualStateManager.GoToState(this, "Delivered", true); else VisualStateManager.GoToState(this, "Sent", true); } if (m.IsKeyExchange) { VisualStateManager.GoToState(this, "KeyExchange", true); } } }
public ConfirmIdentityDialog(MessageRecord record) { this.InitializeComponent(); this._messageRecord = record; if (record.MismatchedIdentities == null) CancelCommand.Execute(null); if (record.MismatchedIdentities != null) mismatch = record.MismatchedIdentities[0]; }
public static void NewMessage(MessageRecord message) { var content = new ToastContent() { Launch = new QueryString() { {"action", "viewConversation" }, { "threadId", message.ThreadId.ToString() } }.ToString(), Visual = new ToastVisual() { TitleText = new ToastText() { Text = $"{message.IndividualRecipient.ShortString} sent you a message" }, BodyTextLine1 = new ToastText() { Text = $"{message.Body.Body}" } }, Actions = new ToastActionsCustom() { Inputs = { new ToastTextBox("tbReply") { PlaceholderContent = "Type a response" } }, Buttons = { new ToastButton("reply", "reply") { ActivationType = ToastActivationType.Background, ImageUri = "Assets/ic_done_all_white_18dp.png", TextBoxId = "tbReply" } } }, Audio = new ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.IM") } }; var doc = content.GetXml(); // Generate WinRT notification var noti = new ToastNotification(doc); ToastNotificationManager.CreateToastNotifier().Show(noti); }
private void OnDataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args) { var m = this.DataContext as MessageRecord; if (m != null) { this.MessageRecord = m; Update(); } }
private void processMessageRecord(MessageRecord record) { if (record.IsOutgoing) processOutgoingMessageRecord(record); else processIncomingMessageRecord(record); }
private void processIncomingMessageRecord(MessageRecord record) { try { PushDatabase pushDatabase = DatabaseFactory.getPushDatabase(); var messageDatabase = DatabaseFactory.getMessageDatabase(); messageDatabase.RemoveMismatchedIdentity(record.MessageId, mismatch.RecipientId, mismatch.IdentityKey); TextSecureEnvelope envelope = new TextSecureEnvelope((uint)TextSecureProtos.Envelope.Types.Type.PREKEY_BUNDLE, record.IndividualRecipient.getNumber(), (uint)record.RecipientDeviceId, "", (ulong)TimeUtil.GetUnixTimestamp(record.DateSent), Base64.decode(record.Body.Body), null); long pushId = pushDatabase.Insert(envelope); var task = new PushDecryptTask(pushId, record.MessageId, record.IndividualRecipient.getNumber()); App.Current.Worker.AddTaskActivities(task); } catch (IOException e) { throw new Exception(); } }
private void processOutgoingMessageRecord(MessageRecord record) { var messageDatabase = DatabaseFactory.getMessageDatabase(); /*MmsDatabase mmsDatabase = DatabaseFactory.getMmsDatabase()); MmsAddressDatabase mmsAddressDatabase = DatabaseFactory.getMmsAddressDatabase();*/ /*if (messageRecord.isMms()) { mmsDatabase.removeMismatchedIdentity(messageRecord.MismatchedIdentities, mismatch.RecipientId, mismatch.IdentityKey); var recipients = mmsAddressDatabase.getRecipientsForId(messageRecord.MessageId); if (recipients.isGroupRecipient()) MessageSender.resendGroupMessage(, masterSecret, messageRecord, mismatch.getRecipientId()); else MessageSender.resend(getContext(), masterSecret, messageRecord); } else {*/ messageDatabase.RemoveMismatchedIdentity(record.MessageId, mismatch.RecipientId, mismatch.IdentityKey); MessageSender.resend(record); // } }
/* public static long send( OutgoingMediaMessage message, long threadId) { try { ThreadDatabase threadDatabase = DatabaseFactory.getThreadDatabase(); MessageDatabase database = DatabaseFactory.getMessageDatabase(); long allocatedThreadId; if (threadId == -1) { allocatedThreadId = threadDatabase.getThreadIdFor(message.getRecipients(), message.getDistributionType()); } else { allocatedThreadId = threadId; } Recipients recipients = message.getRecipients(); long messageId = database.insertMessageOutbox(message, allocatedThreadId, System.currentTimeMillis()); sendMediaMessage(recipients, messageId); return allocatedThreadId; } catch (MmsException e) { Log.w(TAG, e); return threadId; } } public static void resendGroupMessage(MessageRecord messageRecord, long filterRecipientId) { if (!messageRecord.isMms()) throw new AssertionError("Not Group"); Recipients recipients = DatabaseFactory.getMmsAddressDatabase().getRecipientsForId(messageRecord.getId()); sendGroupPush(recipients, messageRecord.getId(), filterRecipientId); }*/ public static void resend(MessageRecord messageRecord) { try { long messageId = messageRecord.MessageId; bool keyExchange = messageRecord.IsKeyExchange; /* if (messageRecord.isMms()) // TODO: media { Recipients recipients = DatabaseFactory.getMmsAddressDatabase(context).getRecipientsForId(messageId); sendMediaMessage(recipients, forceSms, messageId); } else {*/ Recipients recipients = messageRecord.Recipients; sendTextMessage(recipients, keyExchange, messageId); //} } catch (Exception e) { Log.Warn(e.Message); } }