/*!
- Ripple Mobile Environment Emulator v0.9.8 :: Built On Fri Mar 28 2014 13:51:03 GMT+0800 (CST)
+ Ripple Mobile Environment Emulator v0.9.8 :: Built On Fri Apr 04 2014 14:27:22 GMT+0800 (CST)
Apache License
Version 2.0, January 2004
_NFC_OUTPUT_MESSAGE = "tizen1.0-nfc-output-message",
_powered = false,
_isConnected = false,
+ _tagNDEF,
+ _tagRaw,
+ _peerNDEF,
+ btNodes,
+ _btDeviceTemplate = "",
+ _btSimulatedDevs = {},
+ _btBluetoothDB;
+
+String.prototype.toCharCode = function () {
+ return this.split("").map(function(char) {
+ return char.charCodeAt(0);
+ });
+};
+
+function elementEnableDisableSetting(prop) {
+ jQuery("#nfc-attach-msg").text("\xa0");
+ jQuery("#nfc-peer-send-msg").text("\xa0");
+ if (prop && prop.power !== undefined && prop.power !== null) {
+ if (!prop.power) {
+ $("#nfc-type").removeAttr("disabled");
+ }
+ }
+ if (prop && prop.connectedState !== undefined && prop.connectedState !== null) {
+ if (prop.connectedState) {
+ $("#nfc-type").attr("disabled", "disabled");
+ $("#nfc-tag-type-text").text($("#nfc-tag-type option:selected").text());
+ $("#nfc-tag-type").hide();
+ $("#nfc-tag-type-text").show();
+ $("#nfc-tag-NDEF-support-text").text($("#nfc-tag-NDEF-support option:selected").text());
+ $("#nfc-tag-NDEF-support").hide();
+ $("#nfc-tag-NDEF-support-text").show();
+ $("#nfc-raw-data").attr("disabled", "disabled");
+ } else {
+ $("#nfc-type").removeAttr("disabled");
+ $("#nfc-tag-type").show();
+ $("#nfc-tag-type-text").hide();
+ $("#nfc-tag-NDEF-support").show();
+ $("#nfc-tag-NDEF-support-text").hide();
+ $("#nfc-raw-data").removeAttr("disabled");
+ }
+ }
+}
+
+function _initializeDB() {
_tagNDEF = {
type: "GENERIC_TARGET",
isSupportedNDEF: true,
recordCount: 2,
records: [{
tnf: 1,
- type: "TypeA",
- id: "ID001",
- payload: "This is 1st payload"
+ type: "TypeA".toCharCode(),
+ id: "ID001".toCharCode(),
+ payload: "This is 1st payload".toCharCode()
}, {
tnf: 1,
- type: "TypeA",
- id: "ID002",
- payload: "This is 2nd payload"
+ type: "TypeA".toCharCode(),
+ id: "ID002".toCharCode(),
+ payload: "This is 2nd payload".toCharCode()
}]
},
{
recordCount: 2,
records: [{
tnf: 1,
- type: "TypeA",
- id: "ID003",
- payload: "This is 1st payload"
+ type: "TypeA".toCharCode(),
+ id: "ID003".toCharCode(),
+ payload: "This is 1st payload".toCharCode()
}, {
tnf: 1,
- type: "TypeA",
- id: "ID004",
- payload: "This is 2nd payload"
+ type: "TypeA".toCharCode(),
+ id: "ID004".toCharCode(),
+ payload: "This is 2nd payload".toCharCode()
}]
},
{
recordCount: 2,
records: [{
tnf: 1,
- type: "TypeA",
- id: "ID005",
- payload: "This is 1st payload"
+ type: "TypeA".toCharCode(),
+ id: "ID005".toCharCode(),
+ payload: "This is 1st payload".toCharCode()
}, {
tnf: 1,
- type: "TypeA",
- id: "ID006",
- payload: "This is 2nd payload"
+ type: "TypeA".toCharCode(),
+ id: "ID006".toCharCode(),
+ payload: "This is 2nd payload".toCharCode()
}]
}]
- },
+ };
+
_tagRaw = {
type: "GENERIC_TARGET",
isSupportedNDEF: false,
rawData : ""
- },
+ };
+
_peerNDEF = {
ndef: {
recordCount: 2,
records: [{
tnf: 1,
- type: "TypeA",
- id: "ID001",
- payload: "This is 1st payload"
+ type: "TypeA".toCharCode(),
+ id: "ID001".toCharCode(),
+ payload: "This is 1st payload".toCharCode()
}, {
tnf: 1,
- type: "TypeA",
- id: "ID002",
- payload: "This is 2nd payload"
+ type: "TypeA".toCharCode(),
+ id: "ID002".toCharCode(),
+ payload: "This is 2nd payload".toCharCode()
}]
}
- },
- btNodes,
- _btDeviceTemplate = "",
- _btSimulatedDevs = {},
- _btBluetoothDB;
-
-function elementEnableDisableSetting(prop) {
- jQuery("#nfc-attach-msg").text("\xa0");
- jQuery("#nfc-peer-send-msg").text("\xa0");
- if (prop && prop.power !== undefined && prop.power !== null) {
- if (!prop.power) {
- $("#nfc-type").removeAttr("disabled");
- }
- }
- if (prop && prop.connectedState !== undefined && prop.connectedState !== null) {
- if (prop.connectedState) {
- $("#nfc-type").attr("disabled", "disabled");
- $("#nfc-tag-type-text").text($("#nfc-tag-type option:selected").text());
- $("#nfc-tag-type").hide();
- $("#nfc-tag-type-text").show();
- $("#nfc-tag-NDEF-support-text").text($("#nfc-tag-NDEF-support option:selected").text());
- $("#nfc-tag-NDEF-support").hide();
- $("#nfc-tag-NDEF-support-text").show();
- $("#nfc-raw-data").attr("disabled", "disabled");
- } else {
- $("#nfc-type").removeAttr("disabled");
- $("#nfc-tag-type").show();
- $("#nfc-tag-type-text").hide();
- $("#nfc-tag-NDEF-support").show();
- $("#nfc-tag-NDEF-support-text").hide();
- $("#nfc-raw-data").removeAttr("disabled");
- }
- }
+ };
}
function _initializeElements() {
return;
}
db.saveObject(_NFC_PEER, _peerNDEF);
- event.trigger("nfc-peer-sending-ndef", [_peerNDEF]);
+ event.trigger("nfc-peer-sending-ndef", []);
});
// Initialize network bearer selection
display: true
},
initialize: function () {
+ _initializeDB();
_initializeElements();
// Events for nfc module
peers = channels.logical;
}
- channel = new Channel(isBasic, aid);
+ channel = new Channel(isBasic, aid, onChannelClosed);
peers.push(channel);
successCallback(channel);
});
}
+ function onChannelClosed(isBasicChannel) {
+ if (isBasicChannel) {
+ session.locker = null;
+ }
+ }
+
// public
function openBasicChannel(aid, successCallback, errorCallback) {
if (!_security.openBasicChannel) {
t.Session("getATR", arguments);
- return t.byte(atr.slice(0), "[]");
+ return t.byte(atr, "[]+");
}
function close() {
closeChannel(channels[type]);
channels[type] = [];
}
- session.locker = null;
}
session.isClosed = false;
this.closeChannels = closeChannels;
};
-Channel = function (isBasic, aid) {
+Channel = function (isBasic, aid, onClosed) {
var channel = {};
// private
return;
channel.isClosed = true;
+ onClosed(channel.isBasicChannel);
}
function transmit(command, successCallback, errorCallback) {
event.trigger("SETransmitted", [aid, command]);
- successCallback(t.byte(response, "[]"));
+ successCallback(t.byte(response, "[]+"));
}, 1);
}
t = require('ripple/platform/tizen/2.0/typecast'),
WebAPIError = require('ripple/platform/tizen/2.0/WebAPIError'),
WebAPIException = require('ripple/platform/tizen/2.0/WebAPIException'),
- NDEFRecord = require('ripple/platform/tizen/2.0/NDEFRecordInternal'),
+ NDEFRecord = require('ripple/platform/tizen/2.0/NDEFRecord'),
NDEFMessage = require('ripple/platform/tizen/2.0/NDEFMessage'),
NFCAdapter,
NFCAdapterPrototype,
if (obj instanceof window.tizen[pattern._constructor])
return true;
+ if ("_derived" in pattern)
+ return true;
+
return false;
}
break;
}
if (ret === null) {
+ if ("_constructor" in pattern)
+ break;
+
return null;
}
break;
elementType = _self(pattern[0]);
for (i in obj) {
- if (obj[i]) {
+ if (obj[i] !== undefined) {
arr[i] = elementType.copy(obj[i]);
if (arr[i] === null)
return null;
break;
}
if (derived === null) {
+ if ("_constructor" in pattern)
+ break;
+
return null;
}
for (attr in derived) {