Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Merges in BlackBerry 10 support
Browse files Browse the repository at this point in the history
  • Loading branch information
umcsdon authored and timwindsor committed Jul 15, 2015
1 parent 70ca00b commit 7b320e1
Show file tree
Hide file tree
Showing 34 changed files with 9,426 additions and 0 deletions.
703 changes: 703 additions & 0 deletions src/blackberry10/LICENSE

Large diffs are not rendered by default.

143 changes: 143 additions & 0 deletions src/blackberry10/index.js
@@ -0,0 +1,143 @@
/*
* Copyright 2013-2015 BlackBerry Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var barcodescanner,
resultObjs = {},
readCallback,
_utils = require("../../lib/utils");

module.exports = {

// methods to start and stop scanning
startRead: function (success, fail, args, env) {
var result = new PluginResult(args, env);
resultObjs[result.callbackId] = result;
readCallback = result.callbackId;
var views = qnx.webplatform.getWebViews();
var handle = null;
var group = null;
var z = -1;
for (var i = 0; i < views.length; i++) {
if (views[i].visible && views[i].zOrder > z){
z = views[i].zOrder;
group = views[i].windowGroup;
handle = views[i].jsScreenWindowHandle;
}
}
if (handle !== null) {
var values = { group: group, handle: handle };
result.ok(barcodescanner.getInstance().startRead(result.callbackId, values), true);
} else {
result.error("Failed to find window handle", false);
}
},
stopRead: function (success, fail, args, env) {
var result = new PluginResult(args, env);
resultObjs[result.callbackId] = result;
result.ok(barcodescanner.getInstance().stopRead(result.callbackId), true);
},
add: function (success, fail) {
console.log('Frame Available event listening');
},
remove: function (success, fail) {
console.log('End listening to frames');
}
};


JNEXT.BarcodeScanner = function () {
var self = this,
hasInstance = false;

self.getId = function () {
return self.m_id;
};

self.init = function () {
if (!JNEXT.require("libBarcodeScanner")) {
return false;
}

self.m_id = JNEXT.createObject("libBarcodeScanner.BarcodeScannerJS");

if (self.m_id === "") {
return false;
}

JNEXT.registerEvents(self);
};

// ************************
// Enter your methods here
// ************************

// Fired by the Event framework (used by asynchronous callbacks)

self.onEvent = function (strData) {
var arData = strData.split(" "),
callbackId = arData[0],
receivedEvent = arData[1],
data = receivedEvent + " " + arData[2],
result = resultObjs[callbackId],
events = ["community.barcodescanner.codefound.native",
"community.barcodescanner.errorfound.native",
"community.barcodescanner.started.native",
"community.barcodescanner.ended.native"];

// Restructures results when codefound has spaces
if(arData.length > 3){
var i;
for(i=3; i<arData.length; i++) {
data += " " + arData[i];
}
}

if (events.indexOf(receivedEvent) != -1) {
console.log(callbackId);
console.log(data);
result.callbackOk(data, true);

}
if(receivedEvent == "community.barcodescanner.ended.native") {
delete resultObjs[readCallback];
readCallback = null
}

};

// Thread methods
self.startRead = function (callbackId, handle) {
return JNEXT.invoke(self.m_id, "startRead " + callbackId + " " + JSON.stringify(handle));
};
self.stopRead = function (callbackId) {
return JNEXT.invoke(self.m_id, "stopRead " + callbackId);
};

// ************************
// End of methods to edit
// ************************
self.m_id = "";

self.getInstance = function () {
if (!hasInstance) {
hasInstance = true;
self.init();
}
return self;
};

};

barcodescanner = new JNEXT.BarcodeScanner();
220 changes: 220 additions & 0 deletions src/blackberry10/native/.cproject

Large diffs are not rendered by default.

@@ -0,0 +1,2 @@
QNX_CURRENT_INSTALL=BlackBerry Native SDK 10.2
eclipse.preferences.version=1
2 changes: 2 additions & 0 deletions src/blackberry10/native/device/.gitignore
@@ -0,0 +1,2 @@
/src
/public
Binary file not shown.
19 changes: 19 additions & 0 deletions src/blackberry10/native/public/json/autolink.h
@@ -0,0 +1,19 @@
#ifndef JSON_AUTOLINK_H_INCLUDED
# define JSON_AUTOLINK_H_INCLUDED

# include "config.h"

# ifdef JSON_IN_CPPTL
# include <cpptl/cpptl_autolink.h>
# endif

# if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && !defined(JSON_IN_CPPTL)
# define CPPTL_AUTOLINK_NAME "json"
# undef CPPTL_AUTOLINK_DLL
# ifdef JSON_DLL
# define CPPTL_AUTOLINK_DLL
# endif
# include "autolink.h"
# endif

#endif // JSON_AUTOLINK_H_INCLUDED
43 changes: 43 additions & 0 deletions src/blackberry10/native/public/json/config.h
@@ -0,0 +1,43 @@
#ifndef JSON_CONFIG_H_INCLUDED
# define JSON_CONFIG_H_INCLUDED

/// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1

/// If defined, indicates that json may leverage CppTL library
//# define JSON_USE_CPPTL 1
/// If defined, indicates that cpptl vector based map should be used instead of std::map
/// as Value container.
//# define JSON_USE_CPPTL_SMALLMAP 1
/// If defined, indicates that Json specific container should be used
/// (hash table & simple deque container with customizable allocator).
/// THIS FEATURE IS STILL EXPERIMENTAL!
//# define JSON_VALUE_USE_INTERNAL_MAP 1
/// Force usage of standard new/malloc based allocator instead of memory pool based allocator.
/// The memory pools allocator used optimization (initializing Value and ValueInternalLink
/// as if it was a POD) that may cause some validation tool to report errors.
/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.
//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1

/// If defined, indicates that Json use exception to report invalid type manipulation
/// instead of C assert macro.
# define JSON_USE_EXCEPTION 1

# ifdef JSON_IN_CPPTL
# include <cpptl/config.h>
# ifndef JSON_USE_CPPTL
# define JSON_USE_CPPTL 1
# endif
# endif

# ifdef JSON_IN_CPPTL
# define JSON_API CPPTL_API
# elif defined(JSON_DLL_BUILD)
# define JSON_API __declspec(dllexport)
# elif defined(JSON_DLL)
# define JSON_API __declspec(dllimport)
# else
# define JSON_API
# endif

#endif // JSON_CONFIG_H_INCLUDED
42 changes: 42 additions & 0 deletions src/blackberry10/native/public/json/features.h
@@ -0,0 +1,42 @@
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
# define CPPTL_JSON_FEATURES_H_INCLUDED

# include "forwards.h"

namespace Json {

/** \brief Configuration passed to reader and writer.
* This configuration object can be used to force the Reader or Writer
* to behave in a standard conforming way.
*/
class JSON_API Features
{
public:
/** \brief A configuration that allows all features and assumes all strings are UTF-8.
* - C & C++ comments are allowed
* - Root object can be any JSON value
* - Assumes Value strings are encoded in UTF-8
*/
static Features all();

/** \brief A configuration that is strictly compatible with the JSON specification.
* - Comments are forbidden.
* - Root object must be either an array or an object value.
* - Assumes Value strings are encoded in UTF-8
*/
static Features strictMode();

/** \brief Initialize the configuration like JsonConfig::allFeatures;
*/
Features();

/// \c true if comments are allowed. Default: \c true.
bool allowComments_;

/// \c true if root must be either an array or an object value. Default: \c false.
bool strictRoot_;
};

} // namespace Json

#endif // CPPTL_JSON_FEATURES_H_INCLUDED
39 changes: 39 additions & 0 deletions src/blackberry10/native/public/json/forwards.h
@@ -0,0 +1,39 @@
#ifndef JSON_FORWARDS_H_INCLUDED
# define JSON_FORWARDS_H_INCLUDED

# include "config.h"

namespace Json {

// writer.h
class FastWriter;
class StyledWriter;

// reader.h
class Reader;

// features.h
class Features;

// value.h
typedef int Int;
typedef unsigned int UInt;
class StaticString;
class Path;
class PathArgument;
class Value;
class ValueIteratorBase;
class ValueIterator;
class ValueConstIterator;
#ifdef JSON_VALUE_USE_INTERNAL_MAP
class ValueAllocator;
class ValueMapAllocator;
class ValueInternalLink;
class ValueInternalArray;
class ValueInternalMap;
#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP

} // namespace Json


#endif // JSON_FORWARDS_H_INCLUDED
10 changes: 10 additions & 0 deletions src/blackberry10/native/public/json/json.h
@@ -0,0 +1,10 @@
#ifndef JSON_JSON_H_INCLUDED
# define JSON_JSON_H_INCLUDED

# include "autolink.h"
# include "value.h"
# include "reader.h"
# include "writer.h"
# include "features.h"

#endif // JSON_JSON_H_INCLUDED

0 comments on commit 7b320e1

Please sign in to comment.