Skip to content
Browse files

Merge pull request #214 from zivchang/next

Application and NFC API update
  • Loading branch information...
2 parents 85b1adb + 2f353fd commit eed2c718ccccbfac60e6ea12253fd38e3129d549 @zivchang zivchang committed Apr 15, 2013
View
21 lib/ripple/platform/tizen/2.0/application.js
@@ -56,6 +56,7 @@ function _setupCurrentApp() {
categories: [],
installDate: new Date(),
size: 1024,
+ sharedURI: "/usr/local/share/",
operation: "",
appControl: {
uri: "",
@@ -433,6 +434,25 @@ _self = function () {
return certs;
}
+ function getAppSharedURI(id) {
+ var appId;
+
+ if (id === null || id === undefined) {
+ appId = _data.activeApp.appId;
+ return _data.applications[appId].sharedURI;
+ }
+
+ if (id && (typeof id !== "string")) {
+ throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
+ }
+
+ if (!_data.applications[id]) {
+ throw new WebAPIError(errorcode.NOT_FOUND_ERR);
+ }
+
+ return _data.applications[id].sharedURI;
+ }
+
function addAppInfoEventListener(eventCallback) {
var handle;
@@ -485,6 +505,7 @@ _self = function () {
getAppsInfo : getAppsInfo,
getAppInfo : getAppInfo,
getAppCerts : getAppCerts,
+ getAppSharedURI: getAppSharedURI,
addAppInfoEventListener : addAppInfoEventListener,
removeAppInfoEventListener : removeAppInfoEventListener,
handleSubFeatures : handleSubFeatures
View
38 lib/ripple/platform/tizen/2.0/nfc.js
@@ -49,7 +49,7 @@ var db = require('ripple/db'),
},
_security = {
"http://tizen.org/privilege/nfc.admin": ["setPowered"],
- "http://tizen.org/privilege/nfc.common": ["getDefaultAdapter", "getCachedMessage", "toByte"],
+ "http://tizen.org/privilege/nfc.common": ["getDefaultAdapter", "setExclusiveMode", "getCachedMessage", "toByte"],
"http://tizen.org/privilege/nfc.p2p": ["setPeerListener", "unsetPeerListener", "setReceiveNDEFListener", "unsetReceiveNDEFListener", "sendNDEF"],
"http://tizen.org/privilege/nfc.tag": ["setTagListener", "unsetTagListener", "readNDEF", "writeNDEF", "transceive"],
all: true
@@ -70,6 +70,7 @@ function _validateCallbackType(onSuccess) {
}
_self = function () {
+ var nfc, _exclusiveMode = false;
function getDefaultAdapter() {
if (!_security.all && !_security.getDefaultAdapter) {
throw new WebAPIError(errorcode.SECURITY_ERR);
@@ -85,6 +86,28 @@ _self = function () {
return _data.nfcAdapter;
}
+ /* API Description:
+ * If it gets priority and it is in foreground, system doesn't
+ * send app controls that are usually sent when detecting NFC Tag
+ * or receiving NDEF Message from the connected NFC peer-to-peer target
+ *
+ * Implementation detail:
+ * due to simulator only support single running instance and doesn't have
+ * other app controls which be called by design. we just put some system
+ * exclusive mode info on the 'System Summary' panel
+ */
+ function setExclusiveMode(mode) {
+ if (!_security.all && !_security.setExclusiveMode) {
+ throw new WebAPIError(errorcode.SECURITY_ERR);
+ }
+
+ if (typeof mode !== "boolean") {
+ throw new WebAPIError(errorcode.TYPE_MISMATCH_ERR);
+ }
+ _exclusiveMode = mode;
+ jQuery("#NFCExclusiveModeValue").text(_exclusiveMode);
+ }
+
function handleSubFeatures(subFeatures) {
for (var subFeature in subFeatures) {
if (_security[subFeature].length === 0) {
@@ -98,8 +121,9 @@ _self = function () {
}
}
- var nfc = {
+ nfc = {
getDefaultAdapter: getDefaultAdapter,
+ setExclusiveMode: setExclusiveMode,
handleSubFeatures: handleSubFeatures
};
@@ -184,10 +208,10 @@ NFCAdapter = function () {
}
});
event.on("nfc-peer-sending-ndef", function () {
- var _records = [], rec, _ndef;
+ var _records = [], rec, _ndef, i;
if (isPeerConnected) {
peer = db.retrieveObject(_NFC_PEER);
- for(i in peer.ndef.records) {
+ for (i in peer.ndef.records) {
rec = peer.ndef.records[i];
_records.push(new NDEFRecord(rec.tnf, rec.type, rec.payload, rec.id));
}
@@ -265,7 +289,7 @@ NFCAdapter = function () {
successCallback();
}
}
-
+/*
function setCardEmulation(_seType, successCallback, errorCallback) {
var originalType;
if (!_security.all && !_security.setCardEmulation) {
@@ -295,7 +319,6 @@ NFCAdapter = function () {
successCallback();
}
}
-
function setCardEmulationChangeListener(changeCallback) {
if (!_security.all && !_security.setCardEmulationChangeListener) {
throw new WebAPIError(errorcode.SECURITY_ERR);
@@ -318,6 +341,7 @@ NFCAdapter = function () {
_data.listener.onCardEmulationChanged = null;
}
+*/
// Registers a callback function to invoke when NFC tag is detected.
function setTagListener(detectCallback, tagFilter) {
@@ -505,6 +529,7 @@ NFCTag = function (type, isSupportedNDEF, ndefSize, properties, isConnected, nde
}
// Formats the detected tag that can store NDEF messages.
+ /*
function formatNDEF(successCallback, errorCallback, key) {
tizen1_utils.validateCallbackType(successCallback, errorCallback);
@@ -523,6 +548,7 @@ NFCTag = function (type, isSupportedNDEF, ndefSize, properties, isConnected, nde
successCallback();
}
+ */
nfcTag = {
readNDEF : readNDEF,
View
4 lib/ripple/ui.js
@@ -282,12 +282,12 @@ function _db_upgrade_for_release() {
var version = db.retrieve(constants.RELEASE_VERSION);
// version: 20121115 is the first release version
- if (version === null || version === undefined || Number(version) < 20130411) {
+ if (version === null || version === undefined || Number(version) < 20130417) {
db.remove(constants.COMMON.APPLICATION_STATE + "tizen");
db.remove(constants.COMMON.APPLICATION_STATE + "cordova");
db.remove("tizen1-db-application");
db.remove("tizen-db-package");
- version = 20130411;
+ version = 20130417;
db.save(constants.RELEASE_VERSION, version);
}
}
View
8 lib/ripple/ui/plugins/application.js
@@ -33,6 +33,7 @@ var event = require('ripple/event'),
categories: ["media"],
size: 5120,
packageId: "TEST_APP_ID",
+ sharedURI: "/usr/local/share/viewer",
operation: "http://tizen.org/appcontrol/operation/view",
appControl: {
uri: "http://tizen.org/appcontrol/uri/view",
@@ -52,6 +53,7 @@ var event = require('ripple/event'),
categories: ["media"],
size: 2048,
packageId: "TEST_APP_ID",
+ sharedURI: "/usr/local/share/player",
operation: "http://tizen.org/appcontrol/operation/play",
appControl: {
uri: "http://tizen.org/appcontrol/uri/play",
@@ -71,6 +73,7 @@ var event = require('ripple/event'),
categories: ["media"],
size: 3094,
packageId: "EXAMPLE_ID",
+ sharedURI: "/usr/local/share/dummy",
operation: "http://tizen.org/appcontrol/operation/dummy",
appControl: {
uri: "http://tizen.org/appcontrol/uri/dummy",
@@ -90,6 +93,7 @@ var event = require('ripple/event'),
categories: ["dialer"],
size: 2048,
packageId: "SAMPLE_ID",
+ sharedURI: "/usr/local/share/dialer",
operation: "http://tizen.org/appcontrol/operation/call",
appControl: {
uri: "http://tizen.org/appcontrol/uri/call",
@@ -109,6 +113,7 @@ var event = require('ripple/event'),
categories: ["message"],
size: 2048,
packageId: "SAMPLE_ID",
+ sharedURI: "/usr/local/share/sender",
operation: "http://tizen.org/appcontrol/operation/send_text",
appControl: {
uri: "http://tizen.org/appcontrol/uri/send_text",
@@ -131,6 +136,7 @@ var event = require('ripple/event'),
installDate: new Date(),
size: 2048,
packageId: "SAMPLE_ID",
+ sharedURI: "/usr/local/share/dialer",
operation: "http://tizen.org/appcontrol/operation/call",
appControl: {
uri: "http://tizen.org/appcontrol/uri/call",
@@ -151,6 +157,7 @@ var event = require('ripple/event'),
installDate: new Date(),
size: 2048,
packageId: "SAMPLE_ID",
+ sharedURI: "/usr/local/share/sender",
operation: "http://tizen.org/appcontrol/operation/send_text",
appControl: {
uri: "http://tizen.org/appcontrol/uri/send_text",
@@ -191,6 +198,7 @@ function _loadInstalledAppList() {
.replace(/#InstallDate/, item.installDate)
.replace(/#Size/, item.size)
.replace(/#PackageID/, item.packageId)
+ .replace(/#SharedURI/, item.sharedURI)
.replace(/#Operation/, item.operation)
.replace(/#URI/, item.appControl.uri)
.replace(/#MIME/, item.appControl.mime)
View
1 lib/ripple/ui/plugins/information.js
@@ -75,6 +75,7 @@ function _updateInformationView() {
infoList.push("<section><div style=\"clear:both;\"></div><div id=\"systemSummaryLockScreenContainer\" style=\"width:320px; height:20px; overflow:hidden; white-space: nowrap; text-overflow: ellipsis;\" ><label class=\"ui-text-label\">Lock Screen Image: </label><span>" + _systemSettings["LOCK_SCREEN"] + "</span></div></section>");
infoList.push("<section><div style=\"clear:both;\"></div><div id=\"systemSummaryInComingCallContainer\" style=\"width:320px; height:20px; overflow:hidden; white-space: nowrap; text-overflow: ellipsis;\" ><label class=\"ui-text-label\">Incoming Call Number: </label><span>" + _systemSettings["INCOMING_CALL"] + "</span></div></section>");
infoList.push("<section><div style=\"clear:both;\"></div><div id=\"systemSummaryNotiEMailContainer\" style=\"width:320px; height:20px; overflow:hidden; white-space: nowrap; text-overflow: ellipsis;\" ><label class=\"ui-text-label\">Notification Email: </label><span>" + _systemSettings["NOTIFICATION_EMAIL"] + "</span></div></section>");
+ infoList.push("<section><div style=\"clear:both;\"></div><div id=\"NFCExclusiveModeContainer\" style=\"width:320px; height:20px; overflow:hidden; white-space: nowrap; text-overflow: ellipsis;\" ><label class=\"ui-text-label\">NFC Exclusive Mode: </label><span id=\"NFCExclusiveModeValue\">false</span></div></section>");
infoPane.innerHTML = infoList.join("");
// Make tooltip if it needed
View
4 lib/ripple/ui/plugins/package/panel.html
@@ -204,6 +204,10 @@ <h3 class="config-accordion-node-title ui-text-pass">
<td><label class="ui-text-label">Package ID</label></td>
<td>#PackageID</td>
</tr>
+ <tr>
+ <td><label class="ui-text-label">Shared URI</label></td>
+ <td>#SharedURI</td>
+ </tr>
<tr><td colspan="2"><hr></td></tr>
</table>
<h3>Binding Control Operation</h3>

0 comments on commit eed2c71

Please sign in to comment.
Something went wrong with that request. Please try again.