transit-widget-tools /runtime/chrome/modules/api/jil/1.1r4/Device.jsm

Language Unknown Lines 196
MD5 Hash ea07940f2edad4bd580374d3cfa6c567
Repository http://transit-widget-tools.googlecode.com/svn/trunk/ View Raw File
  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
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
var EXPORTED_SYMBOLS = ["Device"];

var _Device_122 = Components.classes["@jil.org/jilapi-device;1"].getService(Components.interfaces.jilDevice);

Components.utils.import("resource://transit-runtime/api/jil/SecurityManager.jsm");

Components.utils.import("resource://transit-runtime/api/jil/1.1r4/AccountInfo.jsm");
Components.utils.import("resource://transit-runtime/api/jil/1.1r4/DataNetworkInfo.jsm");
Components.utils.import("resource://transit-runtime/api/jil/1.1r4/DeviceInfo.jsm");
Components.utils.import("resource://transit-runtime/api/jil/1.1r4/DeviceStateInfo.jsm");
Components.utils.import("resource://transit-runtime/api/jil/1.1r4/File.jsm");
Components.utils.import("resource://transit-runtime/api/jil/1.1r4/PositionInfo.jsm");
Components.utils.import("resource://transit-runtime/api/jil/1.1r4/PowerInfo.jsm");
Components.utils.import("resource://transit-runtime/api/jil/1.1r4/RadioInfo.jsm");
Components.utils.import("resource://transit-runtime/api/jil/1.1r4/AddressBookItem.jsm");

function Device()
{
  this.DeviceInfo = new DeviceInfo();
  this.AccountInfo = new AccountInfo();
  this.DataNetworkInfo = new DataNetworkInfo();
  this.DeviceStateInfo = new DeviceStateInfo();
  this.PowerInfo = new PowerInfo();
  this.RadioInfo = new RadioInfo();
  
  this.clipboardString = _Device_122.clipboardString;
  this.widgetEngineName = _Device_122.widgetEngineName;
  this.widgetEngineProvider = _Device_122.widgetEngineProvider;
  this.widgetEngineVersion = _Device_122.widgetEngineVersion;
  
  this.onFilesFound = null;
}

Device.prototype = function()
{  
}; 

Device.prototype.toString = function()
{
  return("Widget.Device");
};

Device.prototype.AccountInfo = null;

Device.prototype.ApplicationTypes = null;

Device.prototype.DataNetworkInfo = null;

Device.prototype.DeviceInfo = null;

Device.prototype.DeviceStateInfo = null;

Device.prototype.PowerInfo = null;

Device.prototype.RadioInfo = null;

// the isEmulator flag is not part of this spec, but provided in case there's a need
Device.prototype.isEmulator = true;
  
Device.prototype.clipboardString = null;

Device.prototype.widgetEngineName = null;

Device.prototype.widgetEngineProvider = null;

Device.prototype.widgetEngineVersion = null;

Device.prototype.onFilesFound = null;

Device.prototype.copyFile = function(originalFile, destinationFullName)
{

  var result = null;
  SecurityManager.checkSecurity("Copy File (Device.copyFile)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  {
    result = _Device_122.copyFile(originalFile, destinationFullName);
  });
  return(result);
};

Device.prototype.deleteFile = function(destinationFullName)
{
  var result = null;
  SecurityManager.checkSecurity("Delete File (Device.deleteFile)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  {
    result = _Device_122.deleteFile(destinationFullName);
  });
  return(result);
};

Device.prototype.findFiles = function(matchFile, startInx, endInx)
{
  SecurityManager.checkSecurity("File Search (Device.findFiles)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  {
    _Device_122.findFiles(matchFile.updateJIL(), startInx, endInx);
  });
};

Device.prototype.getAvailableApplications = function()
{
  var result = null;
  SecurityManager.checkSecurity("Get Available Applications (Device.getAvailableApplications)", SecurityManager.OP_SESSION, SecurityManager.OP_ALLOWED, SecurityManager.OP_ALLOWED, function()
  {
    result = _Device_122.getAvailableApplications();
  });
  return(result);
};

Device.prototype.getDirectoryFileNames = function(sourceDirectory)
{
  var result = null;
  SecurityManager.checkSecurity("List Files in a Folder (Device.getDirectoryFileNames)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  {
    result = _Device_122.getDirectoryFileNames(sourceDirectory);
  });
  return(result);
};

Device.prototype.getFile = function(fullName)
{
  var wrappedFile = null;
  SecurityManager.checkSecurity("Access a File (Device.getFile)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  {
    var jilFile = _Device_122.getFile(fullName);
    
    if ( jilFile == null )
    {
//       var exc = new Exception();
//       exc.message = "Invalid file name";
//       exc.type = ExceptionTypes.INVALID_PARAMETER;
//       throw(exc);
    }
    
    wrappedFile = new File();
    wrappedFile.setJIL(jilFile);
  });
  return(wrappedFile);
};

Device.prototype.getFileSystemRoots = function()
{
  return(_Device_122.getFileSystemRoots());
};

Device.prototype.getFileSystemSize = function(fileSystemRoot)
{
  return(_Device_122.getFileSystemSize(fileSystemRoot));
};

Device.prototype.launchApplication = function(application, startParameter)
{
  SecurityManager.checkSecurity("Launch Application (Device.launchApplication)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  {
    _Device_122.launchApplication(application, startParameter);
  });
};

Device.prototype.moveFile = function(originalFile, destinationFullName)
{
  var result = null;
  SecurityManager.checkSecurity("Move File (Device.moveFile)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  {
    result = _Device_122.moveFile(originalFile, destinationFullName);
  });
  return(result);
};

Device.prototype.setRingtone = function(ringtoneFileUrl, addressBookItem)
{
  if ( (ringtoneFileUrl == null) || (ringtoneFileUrl.constructor != String) )
    this.throwIPException("Invalid argument type for ringtoneFileUrl in Device.setRingtone");

  if ( (addressBookItem == null) || !(addressBookItem instanceof AddressBookItem) )
    this.throwIPException("Invalid argument type for addressBookItem in Device.setRingtone");

  SecurityManager.checkSecurity("Set Contact Ringtone (Device.setRingtone)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  {
    _Device_122.setRingtone(ringtoneFileUrl, addressBookItem.updateJIL());
  });
};

Device.prototype.vibrate = function(durationSeconds)
{
  if ( (durationSeconds == null) || !(durationSeconds > -1) )
    this.throwIPException("Invalid argument type for durationSeconds in Device.vibrate");
  
  _Device_122.vibrate(durationSeconds);
};

Device.prototype.throwIPException = function(message)
{
//   var exc = new Exception();
//   exc.message = message;
//   exc.type = ExceptionTypes.INVALID_PARAMETER;
//   throw(exc);
};
Back to Top