Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
15747 anikendra 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}\",\"manufacturer\":\"{5}\"",
39
                                        this.name,
40
                                        this.platform,
41
                                        this.uuid,
42
                                        this.version,
43
                                        this.model,
44
                                        this.manufacturer);
45
 
46
            res = "{" + res + "}";
47
            //Debug.WriteLine("Result::" + res);
48
            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res));
49
        }
50
 
51
        public string model
52
        {
53
            get
54
            {
55
                return DeviceStatus.DeviceName;
56
                //return String.Format("{0},{1},{2}", DeviceStatus.DeviceManufacturer, DeviceStatus.DeviceHardwareVersion, DeviceStatus.DeviceFirmwareVersion); 
57
            }
58
        }
59
 
60
        public string manufacturer
61
        {
62
            get
63
            {
64
                return DeviceStatus.DeviceManufacturer;
65
            }
66
        }
67
 
68
        public string name
69
        {
70
            get
71
            {
72
                return DeviceStatus.DeviceName;
73
 
74
            }
75
        }
76
 
77
        public string platform
78
        {
79
            get
80
            {
81
                return Environment.OSVersion.Platform.ToString();
82
            }
83
        }
84
 
85
        public string uuid
86
        {
87
            get
88
            {
89
                object id;
90
 
91
                UserExtendedProperties.TryGetValue("ANID", out id);
92
                if (id != null)
93
                {
94
                    return id.ToString().Substring(2, 32);
95
                }
96
 
97
                UserExtendedProperties.TryGetValue("ANID2", out id);
98
                if (id != null)
99
                {
100
                    return id.ToString();
101
                }
102
 
103
                string returnVal = "???unknown???";
104
 
105
                using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication())
106
                {
107
                    try
108
                    {
109
                        IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream("DeviceID.txt", FileMode.Open, FileAccess.Read, appStorage);
110
 
111
                        using (StreamReader reader = new StreamReader(fileStream))
112
                        {
113
                            returnVal = reader.ReadLine();
114
                        }
115
                    }
116
                    catch (Exception /*ex*/)
117
                    {
118
 
119
                    }
120
                }
121
 
122
                return returnVal;
123
            }
124
        }
125
 
126
        public string version
127
        {
128
            get
129
            {
130
                return Environment.OSVersion.Version.ToString();
131
            }
132
        }
133
 
134
    }
135
}