Touchgui/plugins/org.apache.cordova.device/src/wp/Device.cs

changeset 0
e8ccd40d0ef6
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Touchgui/plugins/org.apache.cordova.device/src/wp/Device.cs	Thu Jun 04 14:50:33 2015 +0200
     1.3 @@ -0,0 +1,123 @@
     1.4 +/*  
     1.5 +	Licensed under the Apache License, Version 2.0 (the "License");
     1.6 +	you may not use this file except in compliance with the License.
     1.7 +	You may obtain a copy of the License at
     1.8 +	
     1.9 +	http://www.apache.org/licenses/LICENSE-2.0
    1.10 +	
    1.11 +	Unless required by applicable law or agreed to in writing, software
    1.12 +	distributed under the License is distributed on an "AS IS" BASIS,
    1.13 +	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.14 +	See the License for the specific language governing permissions and
    1.15 +	limitations under the License.
    1.16 +*/
    1.17 +
    1.18 +using System;
    1.19 +using System.Net;
    1.20 +using System.Windows;
    1.21 +using System.Windows.Controls;
    1.22 +using System.Windows.Documents;
    1.23 +using System.Windows.Ink;
    1.24 +using System.Windows.Input;
    1.25 +using System.Windows.Media;
    1.26 +using System.Windows.Media.Animation;
    1.27 +using System.Windows.Shapes;
    1.28 +using Microsoft.Phone.Info;
    1.29 +using System.IO.IsolatedStorage;
    1.30 +using System.Windows.Resources;
    1.31 +using System.IO;
    1.32 +using System.Diagnostics;
    1.33 +
    1.34 +namespace WPCordovaClassLib.Cordova.Commands
    1.35 +{
    1.36 +    public class Device : BaseCommand
    1.37 +    {
    1.38 +        public void getDeviceInfo(string notused)
    1.39 +        {
    1.40 +
    1.41 +            string res = String.Format("\"name\":\"{0}\",\"platform\":\"{1}\",\"uuid\":\"{2}\",\"version\":\"{3}\",\"model\":\"{4}\"",
    1.42 +                                        this.name,
    1.43 +                                        this.platform,
    1.44 +                                        this.uuid,
    1.45 +                                        this.version,
    1.46 +                                        this.model);
    1.47 +
    1.48 +            res = "{" + res + "}";
    1.49 +            //Debug.WriteLine("Result::" + res);
    1.50 +            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res));
    1.51 +        }
    1.52 +
    1.53 +        public string model
    1.54 +        {
    1.55 +            get
    1.56 +            {
    1.57 +                return DeviceStatus.DeviceName;
    1.58 +                //return String.Format("{0},{1},{2}", DeviceStatus.DeviceManufacturer, DeviceStatus.DeviceHardwareVersion, DeviceStatus.DeviceFirmwareVersion); 
    1.59 +            }
    1.60 +        }
    1.61 +
    1.62 +        public string name
    1.63 +        {
    1.64 +            get
    1.65 +            {
    1.66 +                return DeviceStatus.DeviceName;
    1.67 +                
    1.68 +            }
    1.69 +        }
    1.70 +
    1.71 +        public string platform
    1.72 +        {
    1.73 +            get
    1.74 +            {
    1.75 +                return Environment.OSVersion.Platform.ToString();
    1.76 +            }
    1.77 +        }
    1.78 +
    1.79 +        public string uuid
    1.80 +        {
    1.81 +            get
    1.82 +            {
    1.83 +                string returnVal = "";
    1.84 +                object id;
    1.85 +                UserExtendedProperties.TryGetValue("ANID", out id);
    1.86 +
    1.87 +                if (id != null)
    1.88 +                {
    1.89 +                    returnVal = id.ToString().Substring(2, 32);
    1.90 +                }
    1.91 +                else
    1.92 +                {
    1.93 +                    returnVal = "???unknown???";
    1.94 +
    1.95 +                    using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
    1.96 +                    {
    1.97 +                        try
    1.98 +                        {
    1.99 +                            IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream("DeviceID.txt", FileMode.Open, FileAccess.Read, appStorage);
   1.100 +
   1.101 +                            using (StreamReader reader = new StreamReader(fileStream))
   1.102 +                            {
   1.103 +                                returnVal = reader.ReadLine();
   1.104 +                            }
   1.105 +                        }
   1.106 +                        catch (Exception /*ex*/)
   1.107 +                        {
   1.108 +
   1.109 +                        }
   1.110 +                    }
   1.111 +                }
   1.112 +
   1.113 +                return returnVal;
   1.114 +            }
   1.115 +        }
   1.116 +
   1.117 +        public string version
   1.118 +        {
   1.119 +            get
   1.120 +            {
   1.121 +                return Environment.OSVersion.Version.ToString();
   1.122 +            }
   1.123 +        }
   1.124 +
   1.125 +    }
   1.126 +}

mercurial