Debian Codegraph @

Xpjproject/pjsip-apps/src/pjsua/winrt/gui/uwp/Voip/Helpers/EndpointHelper.cs

raw symbols SCIP
1 /* $Id*/
2 /*
3 * Copyright (C) 2016 Teluu Inc. (http://www.teluu.com)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 }