summaryrefslogtreecommitdiff
path: root/StoneIsland/plugins/cordova-plugin-sim/src/wp/Sim.cs
blob: d6e5c9dbc52559c7aed49495aaf4fc6726797bf2 (plain)
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
// DeviceNetworkInformation
// https://msdn.microsoft.com/en-us/library/windows/apps/microsoft.phone.net.networkinformation.devicenetworkinformation(v=vs.105).aspx
//
// TODO http://stackoverflow.com/a/21879531

using System;
using Microsoft.Phone.Net.NetworkInformation;

namespace WPCordovaClassLib.Cordova.Commands
{
    public class Sim : BaseCommand
    {
        public void getSimInfo(string notused)
        {

            string res = String.Format("\"carrierName\":\"{0}\",\"countryCode\":\"\",\"mcc\":\"\",\"mnc\":\"\",\"isCellularDataEnabled\":\"{1}\",\"isCellularDataRoamingEnabled\":\"{2}\",\"isNetworkAvailable\":\"{3}\",\"isWiFiEnabled\":\"{4}\"",
                                        this.CellularMobileOperator,
                                        this.IsCellularDataEnabled,
                                        this.IsCellularDataRoamingEnabled,
                                        this.IsNetworkAvailable,
                                        this.IsWiFiEnabled);

            res = "{" + res + "}";

            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res));
        }

        // Gets the name of the cellular mobile operator.
        public string CellularMobileOperator
        {
            get
            {
                return DeviceNetworkInformation.CellularMobileOperator;
            }
        }

        // Gets a value indicating whether the network is cellular data enabled.
        public bool IsCellularDataEnabled
        {
            get
            {
                return DeviceNetworkInformation.IsCellularDataEnabled;
            }
        }

        // Gets a value indicating whether the network allows data roaming.
        public bool IsCellularDataRoamingEnabled
        {
            get
            {
                return DeviceNetworkInformation.IsCellularDataRoamingEnabled;
            }
        }

        // Gets a value indicating whether the network is available.
        public bool IsNetworkAvailable
        {
            get
            {
                return DeviceNetworkInformation.IsNetworkAvailable;
            }
        }

        // Gets a value indicating whether the network is Wi-Fi enabled.
        public bool IsWiFiEnabled
        {
            get
            {
                return DeviceNetworkInformation.IsWiFiEnabled;
            }
        }

    }
}