@@ -52,7 +52,6 @@ public SignalServiceAccountManager(SignalServiceConfiguration configuration,
52
52
/// Construct a SignalServiceAccountManager for linking as a slave device
53
53
/// </summary>
54
54
/// <param name="configuration">The URL configuration for the Signal Service</param>
55
- /// <param name="token">The cancellation token for the ProvisioningSocket</param>
56
55
/// <param name="userAgent">A string which identifies the client software</param>
57
56
public SignalServiceAccountManager ( SignalServiceConfiguration configuration , string userAgent )
58
57
{
@@ -66,28 +65,32 @@ public SignalServiceAccountManager(SignalServiceConfiguration configuration, str
66
65
///
67
66
/// </summary>
68
67
/// <param name="pin"></param>
69
- public void SetPin ( string pin )
68
+ public async Task SetPin ( string pin )
70
69
{
71
70
if ( pin != null )
72
- PushServiceSocket . SetPin ( pin ) ;
71
+ {
72
+ await PushServiceSocket . SetPin ( pin ) ;
73
+ }
73
74
else
74
- PushServiceSocket . RemovePin ( ) ;
75
+ {
76
+ await PushServiceSocket . RemovePin ( ) ;
77
+ }
75
78
}
76
79
77
80
/// <summary>
78
81
/// Register/Unregister a Google Cloud Messaging registration ID.
79
82
/// </summary>
80
83
/// <param name="gcmRegistrationId">The GCM id to register. A call with an absent value will unregister.</param>
81
84
/// <returns></returns>
82
- public void SetGcmId ( May < string > gcmRegistrationId ) // throws IOException
85
+ public async Task SetGcmId ( May < string > gcmRegistrationId ) // throws IOException
83
86
{
84
87
if ( gcmRegistrationId . HasValue )
85
88
{
86
- this . PushServiceSocket . RegisterGcmId ( gcmRegistrationId . ForceGetValue ( ) ) ;
89
+ await PushServiceSocket . RegisterGcmId ( gcmRegistrationId . ForceGetValue ( ) ) ;
87
90
}
88
91
else
89
92
{
90
- this . PushServiceSocket . UnregisterGcmId ( ) ;
93
+ await PushServiceSocket . UnregisterGcmId ( ) ;
91
94
}
92
95
}
93
96
@@ -96,19 +99,19 @@ public void SetGcmId(May<string> gcmRegistrationId)// throws IOException
96
99
/// an SMS verification code to this Signal user.
97
100
/// </summary>
98
101
/// <returns></returns>
99
- public void RequestSmsVerificationCode ( ) // throws IOException
102
+ public async Task RequestSmsVerificationCode ( ) // throws IOException
100
103
{
101
- this . PushServiceSocket . CreateAccount ( false ) ;
104
+ await PushServiceSocket . CreateAccount ( false ) ;
102
105
}
103
106
104
107
/// <summary>
105
108
/// Request a Voice verification code. On success, the server will
106
109
/// make a voice call to this Signal user.
107
110
/// </summary>
108
111
/// <returns></returns>
109
- public void RequestVoiceVerificationCode ( ) // throws IOException
112
+ public async Task RequestVoiceVerificationCode ( ) // throws IOException
110
113
{
111
- this . PushServiceSocket . CreateAccount ( true ) ;
114
+ await PushServiceSocket . CreateAccount ( true ) ;
112
115
}
113
116
114
117
/// <summary>
@@ -124,10 +127,10 @@ public void RequestVoiceVerificationCode()// throws IOException
124
127
/// <param name="fetchesMessages">True if the client does not support GCM</param>
125
128
/// <param name="pin"></param>
126
129
/// <returns></returns>
127
- public void VerifyAccountWithCode ( string verificationCode , string signalingKey ,
130
+ public async Task VerifyAccountWithCode ( string verificationCode , string signalingKey ,
128
131
uint signalProtocolRegistrationId , bool fetchesMessages , string pin )
129
132
{
130
- this . PushServiceSocket . VerifyAccountCode ( verificationCode , signalingKey ,
133
+ await PushServiceSocket . VerifyAccountCode ( verificationCode , signalingKey ,
131
134
signalProtocolRegistrationId , fetchesMessages , pin ) ;
132
135
}
133
136
@@ -142,9 +145,9 @@ public void VerifyAccountWithCode(string verificationCode, string signalingKey,
142
145
/// <param name="fetchesMessages">True if the client does not support GCM</param>
143
146
/// <param name="pin"></param>
144
147
/// <returns></returns>
145
- public void SetAccountAttributes ( string signalingKey , uint signalProtocolRegistrationId , bool fetchesMessages , string pin )
148
+ public async Task SetAccountAttributes ( string signalingKey , uint signalProtocolRegistrationId , bool fetchesMessages , string pin )
146
149
{
147
- this . PushServiceSocket . SetAccountAttributes ( signalingKey , signalProtocolRegistrationId , fetchesMessages , pin ) ;
150
+ await PushServiceSocket . SetAccountAttributes ( signalingKey , signalProtocolRegistrationId , fetchesMessages , pin ) ;
148
151
}
149
152
150
153
/// <summary>
@@ -155,48 +158,48 @@ public void SetAccountAttributes(string signalingKey, uint signalProtocolRegistr
155
158
/// <param name="signedPreKey">The client's signed prekey.</param>
156
159
/// <param name="oneTimePreKeys">The client's list of one-time prekeys.</param>
157
160
/// <returns></returns>
158
- public bool SetPreKeys ( IdentityKey identityKey , SignedPreKeyRecord signedPreKey , IList < PreKeyRecord > oneTimePreKeys ) //throws IOException
161
+ public async Task < bool > SetPreKeys ( IdentityKey identityKey , SignedPreKeyRecord signedPreKey , IList < PreKeyRecord > oneTimePreKeys ) //throws IOException
159
162
{
160
- this . PushServiceSocket . RegisterPreKeys ( identityKey , signedPreKey , oneTimePreKeys ) ;
163
+ await PushServiceSocket . RegisterPreKeys ( identityKey , signedPreKey , oneTimePreKeys ) ;
161
164
return true ;
162
165
}
163
166
164
167
/// <summary>
165
168
///
166
169
/// </summary>
167
170
/// <returns>The server's count of currently available (eg. unused) prekeys for this user.</returns>
168
- public int GetPreKeysCount ( ) // throws IOException
171
+ public async Task < int > GetPreKeysCount ( ) // throws IOException
169
172
{
170
- return this . PushServiceSocket . GetAvailablePreKeys ( ) ;
173
+ return await PushServiceSocket . GetAvailablePreKeys ( ) ;
171
174
}
172
175
173
176
/// <summary>
174
177
/// Set the client's signed prekey.
175
178
/// </summary>
176
179
/// <param name="signedPreKey">The client's new signed prekey.</param>
177
- public void SetSignedPreKey ( SignedPreKeyRecord signedPreKey ) // throws IOException
180
+ public async Task SetSignedPreKey ( SignedPreKeyRecord signedPreKey ) // throws IOException
178
181
{
179
- this . PushServiceSocket . SetCurrentSignedPreKey ( signedPreKey ) ;
182
+ await PushServiceSocket . SetCurrentSignedPreKey ( signedPreKey ) ;
180
183
}
181
184
182
185
/// <summary>
183
186
///
184
187
/// </summary>
185
188
/// <returns>The server's view of the client's current signed prekey.</returns>
186
- public SignedPreKeyEntity GetSignedPreKey ( ) // throws IOException
189
+ public async Task < SignedPreKeyEntity > GetSignedPreKey ( ) // throws IOException
187
190
{
188
- return this . PushServiceSocket . GetCurrentSignedPreKey ( ) ;
191
+ return await PushServiceSocket . GetCurrentSignedPreKey ( ) ;
189
192
}
190
193
191
194
/// <summary>
192
195
/// Checks whether a contact is currently registered with the server
193
196
/// </summary>
194
197
/// <param name="e164number">The contact to check.</param>
195
198
/// <returns>An optional ContactTokenDetails, present if registered, absent if not.</returns>
196
- public May < ContactTokenDetails > GetContact ( string e164number ) // throws IOException
199
+ public async Task < May < ContactTokenDetails > > GetContact ( string e164number ) // throws IOException
197
200
{
198
201
string contactToken = CreateDirectoryServerToken ( e164number , true ) ;
199
- ContactTokenDetails contactTokenDetails = this . PushServiceSocket . GetContactTokenDetails ( contactToken ) ;
202
+ ContactTokenDetails contactTokenDetails = await PushServiceSocket . GetContactTokenDetails ( contactToken ) ;
200
203
201
204
if ( contactTokenDetails != null )
202
205
{
@@ -211,10 +214,10 @@ public May<ContactTokenDetails> GetContact(string e164number)// throws IOExcepti
211
214
/// </summary>
212
215
/// <param name="e164numbers">The contacts to check.</param>
213
216
/// <returns>A list of ContactTokenDetails for the registered users.</returns>
214
- public List < ContactTokenDetails > GetContacts ( IList < string > e164numbers )
217
+ public async Task < List < ContactTokenDetails > > GetContacts ( IList < string > e164numbers )
215
218
{
216
219
IDictionary < string , string > contactTokensMap = CreateDirectoryServerTokenMap ( e164numbers ) ;
217
- List < ContactTokenDetails > activeTokens = this . PushServiceSocket . RetrieveDirectory ( contactTokensMap . Keys ) ;
220
+ List < ContactTokenDetails > activeTokens = await PushServiceSocket . RetrieveDirectory ( contactTokensMap . Keys ) ;
218
221
219
222
foreach ( ContactTokenDetails activeToken in activeTokens )
220
223
{
@@ -242,9 +245,9 @@ public async Task<string> GetNewDeviceUuid(CancellationToken token)
242
245
/// Called by an already verified device.
243
246
/// </summary>
244
247
/// <returns>A verification code (String of 6 digits)</returns>
245
- public string GetNewDeviceVerificationCode ( ) // throws IOException
248
+ public async Task < string > GetNewDeviceVerificationCode ( ) // throws IOException
246
249
{
247
- return this . PushServiceSocket . GetNewDeviceVerificationCode ( ) ;
250
+ return await PushServiceSocket . GetNewDeviceVerificationCode ( ) ;
248
251
}
249
252
250
253
/// <summary>
@@ -302,7 +305,7 @@ public async Task<int> FinishNewDeviceRegistration(CancellationToken token, Sign
302
305
/// <param name="identityKeyPair"></param>
303
306
/// <param name="profileKey"></param>
304
307
/// <param name="code"></param>
305
- public void AddDevice ( string deviceIdentifier ,
308
+ public async Task AddDevice ( string deviceIdentifier ,
306
309
ECPublicKey deviceKey ,
307
310
IdentityKeyPair identityKeyPair ,
308
311
byte [ ] profileKey ,
@@ -323,25 +326,25 @@ public void AddDevice(string deviceIdentifier,
323
326
}
324
327
325
328
byte [ ] ciphertext = cipher . encrypt ( message ) ;
326
- this . PushServiceSocket . SendProvisioningMessage ( deviceIdentifier , ciphertext ) ;
329
+ await PushServiceSocket . SendProvisioningMessage ( deviceIdentifier , ciphertext ) ;
327
330
}
328
331
329
332
/// <summary>
330
333
/// TODO
331
334
/// </summary>
332
335
/// <returns></returns>
333
- public List < DeviceInfo > GetDevices ( )
336
+ public async Task < List < DeviceInfo > > GetDevices ( )
334
337
{
335
- return this . PushServiceSocket . GetDevices ( ) ;
338
+ return await PushServiceSocket . GetDevices ( ) ;
336
339
}
337
340
338
341
/// <summary>
339
342
/// TODO
340
343
/// </summary>
341
344
/// <param name="deviceId"></param>
342
- public void RemoveDevice ( long deviceId )
345
+ public async Task RemoveDevice ( long deviceId )
343
346
{
344
- this . PushServiceSocket . RemoveDevice ( deviceId ) ;
347
+ await PushServiceSocket . RemoveDevice ( deviceId ) ;
345
348
}
346
349
347
350
/// <summary>
@@ -358,26 +361,26 @@ public async Task<TurnServerInfo> GetTurnServerInfo(CancellationToken token)
358
361
/// </summary>
359
362
/// <param name="key"></param>
360
363
/// <param name="name"></param>
361
- public void SetProfileName ( byte [ ] key , string name )
364
+ public async Task SetProfileName ( byte [ ] key , string name )
362
365
{
363
366
if ( name == null ) name = "" ;
364
367
string ciphertextName = Base64 . EncodeBytesWithoutPadding ( new ProfileCipher ( key ) . EncryptName ( Encoding . Unicode . GetBytes ( name ) , ProfileCipher . NAME_PADDED_LENGTH ) ) ;
365
- PushServiceSocket . SetProfileName ( ciphertextName ) ;
368
+ await PushServiceSocket . SetProfileName ( ciphertextName ) ;
366
369
}
367
370
368
371
/// <summary>
369
372
/// TODO
370
373
/// </summary>
371
374
/// <param name="key"></param>
372
375
/// <param name="avatar"></param>
373
- public void SetProfileAvatar ( byte [ ] key , StreamDetails avatar )
376
+ public async Task SetProfileAvatar ( byte [ ] key , StreamDetails avatar )
374
377
{
375
378
ProfileAvatarData profileAvatarData = null ;
376
379
if ( avatar != null )
377
380
{
378
381
profileAvatarData = new ProfileAvatarData ( avatar . InputStream , avatar . Length , avatar . ContentType , new ProfileCipherOutputStreamFactory ( key ) ) ;
379
382
}
380
- PushServiceSocket . SetProfileAvatar ( profileAvatarData ) ;
383
+ await PushServiceSocket . SetProfileAvatar ( profileAvatarData ) ;
381
384
}
382
385
383
386
/// <summary>
0 commit comments