Skip to content

Commit 38cd95f

Browse files
committed
Support for group color sync
1 parent ddf8d33 commit 38cd95f

File tree

7 files changed

+81
-20
lines changed

7 files changed

+81
-20
lines changed

libsignal-service-dotnet/messages/SignalServiceAttachmentStream.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public class SignalServiceAttachmentStream : SignalServiceAttachment
2121
public int Height { get; }
2222

2323

24-
public SignalServiceAttachmentStream(Stream inputStream, string contentType, long length, string fileName, bool voiceNote, IProgressListener listener)
24+
public SignalServiceAttachmentStream(Stream inputStream, string contentType, long length, string fileName, bool voiceNote, IProgressListener? listener)
2525
: this(inputStream, contentType, length, fileName, voiceNote, null, 0, 0, listener)
2626
{
2727
}
2828

29-
public SignalServiceAttachmentStream(Stream inputStream, String contentType, long length, string fileName, bool voiceNote, byte[] preview, int width, int height, IProgressListener listener)
29+
public SignalServiceAttachmentStream(Stream inputStream, String contentType, long length, string fileName, bool voiceNote, byte[] preview, int width, int height, IProgressListener? listener)
3030
: base(contentType)
3131
{
3232
InputStream = inputStream;

libsignal-service-dotnet/messages/multidevice/DeviceContact.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ public class DeviceContact
66
public string Number { get; }
77
public string Name { get; }
88
public SignalServiceAttachmentStream Avatar { get; }
9-
public string Color { get; }
9+
public string? Color { get; }
1010
public VerifiedMessage Verified { get; }
1111
public byte[] ProfileKey { get; }
1212
public bool Blocked { get; }
1313
public uint? ExpirationTimer { get; }
1414

15-
public DeviceContact(string number, string name, SignalServiceAttachmentStream avatar, string color, VerifiedMessage verified, byte[] profileKey, bool blocked, uint? expirationTimer)
15+
public DeviceContact(string number, string name, SignalServiceAttachmentStream avatar, string? color, VerifiedMessage verified, byte[] profileKey, bool blocked, uint? expirationTimer)
1616
{
1717
Number = number;
1818
Name = name;

libsignal-service-dotnet/messages/multidevice/DeviceContactsInputStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public DeviceContact Read()// throws IOException
2626
string number = details.Number;
2727
string name = details.Name;
2828
SignalServiceAttachmentStream avatar = null;
29-
string color = details.ColorOneofCase == ContactDetails.ColorOneofOneofCase.Color ? details.Color : null;
29+
string? color = details.ColorOneofCase == ContactDetails.ColorOneofOneofCase.Color ? details.Color : null;
3030
VerifiedMessage verified = null;
3131
byte[] profileKey = null;
3232
bool blocked = false;

libsignal-service-dotnet/messages/multidevice/DeviceGroup.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ namespace libsignalservice.messages.multidevice
77
public class DeviceGroup
88
{
99
public byte[] Id { get; }
10-
public String Name { get; }
11-
public IList<String> Members { get; }
12-
public SignalServiceAttachmentStream Avatar { get; }
10+
public string? Name { get; }
11+
public IList<string> Members { get; }
12+
public SignalServiceAttachmentStream? Avatar { get; }
1313
public bool Active { get; }
1414
public uint? ExpirationTimer { get; }
15+
public string? Color { get; }
1516

16-
public DeviceGroup(byte[] id, string name, IList<string> members, SignalServiceAttachmentStream avatar, bool active, uint? expirationTimer)
17+
public DeviceGroup(byte[] id, string? name, IList<string> members, SignalServiceAttachmentStream? avatar, bool active, uint? expirationTimer, string? color)
1718
{
1819
Id = id;
1920
Name = name;
2021
Members = members;
2122
Avatar = avatar;
2223
Active = active;
2324
ExpirationTimer = expirationTimer;
25+
Color = color;
2426
}
2527
}
2628
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

libsignal-service-dotnet/messages/multidevice/DeviceGroupsInputStream.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public DeviceGroup Read()
2828
SignalServiceAttachmentStream avatar = null;
2929
bool active = details.Active;
3030
uint? expirationTimer = null;
31+
string? color = details.ColorOneofCase == GroupDetails.ColorOneofOneofCase.Color ? details.Color : null;
3132

3233
if (details.AvatarOneofCase == GroupDetails.AvatarOneofOneofCase.Avatar)
3334
{
@@ -42,7 +43,7 @@ public DeviceGroup Read()
4243
expirationTimer = details.ExpireTimer;
4344
}
4445

45-
return new DeviceGroup(id, name, members, avatar, active, expirationTimer);
46+
return new DeviceGroup(id, name, members, avatar, active, expirationTimer, color);
4647
}
4748
}
4849
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

libsignal-service-dotnet/protobuf/SignalService.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,5 +305,6 @@ message GroupDetails {
305305
repeated string members = 3;
306306
oneof avatar_oneof { Avatar avatar = 4; }
307307
oneof active_oneof { bool active = 5; } //[default = true] ### }
308-
oneof expireTimer_oneof { uint32 expireTimer = 6; }
308+
oneof expireTimer_oneof { uint32 expireTimer = 6; }
309+
oneof color_oneof { string color = 7; }
309310
}

libsignal-service-dotnet/push/SignalServiceProtos.cs

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,17 @@ static SignalServiceReflection() {
175175
"DGxlbmd0aF9vbmVvZkIOCgxudW1iZXJfb25lb2ZCDAoKbmFtZV9vbmVvZkIO",
176176
"CgxhdmF0YXJfb25lb2ZCDQoLY29sb3Jfb25lb2ZCEAoOdmVyaWZpZWRfb25l",
177177
"b2ZCEgoQcHJvZmlsZUtleV9vbmVvZkIPCg1ibG9ja2VkX29uZW9mQhMKEWV4",
178-
"cGlyZVRpbWVyX29uZW9mIsACCgxHcm91cERldGFpbHMSDAoCaWQYASABKAxI",
178+
"cGlyZVRpbWVyX29uZW9mIuACCgxHcm91cERldGFpbHMSDAoCaWQYASABKAxI",
179179
"ABIOCgRuYW1lGAIgASgJSAESDwoHbWVtYmVycxgDIAMoCRIxCgZhdmF0YXIY",
180180
"BCABKAsyHy50ZXh0c2VjdXJlLkdyb3VwRGV0YWlscy5BdmF0YXJIAhIQCgZh",
181-
"Y3RpdmUYBSABKAhIAxIVCgtleHBpcmVUaW1lchgGIAEoDUgEGlYKBkF2YXRh",
182-
"chIVCgtjb250ZW50VHlwZRgBIAEoCUgAEhAKBmxlbmd0aBgCIAEoDUgBQhMK",
183-
"EWNvbnRlbnRUeXBlX29uZW9mQg4KDGxlbmd0aF9vbmVvZkIKCghpZF9vbmVv",
184-
"ZkIMCgpuYW1lX29uZW9mQg4KDGF2YXRhcl9vbmVvZkIOCgxhY3RpdmVfb25l",
185-
"b2ZCEwoRZXhwaXJlVGltZXJfb25lb2ZCWgorb3JnLndoaXNwZXJzeXN0ZW1z",
186-
"LnRleHRzZWN1cmUuaW50ZXJuYWwucHVzaEITU2lnbmFsU2VydmljZVByb3Rv",
187-
"c6oCFWxpYnNpZ25hbHNlcnZpY2UucHVzaGIGcHJvdG8z"));
181+
"Y3RpdmUYBSABKAhIAxIVCgtleHBpcmVUaW1lchgGIAEoDUgEEg8KBWNvbG9y",
182+
"GAcgASgJSAUaVgoGQXZhdGFyEhUKC2NvbnRlbnRUeXBlGAEgASgJSAASEAoG",
183+
"bGVuZ3RoGAIgASgNSAFCEwoRY29udGVudFR5cGVfb25lb2ZCDgoMbGVuZ3Ro",
184+
"X29uZW9mQgoKCGlkX29uZW9mQgwKCm5hbWVfb25lb2ZCDgoMYXZhdGFyX29u",
185+
"ZW9mQg4KDGFjdGl2ZV9vbmVvZkITChFleHBpcmVUaW1lcl9vbmVvZkINCgtj",
186+
"b2xvcl9vbmVvZkJaCitvcmcud2hpc3BlcnN5c3RlbXMudGV4dHNlY3VyZS5p",
187+
"bnRlcm5hbC5wdXNoQhNTaWduYWxTZXJ2aWNlUHJvdG9zqgIVbGlic2lnbmFs",
188+
"c2VydmljZS5wdXNoYgZwcm90bzM="));
188189
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
189190
new pbr::FileDescriptor[] { },
190191
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
@@ -214,7 +215,7 @@ static SignalServiceReflection() {
214215
new pbr::GeneratedClrTypeInfo(typeof(global::libsignalservice.push.AttachmentPointer), global::libsignalservice.push.AttachmentPointer.Parser, new[]{ "Id", "ContentType", "Key", "Size", "Thumbnail", "Digest", "FileName", "Flags", "Width", "Height" }, new[]{ "IdOneof", "ContentTypeOneof", "KeyOneof", "SizeOneof", "ThumbnailOneof", "DigestOneof", "FileNameOneof", "FlagsOneof", "WidthOneof", "HeightOneof" }, new[]{ typeof(global::libsignalservice.push.AttachmentPointer.Types.Flags) }, null),
215216
new pbr::GeneratedClrTypeInfo(typeof(global::libsignalservice.push.GroupContext), global::libsignalservice.push.GroupContext.Parser, new[]{ "Id", "Type", "Name", "Members", "Avatar" }, new[]{ "IdOneof", "TypeOneof", "NameOneof", "AvatarOneof" }, new[]{ typeof(global::libsignalservice.push.GroupContext.Types.Type) }, null),
216217
new pbr::GeneratedClrTypeInfo(typeof(global::libsignalservice.push.ContactDetails), global::libsignalservice.push.ContactDetails.Parser, new[]{ "Number", "Name", "Avatar", "Color", "Verified", "ProfileKey", "Blocked", "ExpireTimer" }, new[]{ "NumberOneof", "NameOneof", "AvatarOneof", "ColorOneof", "VerifiedOneof", "ProfileKeyOneof", "BlockedOneof", "ExpireTimerOneof" }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::libsignalservice.push.ContactDetails.Types.Avatar), global::libsignalservice.push.ContactDetails.Types.Avatar.Parser, new[]{ "ContentType", "Length" }, new[]{ "ContentTypeOneof", "LengthOneof" }, null, null)}),
217-
new pbr::GeneratedClrTypeInfo(typeof(global::libsignalservice.push.GroupDetails), global::libsignalservice.push.GroupDetails.Parser, new[]{ "Id", "Name", "Members", "Avatar", "Active", "ExpireTimer" }, new[]{ "IdOneof", "NameOneof", "AvatarOneof", "ActiveOneof", "ExpireTimerOneof" }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::libsignalservice.push.GroupDetails.Types.Avatar), global::libsignalservice.push.GroupDetails.Types.Avatar.Parser, new[]{ "ContentType", "Length" }, new[]{ "ContentTypeOneof", "LengthOneof" }, null, null)})
218+
new pbr::GeneratedClrTypeInfo(typeof(global::libsignalservice.push.GroupDetails), global::libsignalservice.push.GroupDetails.Parser, new[]{ "Id", "Name", "Members", "Avatar", "Active", "ExpireTimer", "Color" }, new[]{ "IdOneof", "NameOneof", "AvatarOneof", "ActiveOneof", "ExpireTimerOneof", "ColorOneof" }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::libsignalservice.push.GroupDetails.Types.Avatar), global::libsignalservice.push.GroupDetails.Types.Avatar.Parser, new[]{ "ContentType", "Length" }, new[]{ "ContentTypeOneof", "LengthOneof" }, null, null)})
218219
}));
219220
}
220221
#endregion
@@ -10052,6 +10053,12 @@ public GroupDetails(GroupDetails other) : this() {
1005210053
break;
1005310054
}
1005410055

10056+
switch (other.ColorOneofCase) {
10057+
case ColorOneofOneofCase.Color:
10058+
Color = other.Color;
10059+
break;
10060+
}
10061+
1005510062
}
1005610063

1005710064
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -10124,6 +10131,17 @@ public uint ExpireTimer {
1012410131
}
1012510132
}
1012610133

10134+
/// <summary>Field number for the "color" field.</summary>
10135+
public const int ColorFieldNumber = 7;
10136+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
10137+
public string Color {
10138+
get { return colorOneofCase_ == ColorOneofOneofCase.Color ? (string) colorOneof_ : ""; }
10139+
set {
10140+
colorOneof_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
10141+
colorOneofCase_ = ColorOneofOneofCase.Color;
10142+
}
10143+
}
10144+
1012710145
private object idOneof_;
1012810146
/// <summary>Enum of possible cases for the "id_oneof" oneof.</summary>
1012910147
public enum IdOneofOneofCase {
@@ -10214,6 +10232,24 @@ public void ClearExpireTimerOneof() {
1021410232
expireTimerOneof_ = null;
1021510233
}
1021610234

10235+
private object colorOneof_;
10236+
/// <summary>Enum of possible cases for the "color_oneof" oneof.</summary>
10237+
public enum ColorOneofOneofCase {
10238+
None = 0,
10239+
Color = 7,
10240+
}
10241+
private ColorOneofOneofCase colorOneofCase_ = ColorOneofOneofCase.None;
10242+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
10243+
public ColorOneofOneofCase ColorOneofCase {
10244+
get { return colorOneofCase_; }
10245+
}
10246+
10247+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
10248+
public void ClearColorOneof() {
10249+
colorOneofCase_ = ColorOneofOneofCase.None;
10250+
colorOneof_ = null;
10251+
}
10252+
1021710253
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
1021810254
public override bool Equals(object other) {
1021910255
return Equals(other as GroupDetails);
@@ -10233,11 +10269,13 @@ public bool Equals(GroupDetails other) {
1023310269
if (!object.Equals(Avatar, other.Avatar)) return false;
1023410270
if (Active != other.Active) return false;
1023510271
if (ExpireTimer != other.ExpireTimer) return false;
10272+
if (Color != other.Color) return false;
1023610273
if (IdOneofCase != other.IdOneofCase) return false;
1023710274
if (NameOneofCase != other.NameOneofCase) return false;
1023810275
if (AvatarOneofCase != other.AvatarOneofCase) return false;
1023910276
if (ActiveOneofCase != other.ActiveOneofCase) return false;
1024010277
if (ExpireTimerOneofCase != other.ExpireTimerOneofCase) return false;
10278+
if (ColorOneofCase != other.ColorOneofCase) return false;
1024110279
return true;
1024210280
}
1024310281

@@ -10250,11 +10288,13 @@ public override int GetHashCode() {
1025010288
if (avatarOneofCase_ == AvatarOneofOneofCase.Avatar) hash ^= Avatar.GetHashCode();
1025110289
if (activeOneofCase_ == ActiveOneofOneofCase.Active) hash ^= Active.GetHashCode();
1025210290
if (expireTimerOneofCase_ == ExpireTimerOneofOneofCase.ExpireTimer) hash ^= ExpireTimer.GetHashCode();
10291+
if (colorOneofCase_ == ColorOneofOneofCase.Color) hash ^= Color.GetHashCode();
1025310292
hash ^= (int) idOneofCase_;
1025410293
hash ^= (int) nameOneofCase_;
1025510294
hash ^= (int) avatarOneofCase_;
1025610295
hash ^= (int) activeOneofCase_;
1025710296
hash ^= (int) expireTimerOneofCase_;
10297+
hash ^= (int) colorOneofCase_;
1025810298
return hash;
1025910299
}
1026010300

@@ -10286,6 +10326,10 @@ public void WriteTo(pb::CodedOutputStream output) {
1028610326
output.WriteRawTag(48);
1028710327
output.WriteUInt32(ExpireTimer);
1028810328
}
10329+
if (colorOneofCase_ == ColorOneofOneofCase.Color) {
10330+
output.WriteRawTag(58);
10331+
output.WriteString(Color);
10332+
}
1028910333
}
1029010334

1029110335
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -10307,6 +10351,9 @@ public int CalculateSize() {
1030710351
if (expireTimerOneofCase_ == ExpireTimerOneofOneofCase.ExpireTimer) {
1030810352
size += 1 + pb::CodedOutputStream.ComputeUInt32Size(ExpireTimer);
1030910353
}
10354+
if (colorOneofCase_ == ColorOneofOneofCase.Color) {
10355+
size += 1 + pb::CodedOutputStream.ComputeStringSize(Color);
10356+
}
1031010357
return size;
1031110358
}
1031210359

@@ -10346,6 +10393,12 @@ public void MergeFrom(GroupDetails other) {
1034610393
break;
1034710394
}
1034810395

10396+
switch (other.ColorOneofCase) {
10397+
case ColorOneofOneofCase.Color:
10398+
Color = other.Color;
10399+
break;
10400+
}
10401+
1034910402
}
1035010403

1035110404
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
@@ -10385,6 +10438,10 @@ public void MergeFrom(pb::CodedInputStream input) {
1038510438
ExpireTimer = input.ReadUInt32();
1038610439
break;
1038710440
}
10441+
case 58: {
10442+
Color = input.ReadString();
10443+
break;
10444+
}
1038810445
}
1038910446
}
1039010447
}

0 commit comments

Comments
 (0)