michael@0: /* michael@0: Licensed under the Apache License, Version 2.0 (the "License"); michael@0: you may not use this file except in compliance with the License. michael@0: You may obtain a copy of the License at michael@0: michael@0: http://www.apache.org/licenses/LICENSE-2.0 michael@0: michael@0: Unless required by applicable law or agreed to in writing, software michael@0: distributed under the License is distributed on an "AS IS" BASIS, michael@0: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: See the License for the specific language governing permissions and michael@0: limitations under the License. michael@0: */ michael@0: michael@0: using System; michael@0: using System.Net; michael@0: using System.Windows; michael@0: using System.Windows.Controls; michael@0: using System.Windows.Documents; michael@0: using System.Windows.Ink; michael@0: using System.Windows.Input; michael@0: using System.Windows.Media; michael@0: using System.Windows.Media.Animation; michael@0: using System.Windows.Shapes; michael@0: using Microsoft.Phone.Info; michael@0: using System.IO.IsolatedStorage; michael@0: using System.Windows.Resources; michael@0: using System.IO; michael@0: using System.Diagnostics; michael@0: michael@0: namespace WPCordovaClassLib.Cordova.Commands michael@0: { michael@0: public class Device : BaseCommand michael@0: { michael@0: public void getDeviceInfo(string notused) michael@0: { michael@0: michael@0: string res = String.Format("\"name\":\"{0}\",\"platform\":\"{1}\",\"uuid\":\"{2}\",\"version\":\"{3}\",\"model\":\"{4}\"", michael@0: this.name, michael@0: this.platform, michael@0: this.uuid, michael@0: this.version, michael@0: this.model); michael@0: michael@0: res = "{" + res + "}"; michael@0: //Debug.WriteLine("Result::" + res); michael@0: DispatchCommandResult(new PluginResult(PluginResult.Status.OK, res)); michael@0: } michael@0: michael@0: public string model michael@0: { michael@0: get michael@0: { michael@0: return DeviceStatus.DeviceName; michael@0: //return String.Format("{0},{1},{2}", DeviceStatus.DeviceManufacturer, DeviceStatus.DeviceHardwareVersion, DeviceStatus.DeviceFirmwareVersion); michael@0: } michael@0: } michael@0: michael@0: public string name michael@0: { michael@0: get michael@0: { michael@0: return DeviceStatus.DeviceName; michael@0: michael@0: } michael@0: } michael@0: michael@0: public string platform michael@0: { michael@0: get michael@0: { michael@0: return Environment.OSVersion.Platform.ToString(); michael@0: } michael@0: } michael@0: michael@0: public string uuid michael@0: { michael@0: get michael@0: { michael@0: string returnVal = ""; michael@0: object id; michael@0: UserExtendedProperties.TryGetValue("ANID", out id); michael@0: michael@0: if (id != null) michael@0: { michael@0: returnVal = id.ToString().Substring(2, 32); michael@0: } michael@0: else michael@0: { michael@0: returnVal = "???unknown???"; michael@0: michael@0: using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication()) michael@0: { michael@0: try michael@0: { michael@0: IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream("DeviceID.txt", FileMode.Open, FileAccess.Read, appStorage); michael@0: michael@0: using (StreamReader reader = new StreamReader(fileStream)) michael@0: { michael@0: returnVal = reader.ReadLine(); michael@0: } michael@0: } michael@0: catch (Exception /*ex*/) michael@0: { michael@0: michael@0: } michael@0: } michael@0: } michael@0: michael@0: return returnVal; michael@0: } michael@0: } michael@0: michael@0: public string version michael@0: { michael@0: get michael@0: { michael@0: return Environment.OSVersion.Version.ToString(); michael@0: } michael@0: } michael@0: michael@0: } michael@0: }