| 1 |
*/ |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
using System; |
| 21 |
using System.Threading.Tasks; |
| 22 |
using VoipTasks.BackgroundOperations; |
| 23 |
using Windows.Foundation.Collections; |
| 24 |
using Windows.Foundation.Metadata; |
| 25 |
using VoipBackEnd; |
| 26 |
|
| 27 |
namespace VoipUI.Helpers |
| 28 |
{ |
| 29 |
static class EndpointHelper |
| 30 |
{ |
| 31 |
public static async Task<OperationResult> StartServiceAsync() |
| 32 |
{ |
| 33 |
if (!ApiInformation.IsApiContractPresent("Windows.ApplicationModel.Calls.CallsVoipContract", 1)) |
| 34 |
{ |
| 35 |
return OperationResult.Failed; |
| 36 |
} |
| 37 |
|
| 38 |
AppServiceHelper appServiceHelper = new AppServiceHelper(); |
| 39 |
|
| 40 |
ValueSet message = new ValueSet(); |
| 41 |
message[BackgroundOperation.NewBackgroundRequest] = (int)BackgroundRequest.StartService; |
| 42 |
|
| 43 |
ValueSet response = await appServiceHelper.SendMessageAsync(message); |
| 44 |
|
| 45 |
if (response != null) |
| 46 |
{ |
| 47 |
return ((OperationResult)(response[BackgroundOperation.Result])); |
| 48 |
} |
| 49 |
return OperationResult.Failed; |
| 50 |
} |
| 51 |
|
| 52 |
public static async Task<OperationResult> GetAccountInfo() |
| 53 |
{ |
| 54 |
if (!ApiInformation.IsApiContractPresent("Windows.ApplicationModel.Calls.CallsVoipContract", 1)) |
| 55 |
{ |
| 56 |
return OperationResult.Failed; |
| 57 |
} |
| 58 |
|
| 59 |
AppServiceHelper appServiceHelper = new AppServiceHelper(); |
| 60 |
|
| 61 |
ValueSet message = new ValueSet(); |
| 62 |
message[BackgroundOperation.NewBackgroundRequest] = (int)BackgroundRequest.GetAccountInfo; |
| 63 |
|
| 64 |
ValueSet response = await appServiceHelper.SendMessageAsync(message); |
| 65 |
|
| 66 |
if (response != null) |
| 67 |
{ |
| 68 |
return ((OperationResult)(response[BackgroundOperation.Result])); |
| 69 |
} |
| 70 |
return OperationResult.Failed; |
| 71 |
} |
| 72 |
|
| 73 |
public static async Task<OperationResult> ModifyAccount(String id, String registrar, String proxy, String username, String password) |
| 74 |
{ |
| 75 |
if (!ApiInformation.IsApiContractPresent("Windows.ApplicationModel.Calls.CallsVoipContract", 1)) |
| 76 |
{ |
| 77 |
return OperationResult.Failed; |
| 78 |
} |
| 79 |
|
| 80 |
AppServiceHelper appServiceHelper = new AppServiceHelper(); |
| 81 |
|
| 82 |
ValueSet message = new ValueSet(); |
| 83 |
message[ModifyAccountArguments.id.ToString()] = id; |
| 84 |
message[ModifyAccountArguments.registrar.ToString()] = registrar; |
| 85 |
message[ModifyAccountArguments.proxy.ToString()] = proxy; |
| 86 |
message[ModifyAccountArguments.username.ToString()] = username; |
| 87 |
message[ModifyAccountArguments.password.ToString()] = password; |
| 88 |
message[BackgroundOperation.NewBackgroundRequest] = (int)BackgroundRequest.ModifyAccount; |
| 89 |
|
| 90 |
ValueSet response = await appServiceHelper.SendMessageAsync(message); |
| 91 |
|
| 92 |
if (response != null) |
| 93 |
{ |
| 94 |
return ((OperationResult)(response[BackgroundOperation.Result])); |
| 95 |
} |
| 96 |
return OperationResult.Failed; |
| 97 |
} |
| 98 |
} |
| 99 |
} |