PageRenderTime 51ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/runtime/chrome/modules/api/jil/1.1r4/Device.jsm

http://transit-widget-tools.googlecode.com/
Unknown | 196 lines | 156 code | 40 blank | 0 comment | 0 complexity | ea07940f2edad4bd580374d3cfa6c567 MD5 | raw file
  1. var EXPORTED_SYMBOLS = ["Device"];
  2. var _Device_122 = Components.classes["@jil.org/jilapi-device;1"].getService(Components.interfaces.jilDevice);
  3. Components.utils.import("resource://transit-runtime/api/jil/SecurityManager.jsm");
  4. Components.utils.import("resource://transit-runtime/api/jil/1.1r4/AccountInfo.jsm");
  5. Components.utils.import("resource://transit-runtime/api/jil/1.1r4/DataNetworkInfo.jsm");
  6. Components.utils.import("resource://transit-runtime/api/jil/1.1r4/DeviceInfo.jsm");
  7. Components.utils.import("resource://transit-runtime/api/jil/1.1r4/DeviceStateInfo.jsm");
  8. Components.utils.import("resource://transit-runtime/api/jil/1.1r4/File.jsm");
  9. Components.utils.import("resource://transit-runtime/api/jil/1.1r4/PositionInfo.jsm");
  10. Components.utils.import("resource://transit-runtime/api/jil/1.1r4/PowerInfo.jsm");
  11. Components.utils.import("resource://transit-runtime/api/jil/1.1r4/RadioInfo.jsm");
  12. Components.utils.import("resource://transit-runtime/api/jil/1.1r4/AddressBookItem.jsm");
  13. function Device()
  14. {
  15. this.DeviceInfo = new DeviceInfo();
  16. this.AccountInfo = new AccountInfo();
  17. this.DataNetworkInfo = new DataNetworkInfo();
  18. this.DeviceStateInfo = new DeviceStateInfo();
  19. this.PowerInfo = new PowerInfo();
  20. this.RadioInfo = new RadioInfo();
  21. this.clipboardString = _Device_122.clipboardString;
  22. this.widgetEngineName = _Device_122.widgetEngineName;
  23. this.widgetEngineProvider = _Device_122.widgetEngineProvider;
  24. this.widgetEngineVersion = _Device_122.widgetEngineVersion;
  25. this.onFilesFound = null;
  26. }
  27. Device.prototype = function()
  28. {
  29. };
  30. Device.prototype.toString = function()
  31. {
  32. return("Widget.Device");
  33. };
  34. Device.prototype.AccountInfo = null;
  35. Device.prototype.ApplicationTypes = null;
  36. Device.prototype.DataNetworkInfo = null;
  37. Device.prototype.DeviceInfo = null;
  38. Device.prototype.DeviceStateInfo = null;
  39. Device.prototype.PowerInfo = null;
  40. Device.prototype.RadioInfo = null;
  41. // the isEmulator flag is not part of this spec, but provided in case there's a need
  42. Device.prototype.isEmulator = true;
  43. Device.prototype.clipboardString = null;
  44. Device.prototype.widgetEngineName = null;
  45. Device.prototype.widgetEngineProvider = null;
  46. Device.prototype.widgetEngineVersion = null;
  47. Device.prototype.onFilesFound = null;
  48. Device.prototype.copyFile = function(originalFile, destinationFullName)
  49. {
  50. var result = null;
  51. SecurityManager.checkSecurity("Copy File (Device.copyFile)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  52. {
  53. result = _Device_122.copyFile(originalFile, destinationFullName);
  54. });
  55. return(result);
  56. };
  57. Device.prototype.deleteFile = function(destinationFullName)
  58. {
  59. var result = null;
  60. SecurityManager.checkSecurity("Delete File (Device.deleteFile)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  61. {
  62. result = _Device_122.deleteFile(destinationFullName);
  63. });
  64. return(result);
  65. };
  66. Device.prototype.findFiles = function(matchFile, startInx, endInx)
  67. {
  68. SecurityManager.checkSecurity("File Search (Device.findFiles)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  69. {
  70. _Device_122.findFiles(matchFile.updateJIL(), startInx, endInx);
  71. });
  72. };
  73. Device.prototype.getAvailableApplications = function()
  74. {
  75. var result = null;
  76. SecurityManager.checkSecurity("Get Available Applications (Device.getAvailableApplications)", SecurityManager.OP_SESSION, SecurityManager.OP_ALLOWED, SecurityManager.OP_ALLOWED, function()
  77. {
  78. result = _Device_122.getAvailableApplications();
  79. });
  80. return(result);
  81. };
  82. Device.prototype.getDirectoryFileNames = function(sourceDirectory)
  83. {
  84. var result = null;
  85. SecurityManager.checkSecurity("List Files in a Folder (Device.getDirectoryFileNames)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  86. {
  87. result = _Device_122.getDirectoryFileNames(sourceDirectory);
  88. });
  89. return(result);
  90. };
  91. Device.prototype.getFile = function(fullName)
  92. {
  93. var wrappedFile = null;
  94. SecurityManager.checkSecurity("Access a File (Device.getFile)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  95. {
  96. var jilFile = _Device_122.getFile(fullName);
  97. if ( jilFile == null )
  98. {
  99. // var exc = new Exception();
  100. // exc.message = "Invalid file name";
  101. // exc.type = ExceptionTypes.INVALID_PARAMETER;
  102. // throw(exc);
  103. }
  104. wrappedFile = new File();
  105. wrappedFile.setJIL(jilFile);
  106. });
  107. return(wrappedFile);
  108. };
  109. Device.prototype.getFileSystemRoots = function()
  110. {
  111. return(_Device_122.getFileSystemRoots());
  112. };
  113. Device.prototype.getFileSystemSize = function(fileSystemRoot)
  114. {
  115. return(_Device_122.getFileSystemSize(fileSystemRoot));
  116. };
  117. Device.prototype.launchApplication = function(application, startParameter)
  118. {
  119. SecurityManager.checkSecurity("Launch Application (Device.launchApplication)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  120. {
  121. _Device_122.launchApplication(application, startParameter);
  122. });
  123. };
  124. Device.prototype.moveFile = function(originalFile, destinationFullName)
  125. {
  126. var result = null;
  127. SecurityManager.checkSecurity("Move File (Device.moveFile)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  128. {
  129. result = _Device_122.moveFile(originalFile, destinationFullName);
  130. });
  131. return(result);
  132. };
  133. Device.prototype.setRingtone = function(ringtoneFileUrl, addressBookItem)
  134. {
  135. if ( (ringtoneFileUrl == null) || (ringtoneFileUrl.constructor != String) )
  136. this.throwIPException("Invalid argument type for ringtoneFileUrl in Device.setRingtone");
  137. if ( (addressBookItem == null) || !(addressBookItem instanceof AddressBookItem) )
  138. this.throwIPException("Invalid argument type for addressBookItem in Device.setRingtone");
  139. SecurityManager.checkSecurity("Set Contact Ringtone (Device.setRingtone)", SecurityManager.OP_ONE_SHOT, SecurityManager.OP_BLANKET, SecurityManager.OP_ALLOWED, function()
  140. {
  141. _Device_122.setRingtone(ringtoneFileUrl, addressBookItem.updateJIL());
  142. });
  143. };
  144. Device.prototype.vibrate = function(durationSeconds)
  145. {
  146. if ( (durationSeconds == null) || !(durationSeconds > -1) )
  147. this.throwIPException("Invalid argument type for durationSeconds in Device.vibrate");
  148. _Device_122.vibrate(durationSeconds);
  149. };
  150. Device.prototype.throwIPException = function(message)
  151. {
  152. // var exc = new Exception();
  153. // exc.message = message;
  154. // exc.type = ExceptionTypes.INVALID_PARAMETER;
  155. // throw(exc);
  156. };