Permalink
Browse files

Merge pull request #208 from timwindsor/deviceInfoUpdate

isSimulator() call added to Device Info extension
  • Loading branch information...
2 parents 4eb7134 + 5df5663 commit 3ac5235b507ffe15af01d362359f27439d5b597c @timwindsor timwindsor committed Oct 4, 2013

Large diffs are not rendered by default.

Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -85,5 +85,7 @@ string TemplateJS::InvokeMethod(const string& command) {
return m_pTemplateController->getRoamingStatus();
else if (strCommand == "getMNC")
return m_pTemplateController->getMNC();
+ else if (strCommand == "isSimulator")
+ return m_pTemplateController->isSimulator();
return "Unknown C++ method";
}
@@ -16,6 +16,8 @@
#include <string>
#include <sstream>
+#include <bps/bps.h>
+#include <bps/deviceinfo.h>
#include <bb/device/SimCardInfo>
#include <bb/device/HardwareInfo>
#include <bb/device/CellularNetworkInfo>
@@ -29,6 +31,7 @@ namespace webworks {
DeviceInfo::DeviceInfo(TemplateJS *parent) {
m_pParent = parent;
+ bps_initialize();
}
std::string DeviceInfo::getModelNumber() {
@@ -52,7 +55,22 @@ std::string DeviceInfo::getMNC() {
return simInfo.mobileNetworkCode().toLocal8Bit().data();
}
+std::string DeviceInfo::isSimulator() {
+ deviceinfo_details_t *details;
+
+ if (BPS_SUCCESS == deviceinfo_get_details(&details)) {
+ if(deviceinfo_details_is_simulator(details)) {
+ return "true";
+ } else {
+ return "false";
+ }
+ deviceinfo_free_details(&details);
+ }
+ return "null";
+}
+
DeviceInfo::~DeviceInfo() {
+ bps_shutdown();
}
@@ -32,6 +32,7 @@ class DeviceInfo {
std::string getRoamingStatus();
std::string getMCC();
std::string getMNC();
+ std::string isSimulator();
private:
TemplateJS *m_pParent;
@@ -21,6 +21,11 @@ Copy the ext\community.deviceInfo folder into the Framework\ext folder of the We
community.deviceInfo.getModelNumber()
</pre>
+<pre>
+//returns whether the device is a Simulator - 'true' or 'false'
+community.deviceInfo.isSimulator()
+</pre>
+
<pre>
//returns Roaming Status as 'true' or 'false'
community.deviceInfo.getRoamingStatus()
@@ -40,4 +40,10 @@ var _self = {},
_self.getMNC = function () {
return window.webworks.execSync(_ID, "getMNC", null);
};
+
+ //get Mobile Network Code
+ _self.isSimulator = function () {
+ return window.webworks.execSync(_ID, "isSimulator", null);
+ };
+
module.exports = _self;
@@ -34,5 +34,9 @@ module.exports = {
getMNC: function (success, fail) {
success(template.getInstance().getMNC());
+ },
+
+ isSimulator: function (success, fail) {
+ success(template.getInstance().isSimulator());
}
};
@@ -64,6 +64,10 @@ JNEXT.Template = function () {
return JNEXT.invoke(self.m_id, "getMNC");
};
+ self.isSimulator = function () {
+ return JNEXT.invoke(self.m_id, "isSimulator");
+ };
+
// ************************
// End of methods to edit
// ************************

0 comments on commit 3ac5235

Please sign in to comment.