Skip to content

Commit 021e2e2

Browse files
golf1052Trolldemorted
authored andcommitted
Download and decrypt attachments
It's kind of ugly right now.
1 parent 9ac6774 commit 021e2e2

File tree

15 files changed

+590
-150
lines changed

15 files changed

+590
-150
lines changed

Signal-Windows.Lib/IncomingMessages.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,15 @@ private void HandleSignalMessage(SignalServiceEnvelope envelope, SignalServiceCo
440440
ContentType = "",
441441
Key = pointer.Key,
442442
Relay = pointer.Relay,
443-
StorageId = pointer.Id
443+
StorageId = pointer.Id,
444+
Size = (long)pointer.Size,
445+
Digest = pointer.Digest
444446
};
445447
attachments.Add(sa);
446448
}
449+
450+
// Make sure to update attachments count
451+
message.AttachmentsCount = (uint)attachments.Count;
447452
}
448453
SignalLibHandle.Instance.SaveAndDispatchSignalMessage(message, conversation);
449454
}

Signal-Windows.Lib/LibUtils.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
using libsignalservice;
1+
using libsignalservice;
22
using libsignalservice.push;
33
using Microsoft.Extensions.Logging;
4+
using Microsoft.Toolkit.Uwp.Notifications;
45
using System;
56
using System.Collections.Generic;
67
using System.Linq;
78
using System.Text;
89
using System.Threading;
910
using System.Threading.Tasks;
11+
using Windows.Networking.BackgroundTransfer;
12+
using Windows.Storage;
1013
using Windows.UI.Core;
14+
using Windows.UI.Notifications;
1115

1216
namespace Signal_Windows.Lib
1317
{
@@ -148,5 +152,27 @@ public static EventWaitHandle OpenResetEventUnset()
148152
Logger.LogTrace("OpenResetEventUnset()");
149153
return new EventWaitHandle(false, EventResetMode.ManualReset, GlobalEventWaitHandleName, out bool createdNew);
150154
}
155+
156+
public static ToastNotification CreateToastNotification(string text)
157+
{
158+
ToastContent toastContent = new ToastContent()
159+
{
160+
Visual = new ToastVisual()
161+
{
162+
BindingGeneric = new ToastBindingGeneric()
163+
{
164+
Children =
165+
{
166+
new AdaptiveText()
167+
{
168+
Text = text,
169+
HintWrap = true
170+
}
171+
}
172+
}
173+
}
174+
};
175+
return new ToastNotification(toastContent.GetXml());
176+
}
151177
}
152178
}

Signal-Windows.Lib/Migrations/SignalDB/20180203062229_m4.Designer.cs

Lines changed: 256 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Microsoft.EntityFrameworkCore.Migrations;
4+
5+
namespace Signal_Windows.Migrations
6+
{
7+
public partial class m4 : Migration
8+
{
9+
protected override void Up(MigrationBuilder migrationBuilder)
10+
{
11+
migrationBuilder.AddColumn<byte[]>(
12+
name: "Digest",
13+
table: "Attachments",
14+
nullable: true);
15+
16+
migrationBuilder.AddColumn<long>(
17+
name: "Size",
18+
table: "Attachments",
19+
nullable: false,
20+
defaultValue: 0L);
21+
}
22+
23+
protected override void Down(MigrationBuilder migrationBuilder)
24+
{
25+
migrationBuilder.DropColumn(
26+
name: "Digest",
27+
table: "Attachments");
28+
29+
migrationBuilder.DropColumn(
30+
name: "Size",
31+
table: "Attachments");
32+
}
33+
}
34+
}

Signal-Windows.Lib/Migrations/SignalDB/SignalDBContextModelSnapshot.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ partial class SignalDBContextModelSnapshot : ModelSnapshot
1414
protected override void BuildModel(ModelBuilder modelBuilder)
1515
{
1616
modelBuilder
17-
.HasAnnotation("ProductVersion", "1.1.2");
17+
.HasAnnotation("ProductVersion", "1.1.4");
1818

1919
modelBuilder.Entity("Signal_Windows.Models.GroupMembership", b =>
2020
{
@@ -41,6 +41,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
4141

4242
b.Property<string>("ContentType");
4343

44+
b.Property<byte[]>("Digest");
45+
4446
b.Property<string>("FileName");
4547

4648
b.Property<byte[]>("Key");
@@ -51,6 +53,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
5153

5254
b.Property<string>("SentFileName");
5355

56+
b.Property<long>("Size");
57+
5458
b.Property<int>("Status");
5559

5660
b.Property<ulong>("StorageId");

0 commit comments

Comments
 (0)