forked from PeterWaher/IoTGateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAvatar.cs
More file actions
135 lines (124 loc) · 3.28 KB
/
Avatar.cs
File metadata and controls
135 lines (124 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using System;
using Waher.Persistence.Attributes;
using Waher.Security;
namespace Waher.Networking.XMPP.Avatar
{
/// <summary>
/// Contains information about an avatar.
/// </summary>
[CollectionName("Avatars")]
[Index("BareJid")]
public class Avatar
{
private string objectId = null;
private string bareJid = string.Empty;
private string hash = string.Empty;
private string contentType = string.Empty;
private byte[] binary = null;
private int width = 0;
private int height = 0;
/// <summary>
/// Contains information about an avatar.
/// </summary>
public Avatar()
{
}
/// <summary>
/// Contains information about an avatar.
/// </summary>
/// <param name="BareJid">Bare JID related to the avatar.</param>
/// <param name="ContentType">Content-Type of the avatar image.</param>
/// <param name="Binary">Binary encoding of the image.</param>
/// <param name="Width">Width of avatar, in pixels.</param>
/// <param name="Height">Height of avatar, in pixels.</param>
public Avatar(string BareJid, string ContentType, byte[] Binary, int Width, int Height)
{
this.bareJid = BareJid;
this.contentType = ContentType;
this.binary = Binary;
this.hash = Hashes.ComputeSHA1HashString(Binary);
this.width = Width;
this.height = Height;
}
/// <summary>
/// Contains information about an avatar.
/// </summary>
/// <param name="BareJid">Bare JID related to the avatar.</param>
/// <param name="ContentType">Content-Type of the avatar image.</param>
/// <param name="Hash">Hash of the avatar image.</param>
/// <param name="Binary">Binary encoding of the image.</param>
/// <param name="Width">Width of avatar, in pixels.</param>
/// <param name="Height">Height of avatar, in pixels.</param>
public Avatar(string BareJid, string ContentType, string Hash, byte[] Binary, int Width, int Height)
{
this.bareJid = BareJid;
this.contentType = ContentType;
this.binary = Binary;
this.hash = Hash;
this.width = Width;
this.height = Height;
}
/// <summary>
/// Object ID of avatar.
/// </summary>
[ObjectId]
public string ObjectId
{
get { return this.objectId; }
set { this.objectId = value; }
}
/// <summary>
/// Bare JID of avatar.
/// </summary>
public string BareJid
{
get { return this.bareJid; }
set { this.bareJid = value; }
}
/// <summary>
/// Hash digest of avatar.
/// </summary>
[DefaultValueStringEmpty]
public string Hash
{
get { return this.hash; }
set { this.hash = value; }
}
/// <summary>
/// Content-Type of binary encoding of avatar.
/// </summary>
[DefaultValueStringEmpty]
public string ContentType
{
get { return this.contentType; }
set { this.contentType = value; }
}
/// <summary>
/// Binary encoding of avatar.
/// </summary>
[DefaultValueNull]
public byte[] Binary
{
get { return this.binary; }
set { this.binary = value; }
}
/// <summary>
/// Width of avatar, in pixels. 0 = No width provided.
/// </summary>
[DefaultValue(0)]
public int Width
{
get { return this.width; }
set { this.width = value; }
}
/// <summary>
/// Height of avatar, in pixels. 0 = No height provided.
/// </summary>
[DefaultValue(0)]
public int Height
{
get { return this.height; }
set { this.height = value; }
}
}
}