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

changeset 0
e8ccd40d0ef6
equal deleted inserted replaced
-1:000000000000 0:7f9c979661f1
1 /*
2 Licensed under the Apache License, Version 2.0 (the "License");
3 you may not use this file except in compliance with the License.
4 You may obtain a copy of the License at
5
6 http://www.apache.org/licenses/LICENSE-2.0
7
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS,
10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 See the License for the specific language governing permissions and
12 limitations under the License.
13 */
14
15 using System;
16 using System.Net;
17 using System.Windows;
18 using System.Windows.Controls;
19 using System.Windows.Documents;
20 using System.Windows.Ink;
21 using System.Windows.Input;
22 using System.Windows.Media;
23 using System.Windows.Media.Animation;
24 using System.Windows.Shapes;
25 using Microsoft.Phone.Info;
26 using System.IO.IsolatedStorage;
27 using System.Windows.Resources;
28 using System.IO;
29 using System.Diagnostics;
30
31 namespace WPCordovaClassLib.Cordova.Commands
32 {
33 public class Device : BaseCommand
34 {
35 public void getDeviceInfo(string notused)
36 {
37
38 string res = String.Format("\"name\":\"{0}\",\"platform\":\"{1}\",\"uuid\":\"{2}\",\"version\":\"{3}\",\"model\":\"{4}\"",
39 this.name,
40 this.platform,
41 this.uuid,
42 this.version,
43 this.model);
44
45 res = "{" + res + "}";
46 //Debug.WriteLine("Result::" + res);
47 DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res));
48 }
49
50 public string model
51 {
52 get
53 {
54 return DeviceStatus.DeviceName;
55 //return String.Format("{0},{1},{2}", DeviceStatus.DeviceManufacturer, DeviceStatus.DeviceHardwareVersion, DeviceStatus.DeviceFirmwareVersion);
56 }
57 }
58
59 public string name
60 {
61 get
62 {
63 return DeviceStatus.DeviceName;
64
65 }
66 }
67
68 public string platform
69 {
70 get
71 {
72 return Environment.OSVersion.Platform.ToString();
73 }
74 }
75
76 public string uuid
77 {
78 get
79 {
80 string returnVal = "";
81 object id;
82 UserExtendedProperties.TryGetValue("ANID", out id);
83
84 if (id != null)
85 {
86 returnVal = id.ToString().Substring(2, 32);
87 }
88 else
89 {
90 returnVal = "???unknown???";
91
92 using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
93 {
94 try
95 {
96 IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream("DeviceID.txt", FileMode.Open, FileAccess.Read, appStorage);
97
98 using (StreamReader reader = new StreamReader(fileStream))
99 {
100 returnVal = reader.ReadLine();
101 }
102 }
103 catch (Exception /*ex*/)
104 {
105
106 }
107 }
108 }
109
110 return returnVal;
111 }
112 }
113
114 public string version
115 {
116 get
117 {
118 return Environment.OSVersion.Version.ToString();
119 }
120 }
121
122 }
123 }

mercurial