[CB-3367] Updates the framework to work with a smarter plugman and have a dumber packager - Re-writes cordova/plugin scripts to match the CLI interface - Includes the use of a global plugin repository for lookup - Adds a native/<arch> folder for containing the framework files of an app - Moves core plugins from template to root and installs at create time - Update package.json to get plugman from apache master Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/fa5a5900 Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/fa5a5900 Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/fa5a5900 Branch: refs/heads/master Commit: fa5a5900e52bd86ee326de6d59d4ef8f517bfd84 Parents: dcfebe3 Author: Jeffrey Heifetz <jh...@blackberry.com> Authored: Wed May 1 10:17:31 2013 -0400 Committer: lorinbeer <lo...@adobe.com> Committed: Mon May 20 10:42:40 2013 -0700 ---------------------------------------------------------------------- blackberry10/bin/create.js | 232 ++- .../templates/project/cordova/lib/bar-builder.js | 12 +- .../bin/templates/project/cordova/lib/conf.js | 2 + .../templates/project/cordova/lib/file-manager.js | 120 +- .../bin/templates/project/cordova/lib/packager.js | 1 - .../bin/templates/project/cordova/lib/plugin.js | 193 ++ blackberry10/bin/templates/project/cordova/plugin | 49 +- .../project/native/device/plugins/jnext/auth.txt | 3 + .../bin/templates/project/native/device/wwe | 2 + .../native/simulator/plugins/jnext/auth.txt | 3 + .../bin/templates/project/native/simulator/wwe | 2 + .../project/plugins/Accelerometer/plugin.xml | 29 - .../Accelerometer/src/blackberry10/index.js | 45 - .../templates/project/plugins/Battery/plugin.xml | 29 - .../plugins/Battery/src/blackberry10/index.js | 58 - .../templates/project/plugins/Camera/plugin.xml | 29 - .../plugins/Camera/src/blackberry10/index.js | 124 -- .../templates/project/plugins/Contacts/plugin.xml | 29 - .../Contacts/src/blackberry10/ContactActivity.js | 26 - .../Contacts/src/blackberry10/ContactAddress.js | 30 - .../Contacts/src/blackberry10/ContactError.js | 30 - .../Contacts/src/blackberry10/ContactField.js | 27 - .../src/blackberry10/ContactFindOptions.js | 50 - .../Contacts/src/blackberry10/ContactName.js | 39 - .../Contacts/src/blackberry10/ContactNews.js | 26 - .../src/blackberry10/ContactOrganization.js | 22 - .../Contacts/src/blackberry10/ContactPhoto.js | 23 - .../Contacts/src/blackberry10/contactConsts.js | 225 -- .../Contacts/src/blackberry10/contactUtils.js | 223 -- .../plugins/Contacts/src/blackberry10/index.js | 374 ---- .../templates/project/plugins/Device/plugin.xml | 29 - .../plugins/Device/src/blackberry10/index.js | 60 - .../templates/project/plugins/Logger/plugin.xml | 29 - .../plugins/Logger/src/blackberry10/index.js | 25 - .../project/plugins/NetworkStatus/plugin.xml | 29 - .../NetworkStatus/src/blackberry10/index.js | 59 - .../project/plugins/Notification/plugin.xml | 29 - .../plugins/Notification/src/blackberry10/index.js | 91 - .../project/plugins/SplashScreen/plugin.xml | 29 - .../plugins/SplashScreen/src/blackberry10/index.js | 28 - .../project/plugins/com.blackberry.jpps/plugin.xml | 22 - .../src/blackberry10/native/device/libjpps.so | Bin 138046 -> 0 bytes .../src/blackberry10/native/simulator/libjpps.so | Bin 224392 -> 0 bytes .../plugins/com.blackberry.utils/plugin.xml | 22 - .../src/blackberry10/native/device/libutils.so | Bin 130206 -> 0 bytes .../src/blackberry10/native/simulator/libutils.so | Bin 183184 -> 0 bytes .../plugin.xml | 23 - .../src/blackberry10/native/Makefile | 8 - .../src/blackberry10/native/arm/Makefile | 8 - .../src/blackberry10/native/arm/so.le-v7/Makefile | 1 - .../native/arm/so.le-v7/libpimcontacts.so | Bin 170350 -> 0 bytes .../src/blackberry10/native/common.mk | 18 - .../src/blackberry10/native/contact_account.cpp | 74 - .../src/blackberry10/native/contact_account.hpp | 54 - .../blackberry10/native/device/libpimcontacts.so | Bin 170350 -> 0 bytes .../src/blackberry10/native/pim_contacts_js.cpp | 174 -- .../src/blackberry10/native/pim_contacts_js.hpp | 45 - .../src/blackberry10/native/pim_contacts_qt.cpp | 1611 --------------- .../src/blackberry10/native/pim_contacts_qt.hpp | 148 -- .../native/simulator/libpimcontacts.so | Bin 265964 -> 0 bytes .../src/blackberry10/native/x86/Makefile | 8 - .../src/blackberry10/native/x86/so/Makefile | 1 - .../blackberry10/native/x86/so/libpimcontacts.so | Bin 265964 -> 0 bytes .../bin/test/cordova/integration/create.js | 20 +- .../bin/test/cordova/unit/spec/lib/bar-builder.js | 10 +- .../bin/test/cordova/unit/spec/lib/file-manager.js | 119 +- .../bin/test/plugins/Accelerometer/index.js | 2 +- blackberry10/bin/test/plugins/Battery/index.js | 2 +- blackberry10/bin/test/plugins/Camera/index.js | 2 +- blackberry10/bin/test/plugins/Device/index.js | 2 +- blackberry10/bin/test/plugins/Logger/index.js | 2 +- .../bin/test/plugins/NetworkStatus/index.js | 2 +- .../bin/test/plugins/Notification/index.js | 2 +- .../bin/test/plugins/SplashScreen/index.js | 2 +- blackberry10/framework/bootstrap/wwe | 2 - blackberry10/package.json | 14 +- blackberry10/plugins/Accelerometer/plugin.xml | 30 + .../Accelerometer/src/blackberry10/index.js | 45 + blackberry10/plugins/Battery/plugin.xml | 30 + .../plugins/Battery/src/blackberry10/index.js | 58 + blackberry10/plugins/Camera/plugin.xml | 30 + .../plugins/Camera/src/blackberry10/index.js | 124 ++ blackberry10/plugins/Contacts/plugin.xml | 29 + .../Contacts/src/blackberry10/ContactActivity.js | 26 + .../Contacts/src/blackberry10/ContactAddress.js | 30 + .../Contacts/src/blackberry10/ContactError.js | 30 + .../Contacts/src/blackberry10/ContactField.js | 27 + .../src/blackberry10/ContactFindOptions.js | 50 + .../Contacts/src/blackberry10/ContactName.js | 39 + .../Contacts/src/blackberry10/ContactNews.js | 26 + .../src/blackberry10/ContactOrganization.js | 22 + .../Contacts/src/blackberry10/ContactPhoto.js | 23 + .../Contacts/src/blackberry10/contactConsts.js | 225 ++ .../Contacts/src/blackberry10/contactUtils.js | 223 ++ .../plugins/Contacts/src/blackberry10/index.js | 374 ++++ blackberry10/plugins/Device/plugin.xml | 30 + .../plugins/Device/src/blackberry10/index.js | 60 + blackberry10/plugins/Logger/plugin.xml | 30 + .../plugins/Logger/src/blackberry10/index.js | 25 + blackberry10/plugins/NetworkStatus/plugin.xml | 30 + .../NetworkStatus/src/blackberry10/index.js | 59 + blackberry10/plugins/Notification/plugin.xml | 30 + .../plugins/Notification/src/blackberry10/index.js | 91 + blackberry10/plugins/SplashScreen/plugin.xml | 30 + .../plugins/SplashScreen/src/blackberry10/index.js | 28 + .../plugins/com.blackberry.jpps/plugin.xml | 30 + .../src/blackberry10/native/device/libjpps.so | Bin 0 -> 138046 bytes .../src/blackberry10/native/simulator/libjpps.so | Bin 0 -> 224392 bytes .../plugins/com.blackberry.utils/plugin.xml | 30 + .../src/blackberry10/native/device/libutils.so | Bin 0 -> 130206 bytes .../src/blackberry10/native/simulator/libutils.so | Bin 0 -> 183184 bytes .../plugin.xml | 23 + .../src/blackberry10/native/Makefile | 8 + .../src/blackberry10/native/arm/Makefile | 8 + .../src/blackberry10/native/arm/so.le-v7/Makefile | 1 + .../native/arm/so.le-v7/libpimcontacts.so | Bin 0 -> 170350 bytes .../src/blackberry10/native/common.mk | 18 + .../src/blackberry10/native/contact_account.cpp | 74 + .../src/blackberry10/native/contact_account.hpp | 54 + .../blackberry10/native/device/libpimcontacts.so | Bin 0 -> 170350 bytes .../src/blackberry10/native/pim_contacts_js.cpp | 174 ++ .../src/blackberry10/native/pim_contacts_js.hpp | 45 + .../src/blackberry10/native/pim_contacts_qt.cpp | 1611 +++++++++++++++ .../src/blackberry10/native/pim_contacts_qt.hpp | 148 ++ .../native/simulator/libpimcontacts.so | Bin 0 -> 265964 bytes .../src/blackberry10/native/x86/Makefile | 8 + .../src/blackberry10/native/x86/so/Makefile | 1 + .../blackberry10/native/x86/so/libpimcontacts.so | Bin 0 -> 265964 bytes 128 files changed, 4458 insertions(+), 4492 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/create.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/create.js b/blackberry10/bin/create.js index 14ee608..f2fc296 100644 --- a/blackberry10/bin/create.js +++ b/blackberry10/bin/create.js @@ -28,141 +28,149 @@ var build, path = require("path"), fs = require("fs"), wrench = require("wrench"), - jWorkflow = require("jWorkflow"), utils = require(path.join(__dirname, 'lib/utils')), version = getVersion(), project_path = process.argv[2], app_id = process.argv[3], bar_name = process.argv[4], - template_project_dir = path.join(__dirname, "templates", "project"), - modules_project_dir = path.join(__dirname, "..", "node_modules"), - framework_project_dir = path.join(__dirname, "..", "framework"), - build_dir = path.join(__dirname, "build"), + TARGETS = ["device", "simulator"], + TEMPLATE_PROJECT_DIR = path.join(__dirname, "templates", "project"), + MODULES_PROJECT_DIR = path.join(__dirname, "..", "node_modules"), + BOOTSTRAP_PROJECT_DIR = path.join(__dirname, "..", "framework", "bootstrap"), + FRAMEWORK_LIB_PROJECT_DIR = path.join(__dirname, "..", "framework", "lib"), + BUILD_DIR = path.join(__dirname, "build"), + CORDOVA_JS_SRC = path.join(__dirname, "..", "javascript", "cordova.blackberry10.js"), update_dir = path.join(project_path, "lib", "cordova." + version), - js_src = path.join(__dirname, "..", "javascript"), + native_dir = path.join(project_path, "native"), js_path = "javascript", js_basename = "cordova-" + version + ".js"; - function getVersion() { - var version = fs.readFileSync(__dirname + "/../VERSION"); - if (version) { - return version.toString().replace( /([^\x00-\xFF]|\s)*$/g, '' );//.replace("[^\u0000-\u007F]", ""); //.replace(/\W\./g, ''); - } +function getVersion() { + var version = fs.readFileSync(__dirname + "/../VERSION"); + if (version) { + return version.toString().replace( /([^\x00-\xFF]|\s)*$/g, '' );//.replace("[^\u0000-\u007F]", ""); //.replace(/\W\./g, ''); } +} - function validate() { - if (!project_path) { - throw "You must give a project PATH"; - } - if (fs.existsSync(project_path)) { - throw "The project path must be an empty directory"; - } - if (!validPackageName(app_id)) { - throw "App ID must be sequence of alpha-numeric (optionally seperated by '.') characters, no longer than 50 characters"; - } - if (!validBarName(bar_name)) { - throw "BAR filename can only contain alpha-numeric, '.', '-' and '_' characters"; +function validPackageName(packageName) { + var domainRegex = /^[a-zA-Z]([a-zA-Z0-9])*(\.[a-zA-Z]([a-zA-Z0-9])*)*$/; + if (typeof packageName !== "undefined") { + if ((packageName.length > 50) || !domainRegex.test(packageName)) { + return false; } } + return true; +} - function validPackageName(packageName) { - var domainRegex = /^[a-zA-Z]([a-zA-Z0-9])*(\.[a-zA-Z]([a-zA-Z0-9])*)*$/; - if (typeof packageName !== "undefined") { - if ((packageName.length > 50) || !domainRegex.test(packageName)) { - return false; - } - } - return true; - } +function validBarName(barName) { + var barNameRegex = /^[a-zA-Z0-9._\-]+$/; + return (typeof barName === "undefined") || barNameRegex.test(barName); +} - function validBarName(barName) { - var barNameRegex = /^[a-zA-Z0-9._-]+$/; - return (typeof barName === "undefined") || barNameRegex.test(barName); +function validate() { + if (!project_path) { + throw "You must give a project PATH"; } - - function clean() { - if (fs.existsSync(build_dir)) { - wrench.rmdirSyncRecursive(build_dir); - } + if (fs.existsSync(project_path)) { + throw "The project path must be an empty directory"; } - - function copyJavascript() { - wrench.mkdirSyncRecursive(build_dir + "/" + js_path, 0777); - utils.copyFile(path.join(js_src, "cordova.blackberry10.js"), path.join(build_dir, js_path)); - - //rename copied cordova.blackberry10.js file - fs.renameSync(path.join(build_dir, js_path, "cordova.blackberry10.js"), path.join(build_dir, js_path, js_basename)); + if (!validPackageName(app_id)) { + throw "App ID must be sequence of alpha-numeric (optionally seperated by '.') characters, no longer than 50 characters"; } - - function copyFilesToProject() { - // create project using template directory - wrench.mkdirSyncRecursive(project_path, 0777); - wrench.copyDirSyncRecursive(template_project_dir, project_path); - - // change file permission for cordova scripts because ant copy doesn't preserve file permissions - wrench.chmodSyncRecursive(project_path + "/cordova", 0700); - - //copy cordova-*version*.js to www - utils.copyFile(path.join(build_dir, js_path, js_basename), path.join(project_path, "www")); - - //copy node modules to cordova build directory - wrench.mkdirSyncRecursive(project_path + "/cordova/node_modules", 0777); - wrench.copyDirSyncRecursive(modules_project_dir, path.join(project_path, "cordova", "node_modules")); - fs.chmodSync(project_path + "/cordova/node_modules/plugman/plugman.js", 0755); - - //copy framework - wrench.copyDirSyncRecursive(framework_project_dir, path.join(project_path, "cordova", "framework")); - - // save release - wrench.mkdirSyncRecursive(update_dir, 0777); - wrench.copyDirSyncRecursive(build_dir, update_dir); + if (!validBarName(bar_name)) { + throw "BAR filename can only contain alpha-numeric, '.', '-' and '_' characters"; } +} - function updateProject() { - var projectJson, - xmlString, - configXMLPath = path.resolve(project_path + "/www/config.xml"); - - if (typeof app_id !== "undefined") { - xmlString = fs.readFileSync(configXMLPath, "utf-8"); - fs.writeFileSync(configXMLPath, xmlString.replace("default.app.id", app_id), "utf-8"); - } - - if (typeof bar_name !== "undefined") { - projectJson = require(path.resolve(project_path + "/project.json")); - projectJson.barName = bar_name; - fs.writeFileSync(path.join(project_path, "project.json"), JSON.stringify(projectJson, null, 4) + "\n", "utf-8"); - } +function clean() { + if (fs.existsSync(BUILD_DIR)) { + wrench.rmdirSyncRecursive(BUILD_DIR); + } +} + +function copyJavascript() { + wrench.mkdirSyncRecursive(BUILD_DIR + "/" + js_path, 0777); + utils.copyFile(CORDOVA_JS_SRC, path.join(BUILD_DIR, js_path)); + + //rename copied cordova.blackberry10.js file + fs.renameSync(path.join(BUILD_DIR, js_path, "cordova.blackberry10.js"), path.join(BUILD_DIR, js_path, js_basename)); +} + +function copyFilesToProject() { + var nodeModulesDest = path.join(project_path, "cordova", "node_modules"); + + // create project using template directory + wrench.mkdirSyncRecursive(project_path, 0777); + wrench.copyDirSyncRecursive(TEMPLATE_PROJECT_DIR, project_path); + + // change file permission for cordova scripts because ant copy doesn't preserve file permissions + wrench.chmodSyncRecursive(project_path + "/cordova", 0700); + + //copy cordova-*version*.js to www + utils.copyFile(path.join(BUILD_DIR, js_path, js_basename), path.join(project_path, "www")); + + //copy node modules to cordova build directory + wrench.mkdirSyncRecursive(nodeModulesDest, 0777); + wrench.copyDirSyncRecursive(MODULES_PROJECT_DIR, nodeModulesDest); + //change permissions of plugman + fs.chmodSync(path.join(nodeModulesDest, "plugman", "main.js"), 0755); + + //copy framework bootstrap + TARGETS.forEach(function (target) { + var chromeDir = path.join(native_dir, target, "chrome"), + frameworkLibDir = path.join(chromeDir, "lib"); + + wrench.mkdirSyncRecursive(frameworkLibDir); + wrench.copyDirSyncRecursive(BOOTSTRAP_PROJECT_DIR, chromeDir); + wrench.copyDirSyncRecursive(FRAMEWORK_LIB_PROJECT_DIR, frameworkLibDir); + }); + + // save release + wrench.mkdirSyncRecursive(update_dir, 0777); + wrench.copyDirSyncRecursive(BUILD_DIR, update_dir); +} + +function updateProject() { + var projectJson = require(path.resolve(project_path + "/project.json")), + configXMLPath = path.resolve(project_path + "/www/config.xml"), + xmlString; + + if (typeof app_id !== "undefined") { + xmlString = fs.readFileSync(configXMLPath, "utf-8"); + fs.writeFileSync(configXMLPath, xmlString.replace("default.app.id", app_id), "utf-8"); } - function done(error) { - if (error) { - console.log("Project creation failed!\n" + "Error: " + error); - process.exit(1); - } - else { - process.exit(); - } + if (typeof bar_name !== "undefined") { + projectJson.barName = bar_name; } - if ( process.argv[2] === "-h" || process.argv[2] === "--help" ) { - console.log("\nUsage: create <project path> [package name [BAR filename]] \n"); - console.log("Options: \n"); - console.log(" -h, --help output usage information \n"); - } else { - try { - build = jWorkflow.order(validate) - .andThen(clean) - .andThen(copyJavascript) - .andThen(copyFilesToProject) - .andThen(updateProject) - .andThen(clean); - - build.start(function (error) { - done(error); - }); - } catch (ex) { - console.log(ex); - } + projectJson.globalFetchDir = path.join(__dirname, "..", "plugins"); + + fs.writeFileSync(path.join(project_path, "project.json"), JSON.stringify(projectJson, null, 4) + "\n", "utf-8"); +} + +function installPlugins() { + var pluginScript = path.resolve(__dirname, "..", path.join(project_path, "cordova", "lib", "plugin.js")); + require(pluginScript).add(path.join(__dirname, "..", "plugins")); +} + +if ( process.argv[2] === "-h" || process.argv[2] === "--help" ) { + console.log("\nUsage: create <project path> [package name [BAR filename]] \n"); + console.log("Options: \n"); + console.log(" -h, --help output usage information \n"); +} else { + try { + validate(); + clean(); + copyJavascript(); + copyFilesToProject(); + updateProject(); + installPlugins(); + clean(); + process.exit(); + } catch (ex) { + console.log("Project creation failed!\n" + "Error: " + ex); + process.exit(1); } +} http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/cordova/lib/bar-builder.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/bar-builder.js b/blackberry10/bin/templates/project/cordova/lib/bar-builder.js index e1be25c..0a955f9 100644 --- a/blackberry10/bin/templates/project/cordova/lib/bar-builder.js +++ b/blackberry10/bin/templates/project/cordova/lib/bar-builder.js @@ -33,18 +33,16 @@ function buildTarget(previous, baton) { //Create output folder wrench.mkdirSyncRecursive(session.outputDir + "/" + target); - //Copy target dependent files - fileManager.copyWWE(this.session, target); - fileManager.copyWebplatform(this.session, target); + //Copy resources (could be lost if copying assets from other project) + fileManager.copyNative(this.session, target); + //Generate user config here to overwrite default + fileManager.generateUserConfig(session, config); if (config.packageCordovaJs) { //Package cordova.js to chrome folder fileManager.copyWebworks(this.session); } - fileManager.copyJnextDependencies(this.session); - fileManager.copyExtensions(this.session, target); - //Generate frameworkModules.js (this needs to be done AFTER all files have been copied) fileManager.generateFrameworkModulesJS(session); @@ -87,7 +85,7 @@ module.exports = { build: function (session, config, callback) { var context = { session: session, - config: config, + config: config }, workflow = buildWorkflow(session, context); http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/cordova/lib/conf.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/conf.js b/blackberry10/bin/templates/project/cordova/lib/conf.js index 75c47a8..89f8372 100644 --- a/blackberry10/bin/templates/project/cordova/lib/conf.js +++ b/blackberry10/bin/templates/project/cordova/lib/conf.js @@ -30,6 +30,8 @@ function getToolsDir() { module.exports = { ROOT: path.normalize(__dirname + "/../framework"), PROJECT_ROOT: path.normalize(__dirname + "/../../"), + NATIVE: path.normalize(__dirname + "/../../native"), + JNEXT_AUTH: path.normalize(__dirname + "/../../native/plugins/jnext/auth.txt"), BIN: path.normalize(__dirname + "/../framework/bin"), LIB: path.normalize(__dirname + "/../framework/lib"), EXT: path.normalize(__dirname + "/../../plugins"), http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/cordova/lib/file-manager.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/file-manager.js b/blackberry10/bin/templates/project/cordova/lib/file-manager.js index 5f37894..835ead6 100755 --- a/blackberry10/bin/templates/project/cordova/lib/file-manager.js +++ b/blackberry10/bin/templates/project/cordova/lib/file-manager.js @@ -84,28 +84,6 @@ function prepare(session) { wrench.rmdirSyncRecursive(session.sourceDir); } - if (!fs.existsSync(dest.CHROME)) { - wrench.mkdirSyncRecursive(dest.CHROME, "0755"); - } - - // copy bootstrap as well as ui.html file - wrench.copyDirSyncRecursive(conf.DEPENDENCIES_BOOTSTRAP, dest.CHROME); - - if (!fs.existsSync(dest.LIB)) { - wrench.mkdirSyncRecursive(dest.LIB, "0755"); - } - - // copy framework - wrench.copyDirSyncRecursive(conf.LIB, dest.LIB); - - // Copy the ui-resources if they exist - if (fs.existsSync(conf.UI)) { - if (!fs.existsSync(dest.UI)) { - wrench.mkdirSyncRecursive(dest.UI, "0755"); - } - wrench.copyDirSyncRecursive(conf.UI, dest.UI); - } - // unzip archive if (fs.existsSync(session.archivePath)) { if (session.archivePath.toLowerCase().match("[.]zip$")) { @@ -171,27 +149,11 @@ function generateFrameworkModulesJS(session) { fs.writeFileSync(path.normalize(dest.CHROME + "/frameworkModules.js"), frameworkModulesStr + modulesStr); } -function copyWWE(session, target) { - var src = path.normalize(session.conf.DEPENDENCIES_BOOTSTRAP + "/wwe"), +function copyNative(session, target) { + var src = path.normalize(session.conf.NATIVE + "/" + target), dest = path.normalize(session.sourceDir); - packagerUtils.copyFile(src, dest); -} - -function copyWebplatform(session, target) { - - var wpSrc = path.normalize(session.conf.ROOT + "/webplatform.js"), - dest = path.normalize(session.sourceDir), - i18nSrc = path.normalize(session.conf.ROOT + "/i18n.js"); - - if (fs.existsSync(wpSrc)) { - logger.warn(localize.translate("WARN_WEBPLATFORM_JS_PACKAGED")); - packagerUtils.copyFile(wpSrc, dest); - } - if (fs.existsSync(i18nSrc)) { - logger.warn(localize.translate("WARN_WEBPLATFORM_I18N_PACKAGED")); - packagerUtils.copyFile(i18nSrc, dest); - } + copyDirContents(src, dest); } function copyWebworks(session) { @@ -213,95 +175,29 @@ function copyWebworks(session) { } } - -function copyJnextDependencies(session) { - var conf = session.conf, - dest = path.normalize(session.sourcePaths.JNEXT_PLUGINS), - data = "local:/// *\nfile:// *\nhttp:// *"; - - if (!fs.existsSync(dest)) { - wrench.mkdirSyncRecursive(dest, "0755"); - } - - //write auth.txt jnext file - fs.writeFileSync(path.join(dest, "auth.txt"), data); -} - function hasValidExtension(file) { return VALID_EXTENSIONS.some(function (element, index, array) { return path.extname(file) === element; }); } -function copyExtension(session, target, pluginPath) { - var basename = path.basename(pluginPath), - pluginSrcPath = path.join(pluginPath, "src", "blackberry10"), - extDest = session.sourcePaths.EXT, - soDest = session.sourcePaths.JNEXT_PLUGINS, - soPath = path.normalize(path.join(pluginSrcPath, "native", target)), - jsFiles, - soFiles; - - if (fs.existsSync(pluginSrcPath) && fs.statSync(pluginSrcPath).isDirectory()) { - //create output folders - wrench.mkdirSyncRecursive(path.join(extDest, basename), "0755"); - wrench.mkdirSyncRecursive(soDest, "0755"); - - //find all .js and .json files - jsFiles = packagerUtils.listFiles(pluginSrcPath, function (file) { - return hasValidExtension(file); - }); - - //Copy each .js file to its extensions folder - jsFiles.forEach(function (jsFile) { - packagerUtils.copyFile(jsFile, path.join(extDest, basename), pluginSrcPath); - }); - - if (fs.existsSync(soPath)) { - //find all .so files - soFiles = packagerUtils.listFiles(soPath, function (file) { - return path.extname(file) === ".so"; - }); - - //Copy each .so file to the extensions folder - soFiles.forEach(function (soFile) { - packagerUtils.copyFile(soFile, soDest); - }); - } - } -} - -function copyExtensions(session, target) { - var pluginDir = session.conf.EXT; - - if (fs.existsSync(pluginDir)) { - // just read the top-level dirs under "plugin" - fs.readdirSync(pluginDir).forEach(function (plugin) { - copyExtension(session, target, path.join(pluginDir, plugin)); - }); - - } - - +function generateUserConfig(session, config) { + packagerUtils.writeFile(path.join(session.sourcePaths.LIB, "config"), "user.js", "module.exports = " + JSON.stringify(config, null, " ") + ";"); } module.exports = { unzip: unzip, - copyWWE: copyWWE, - - copyWebplatform: copyWebplatform, + copyNative: copyNative, copyWebworks : copyWebworks, - copyJnextDependencies: copyJnextDependencies, - prepareOutputFiles: prepare, - copyExtensions: copyExtensions, - generateFrameworkModulesJS: generateFrameworkModulesJS, + generateUserConfig: generateUserConfig, + cleanSource: function (session) { if (!session.keepSource) { wrench.rmdirSyncRecursive(session.sourceDir); http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/cordova/lib/packager.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/packager.js b/blackberry10/bin/templates/project/cordova/lib/packager.js index ae73dae..01541ac 100644 --- a/blackberry10/bin/templates/project/cordova/lib/packager.js +++ b/blackberry10/bin/templates/project/cordova/lib/packager.js @@ -50,7 +50,6 @@ module.exports = { logger.log(localize.translate("PROGRESS_GEN_OUTPUT")); //Adding debuEnabled property to user.js. Framework will enable/disable WebInspector based on that variable. configObj.debugEnabled = session.debug; - packagerUtils.writeFile(path.join(session.sourcePaths.LIB, "config"), "user.js", "module.exports = " + JSON.stringify(configObj, null, " ") + ";"); barBuilder.build(session, configObj, function (code) { fileManager.cleanSource(session); http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/cordova/lib/plugin.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/lib/plugin.js b/blackberry10/bin/templates/project/cordova/lib/plugin.js new file mode 100644 index 0000000..8fab05b --- /dev/null +++ b/blackberry10/bin/templates/project/cordova/lib/plugin.js @@ -0,0 +1,193 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 path = require("path"), + shell = require('shelljs'), + wrench = require("wrench"), + fs = require('fs'), + et = require('elementtree'), + PROJECT_ROOT = path.join(__dirname, "..", ".."), + PLUGMAN = path.join(PROJECT_ROOT, "cordova", "node_modules", "plugman", "main.js"), + GLOBAL_PLUGIN_PATH = require(path.join(PROJECT_ROOT, "project.json")).globalFetchDir, + LOCAL_PLUGIN_PATH = path.join(PROJECT_ROOT, "plugins"), + argumentor = { + action : process.argv[2], + plugin: process.argv[3], + args: [], + reset: function () { + this.args = []; + return argumentor; + }, + setAction: function () { + this.args.push("--" + this.action); + return argumentor; + }, + setPlatform: function () { + this.args.push("--platform"); + this.args.push("blackberry10"); + return argumentor; + }, + setProject: function () { + this.args.push("--project"); + this.args.push(PROJECT_ROOT); + return argumentor; + }, + setPlugin: function () { + var pluginWithoutTrailingSlash = this.plugin.charAt(this.plugin.length - 1) === "/" ? this.plugin.slice(0, -1) : this.plugin; + this.args.push("--plugin"); + this.args.push(pluginWithoutTrailingSlash); + return argumentor; + }, + setPluginsDir: function (isGlobal) { + this.args.push("--plugins_dir"); + if (isGlobal) { + this.args.push(GLOBAL_PLUGIN_PATH); + } else { + this.args.push(LOCAL_PLUGIN_PATH); + } + return argumentor; + }, + run: function () { + var cmd = PLUGMAN + " " + this.args.join(" "); + return shell.exec(cmd, {silent: false}); + } + }, + plugmanInterface= { + "uninstall": function (plugin) { + if (plugin) { + argumentor.plugin = plugin; + } + argumentor.action = "uninstall"; + argumentor.reset().setAction().setPlatform().setProject().setPlugin().setPluginsDir().run(); + }, + "install": function (plugin) { + if (plugin) { + argumentor.plugin = plugin; + } + argumentor.reset().setPlatform().setProject().setPlugin().setPluginsDir().run(); + } + }; + +function getPluginId(pluginXMLPath) { + var pluginEt = new et.ElementTree(et.XML(fs.readFileSync(pluginXMLPath, "utf-8"))); + return pluginEt._root.attrib.id; +} + +function addPlugin (pluginPath) { + var plugin = pluginPath || argumentor.plugin, + pluginDirs = [], + allFiles; + + //Check if the path they sent in exists + if (!fs.existsSync(plugin) ) { + //Check if the plugin has been fetched globally + plugin = path.resolve(GLOBAL_PLUGIN_PATH, plugin); + if (!fs.existsSync(plugin)) { + console.log("Input ", pluginPath || argumentor.plugin, " cannot be resolved as a plugin"); + process.exit(1); + } + } + + allFiles = wrench.readdirSyncRecursive(plugin); + allFiles.forEach(function (file) { + var fullPath = path.resolve(plugin, file); + + if (path.basename(file) === "plugin.xml") { + pluginDirs.push(path.dirname(fullPath)); + } + }); + + if (!pluginDirs.length) { + console.log("No plugins could be found given the input " + pluginPath || argumentor.plugin); + process.exit(1); + } else { + pluginDirs.forEach(function (pluginDir) { + plugmanInterface.install(pluginDir); + }); + } +} + +function removePlugin (pluginPath) { + var plugin = pluginPath || argumentor.plugin, + pluginIds = [], + allFiles; + + //Check if the path they send in exists + if (!fs.existsSync(plugin) ) { + //Check if it is the folder name of an installed plugin + plugin = path.resolve(LOCAL_PLUGIN_PATH, plugin); + if (!fs.existsSync(plugin)) { + //Assume that this is a plugin id and continue + plugin = pluginPath || argumentor.plugin; + } + } + + allFiles = wrench.readdirSyncRecursive(plugin); + allFiles.forEach(function (file) { + var fullPath = path.resolve(plugin, file), + pluginEt; + + if (path.basename(file) === "plugin.xml") { + pluginIds.push(getPluginId(fullPath)); + } + }); + + pluginIds.forEach(function (pluginId) { + plugmanInterface.uninstall(pluginId); + }); + +} + +function listPlugins () { + fs.readdirSync(LOCAL_PLUGIN_PATH).forEach(function (pluginName) { + //TODO: Parse the plugin.xml and get any extra information ie description + console.log(pluginName); + }); +} + +function listHelp () { + console.log("\nUsage:"); + console.log("add <plugin_dir> Adds all plugins contained in the given directory"); + console.log("rm <plugin_name> [<plugin_name>] Removes all of the listed plugins"); + console.log("ls Lists all of the currently installed plugins"); +} + +function cliEntry () { + switch (argumentor.action) { + case "add": + addPlugin(); + break; + case "rm": + removePlugin(); + break; + case "ls": + listPlugins(); + break; + default: + listHelp(); + } +} + +module.exports = { + add: addPlugin, + rm: removePlugin, + ls: listPlugins, + help: listHelp, + cli: cliEntry +}; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/cordova/plugin ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/cordova/plugin b/blackberry10/bin/templates/project/cordova/plugin index ae261b5..010649b 100755 --- a/blackberry10/bin/templates/project/cordova/plugin +++ b/blackberry10/bin/templates/project/cordova/plugin @@ -19,52 +19,5 @@ * under the License. */ -var action = process.argv[2], - plugin = process.argv[3], - PLUGMAN = require("path").join(__dirname, "node_modules", "plugman", "main.js"), - argumentor = { - argIndex: 2, - setAction: function () { - process.argv[this.argIndex++] = "--" + action; - return argumentor; - }, - setPlatform: function () { - process.argv[this.argIndex++] = "--platform"; - process.argv[this.argIndex++] = "blackberry10"; - return argumentor; - }, - setProject: function () { - process.argv[this.argIndex++] = "--project"; - process.argv[this.argIndex++] = "."; - return argumentor; - }, - setPlugin: function () { - process.argv[this.argIndex++] = "--plugin"; - process.argv[this.argIndex++] = plugin.charAt(plugin.length - 1) === "/" ? plugin.slice(0, -1) : plugin; - return argumentor; - }, - setPluginsDir: function () { - process.argv[this.argIndex++] = "--plugins_dir"; - process.argv[this.argIndex++] = "./plugins"; - return argumentor; - } - }; +require(require("path").join(__dirname, "lib", "plugin.js")).cli(); -switch(action) { - case "uninstall": - argumentor.setAction(); - case "install": - argumentor.setPlatform().setProject().setPlugin().setPluginsDir(); - break; - case "fetch": - case "remove": - argumentor.setAction().setPlugin().setPluginsDir(); - break; - case "prepare": - argumentor.setAction().setPlatform().setProject().setPluginsDir(); - break; - case "list": - argumentor.setAction(); -} - -require(PLUGMAN); http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/native/device/plugins/jnext/auth.txt ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/native/device/plugins/jnext/auth.txt b/blackberry10/bin/templates/project/native/device/plugins/jnext/auth.txt new file mode 100644 index 0000000..0983f4f --- /dev/null +++ b/blackberry10/bin/templates/project/native/device/plugins/jnext/auth.txt @@ -0,0 +1,3 @@ +local:/// * +file:// * +http:// * \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/native/device/wwe ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/native/device/wwe b/blackberry10/bin/templates/project/native/device/wwe new file mode 100644 index 0000000..0e48b92 --- /dev/null +++ b/blackberry10/bin/templates/project/native/device/wwe @@ -0,0 +1,2 @@ +#!/bin/sh +exec weblauncher "$@" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/native/simulator/plugins/jnext/auth.txt ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/native/simulator/plugins/jnext/auth.txt b/blackberry10/bin/templates/project/native/simulator/plugins/jnext/auth.txt new file mode 100644 index 0000000..0983f4f --- /dev/null +++ b/blackberry10/bin/templates/project/native/simulator/plugins/jnext/auth.txt @@ -0,0 +1,3 @@ +local:/// * +file:// * +http:// * \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/native/simulator/wwe ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/native/simulator/wwe b/blackberry10/bin/templates/project/native/simulator/wwe new file mode 100644 index 0000000..0e48b92 --- /dev/null +++ b/blackberry10/bin/templates/project/native/simulator/wwe @@ -0,0 +1,2 @@ +#!/bin/sh +exec weblauncher "$@" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Accelerometer/plugin.xml ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Accelerometer/plugin.xml b/blackberry10/bin/templates/project/plugins/Accelerometer/plugin.xml deleted file mode 100644 index bc5c712..0000000 --- a/blackberry10/bin/templates/project/plugins/Accelerometer/plugin.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. - ---> - -<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" - id="org.apache.cordova.core" - version="0.0.1"> - - <name>Accelerometer</name> - - <platform name="blackberry10"> - <config-file target="www/config.xml" parent="/widget"> - <feature name="Acceleromter" value="Accelerometer"/> - </config-file> - </platform> -</plugin> http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Accelerometer/src/blackberry10/index.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Accelerometer/src/blackberry10/index.js b/blackberry10/bin/templates/project/plugins/Accelerometer/src/blackberry10/index.js deleted file mode 100644 index 47abe42..0000000 --- a/blackberry10/bin/templates/project/plugins/Accelerometer/src/blackberry10/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 callback; - -module.exports = { - start: function (success, fail, args, env) { - var result = new PluginResult(args, env); - window.removeEventListener("devicemotion", callback); - callback = function (motion) { - var info = { - x: motion.accelerationIncludingGravity.x, - y: motion.accelerationIncludingGravity.y, - z: motion.accelerationIncludingGravity.z, - timestamp: motion.timestamp - }; - result.callbackOk(info, true); - }; - window.addEventListener("devicemotion", callback); - result.noResult(true); - }, - stop: function (success, fail, args, env) { - var result = new PluginResult(args, env); - window.removeEventListener("devicemotion", callback); - result.ok("removed"); - } -}; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Battery/plugin.xml ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Battery/plugin.xml b/blackberry10/bin/templates/project/plugins/Battery/plugin.xml deleted file mode 100644 index 242ff4a..0000000 --- a/blackberry10/bin/templates/project/plugins/Battery/plugin.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. - ---> - -<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" - id="org.apache.cordova.core" - version="0.0.1"> - - <name>Battery</name> - - <platform name="blackberry10"> - <config-file target="www/config.xml" parent="/widget"> - <feature name="Battery" value="Battery"/> - </config-file> - </platform> -</plugin> http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Battery/src/blackberry10/index.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Battery/src/blackberry10/index.js b/blackberry10/bin/templates/project/plugins/Battery/src/blackberry10/index.js deleted file mode 100644 index 07a943c..0000000 --- a/blackberry10/bin/templates/project/plugins/Battery/src/blackberry10/index.js +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2010-2011 Research In Motion 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 SYSTEM_EVENTS = ["device.battery.statusChange", - "device.battery.chargeLow", - "device.battery.chargeCritical"], - device = window.qnx.webplatform.device, - _clientListeners = {}; - -module.exports = { - start: function (success, fail, args, env) { - var result = new PluginResult(args, env), - listener = function (info) { - result.callbackOk(info, true); - }; - - if (_clientListeners[env.webview.id]) { - //TODO: Change back to erroring out after reset is implemented - //result.error("Battery listener already running"); - SYSTEM_EVENTS.forEach(function (event) { - device.removeEventListener(event, _clientListeners[env.webview.id]); - }); - } - - _clientListeners[env.webview.id] = listener; - SYSTEM_EVENTS.forEach(function (event) { - device.addEventListener(event, listener); - }); - result.noResult(true); - }, - stop: function (success, fail, args, env) { - var result = new PluginResult(args, env), - listener = _clientListeners[env.webview.id]; - - if (!listener) { - result.error("Battery listener has not started"); - } else { - SYSTEM_EVENTS.forEach(function (event) { - device.removeEventListener(event, listener); - }); - delete _clientListeners[env.webview.id]; - result.noResult(false); - } - } -}; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Camera/plugin.xml ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Camera/plugin.xml b/blackberry10/bin/templates/project/plugins/Camera/plugin.xml deleted file mode 100644 index a5df260..0000000 --- a/blackberry10/bin/templates/project/plugins/Camera/plugin.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. - ---> - -<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" - id="org.apache.cordova.core" - version="0.0.1"> - - <name>Camera</name> - - <platform name="blackberry10"> - <config-file target="www/config.xml" parent="/widget"> - <feature name="Camera" value="Camera"/> - </config-file> - </platform> -</plugin> http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Camera/src/blackberry10/index.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Camera/src/blackberry10/index.js b/blackberry10/bin/templates/project/plugins/Camera/src/blackberry10/index.js deleted file mode 100644 index 922f049..0000000 --- a/blackberry10/bin/templates/project/plugins/Camera/src/blackberry10/index.js +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2010-2011 Research In Motion 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 PictureSourceType = { - PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android) - CAMERA : 1, // Take picture from camera - SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android) - }, - DestinationType = { - DATA_URL: 0, // Return base64 encoded string - FILE_URI: 1, // Return file uri (content://media/external/images/media/2 for Android) - NATIVE_URI: 2 // Return native uri (eg. asset-library://... for iOS) - }; - -function encodeBase64(filePath, callback) { - var sandbox = window.qnx.webplatform.getController().setFileSystemSandbox, // save original sandbox value - errorHandler = function (err) { - var msg = "An error occured: "; - - switch (err.code) { - case FileError.NOT_FOUND_ERR: - msg += "File or directory not found"; - break; - - case FileError.NOT_READABLE_ERR: - msg += "File or directory not readable"; - break; - - case FileError.PATH_EXISTS_ERR: - msg += "File or directory already exists"; - break; - - case FileError.TYPE_MISMATCH_ERR: - msg += "Invalid file type"; - break; - - default: - msg += "Unknown Error"; - break; - }; - - // set it back to original value - window.qnx.webplatform.getController().setFileSystemSandbox = sandbox; - callback(msg); - }, - gotFile = function (fileEntry) { - fileEntry.file(function (file) { - var reader = new FileReader(); - - reader.onloadend = function (e) { - // set it back to original value - window.qnx.webplatform.getController().setFileSystemSandbox = sandbox; - callback(this.result); - }; - - reader.readAsDataURL(file); - }, errorHandler); - }, - onInitFs = function (fs) { - window.qnx.webplatform.getController().setFileSystemSandbox = false; - fs.root.getFile(filePath, {create: false}, gotFile, errorHandler); - }; - - window.webkitRequestFileSystem(window.TEMPORARY, 10 * 1024 * 1024, onInitFs, errorHandler); // set size to 10MB max -} - -module.exports = { - takePicture: function (success, fail, args, env) { - var destinationType = JSON.parse(decodeURIComponent(args[1])), - sourceType = JSON.parse(decodeURIComponent(args[2])), - result = new PluginResult(args, env), - done = function (data) { - if (destinationType === DestinationType.FILE_URI) { - data = "file://" + data; - result.callbackOk(data, false); - } else { - encodeBase64(data, function (data) { - if (/^data:/.test(data)) { - data = data.slice(data.indexOf(",") + 1); - result.callbackOk(data, false); - } else { - result.callbackError(data, false); - } - }); - } - }, - cancel = function (reason) { - result.callbackError(reason, false); - }, - invoked = function (error) { - if (error) { - result.callbackError(error, false); - } - }; - - switch(sourceType) { - case PictureSourceType.CAMERA: - window.qnx.webplatform.getApplication().cards.camera.open("photo", done, cancel, invoked); - break; - - case PictureSourceType.PHOTOLIBRARY: - case PictureSourceType.SAVEDPHOTOALBUM: - window.qnx.webplatform.getApplication().cards.filePicker.open({ - mode: "Picker", - type: ["picture"] - }, done, cancel, invoked); - break; - } - - result.noResult(true); - } -}; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Contacts/plugin.xml ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Contacts/plugin.xml b/blackberry10/bin/templates/project/plugins/Contacts/plugin.xml deleted file mode 100644 index 6753d29..0000000 --- a/blackberry10/bin/templates/project/plugins/Contacts/plugin.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. - ---> - -<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0" - id="org.apache.cordova.core" - version="0.0.1"> - - <name>Contacts</name> - - <platform name="blackberry10"> - <config-file target="www/config.xml" parent="/widget"> - <feature name="Contacts" value="Contacts"/> - </config-file> - </platform> -</plugin> http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactActivity.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactActivity.js b/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactActivity.js deleted file mode 100644 index 0794d23..0000000 --- a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactActivity.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2012 Research In Motion 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 ContactActivity = function (args) { - this.direction = args.direction || null; - this.description = args.description || ""; - this.mimeType = args.mimeType || ""; - this.timestamp = new Date(parseInt(args.timestamp, 10)) || null; -}; - -Object.defineProperty(ContactActivity, "INCOMING", {"value": true}); -Object.defineProperty(ContactActivity, "OUTGOING", {"value": false}); - -module.exports = ContactActivity; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactAddress.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactAddress.js b/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactAddress.js deleted file mode 100644 index 1ba9fe4..0000000 --- a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactAddress.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012 Research In Motion 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 ContactAddress = function (properties) { - this.type = properties && properties.type ? properties.type : ""; - this.streetAddress = properties && properties.streetAddress ? properties.streetAddress : ""; - this.streetOther = properties && properties.streetOther ? properties.streetOther : ""; - this.locality = properties && properties.locality ? properties.locality : ""; - this.region = properties && properties.region ? properties.region : ""; - this.postalCode = properties && properties.postalCode ? properties.postalCode : ""; - this.country = properties && properties.country ? properties.country : ""; -}; - -Object.defineProperty(ContactAddress, "HOME", {"value": "home"}); -Object.defineProperty(ContactAddress, "WORK", {"value": "work"}); -Object.defineProperty(ContactAddress, "OTHER", {"value": "other"}); - -module.exports = ContactAddress; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactError.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactError.js b/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactError.js deleted file mode 100644 index f20f85e..0000000 --- a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactError.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012 Research In Motion 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 ContactError = function (code, msg) { - this.code = code; - this.message = msg; -}; - -Object.defineProperty(ContactError, "UNKNOWN_ERROR", { "value": 0 }); -Object.defineProperty(ContactError, "INVALID_ARGUMENT_ERROR", { "value": 1 }); -Object.defineProperty(ContactError, "TIMEOUT_ERROR", { "value": 2 }); -Object.defineProperty(ContactError, "PENDING_OPERATION_ERROR", { "value": 3 }); -Object.defineProperty(ContactError, "IO_ERROR", { "value": 4 }); -Object.defineProperty(ContactError, "NOT_SUPPORTED_ERROR", { "value": 5 }); -Object.defineProperty(ContactError, "PERMISSION_DENIED_ERROR", { "value": 20 }); - -module.exports = ContactError; - http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactField.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactField.js b/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactField.js deleted file mode 100644 index aad735c..0000000 --- a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactField.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2012 Research In Motion 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 ContactField = function (type, value) { - this.type = type || ""; - this.value = value || ""; -}; - -Object.defineProperty(ContactField, "HOME", {"value": "home"}); -Object.defineProperty(ContactField, "WORK", {"value": "work"}); -Object.defineProperty(ContactField, "OTHER", {"value": "other"}); -Object.defineProperty(ContactField, "MOBILE", {"value": "mobile"}); -Object.defineProperty(ContactField, "DIRECT", {"value": "direct"}); - -module.exports = ContactField; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactFindOptions.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactFindOptions.js b/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactFindOptions.js deleted file mode 100644 index 8be830d..0000000 --- a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactFindOptions.js +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2012 Research In Motion 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. - */ - -/** - * ContactFindOptions. - * @constructor - * @param filter search fields - * @param sort sort fields and order - * @param limit max number of contacts to return - * @param favorite if set, only favorite contacts will be returned - */ - -var ContactFindOptions = function (filter, sort, limit, favorite) { - this.filter = filter || null; - this.sort = sort || null; - this.limit = limit || -1; // -1 for returning all results - this.favorite = favorite || false; - this.includeAccounts = []; - this.excludeAccounts = []; -}; - -Object.defineProperty(ContactFindOptions, "SEARCH_FIELD_GIVEN_NAME", { "value": 0 }); -Object.defineProperty(ContactFindOptions, "SEARCH_FIELD_FAMILY_NAME", { "value": 1 }); -Object.defineProperty(ContactFindOptions, "SEARCH_FIELD_ORGANIZATION_NAME", { "value": 2 }); -Object.defineProperty(ContactFindOptions, "SEARCH_FIELD_PHONE", { "value": 3 }); -Object.defineProperty(ContactFindOptions, "SEARCH_FIELD_EMAIL", { "value": 4 }); -Object.defineProperty(ContactFindOptions, "SEARCH_FIELD_BBMPIN", { "value": 5 }); -Object.defineProperty(ContactFindOptions, "SEARCH_FIELD_LINKEDIN", { "value": 6 }); -Object.defineProperty(ContactFindOptions, "SEARCH_FIELD_TWITTER", { "value": 7 }); -Object.defineProperty(ContactFindOptions, "SEARCH_FIELD_VIDEO_CHAT", { "value": 8 }); - -Object.defineProperty(ContactFindOptions, "SORT_FIELD_GIVEN_NAME", { "value": 0 }); -Object.defineProperty(ContactFindOptions, "SORT_FIELD_FAMILY_NAME", { "value": 1 }); -Object.defineProperty(ContactFindOptions, "SORT_FIELD_ORGANIZATION_NAME", { "value": 2 }); - -module.exports = ContactFindOptions; - http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactName.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactName.js b/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactName.js deleted file mode 100644 index 9b74753..0000000 --- a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactName.js +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012 Research In Motion 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. - */ - -function toFormattedName(properties) { - var formatted = ""; - if (properties && properties.givenName) { - formatted = properties.givenName; - if (properties && properties.familyName) { - formatted += " " + properties.familyName; - } - } - return formatted; -} - -var ContactName = function (properties) { - this.familyName = properties && properties.familyName ? properties.familyName : ""; - this.givenName = properties && properties.givenName ? properties.givenName : ""; - this.formatted = toFormattedName(properties); - this.middleName = properties && properties.middleName ? properties.middleName : ""; - this.honorificPrefix = properties && properties.honorificPrefix ? properties.honorificPrefix : ""; - this.honorificSuffix = properties && properties.honorificSuffix ? properties.honorificSuffix : ""; - this.phoneticFamilyName = properties && properties.phoneticFamilyName ? properties.phoneticFamilyName : ""; - this.phoneticGivenName = properties && properties.phoneticGivenName ? properties.phoneticGivenName : ""; -}; - -module.exports = ContactName; http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactNews.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactNews.js b/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactNews.js deleted file mode 100644 index 7aa9d8c..0000000 --- a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactNews.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2012 Research In Motion 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 ContactNews = function (args) { - this.title = args.title || ""; - this.body = args.body || ""; - this.articleSource = args.articleSource || ""; - this.companies = args.companies || []; - this.publishedAt = new Date(parseInt(args.publishedAt, 10)) || null; - this.uri = args.uri || ""; - this.type = args.type || ""; -}; - -module.exports = ContactNews; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactOrganization.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactOrganization.js b/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactOrganization.js deleted file mode 100644 index ecf5d0c..0000000 --- a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactOrganization.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2012 Research In Motion 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 ContactOrganization = function (properties) { - this.name = properties && properties.name ? properties.name : ""; - this.department = properties && properties.department ? properties.department : ""; - this.title = properties && properties.title ? properties.title : ""; -}; - -module.exports = ContactOrganization; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactPhoto.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactPhoto.js b/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactPhoto.js deleted file mode 100644 index 5b1c9d6..0000000 --- a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/ContactPhoto.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2012 Research In Motion 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 ContactPhoto = function (originalFilePath, pref) { - this.originalFilePath = originalFilePath || ""; - this.pref = pref || false; - this.largeFilePath = ""; - this.smallFilePath = ""; -}; - -module.exports = ContactPhoto; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/fa5a5900/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/contactConsts.js ---------------------------------------------------------------------- diff --git a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/contactConsts.js b/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/contactConsts.js deleted file mode 100644 index ef25206..0000000 --- a/blackberry10/bin/templates/project/plugins/Contacts/src/blackberry10/contactConsts.js +++ /dev/null @@ -1,225 +0,0 @@ -/* -* Copyright 2012 Research In Motion 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 ATTRIBUTE_KIND, - ATTRIBUTE_SUBKIND, - kindAttributeMap = {}, - subKindAttributeMap = {}, - _TITLE = 26, - _START_DATE = 43, - _END_DATE = 44; - -function populateKindAttributeMap() { - ATTRIBUTE_KIND = { - Invalid: 0, - Phone: 1, - Fax: 2, - Pager: 3, - Email: 4, - Website: 5, - Feed: 6, - Profile: 7, - Family: 8, - Person: 9, - Date: 10, - Group: 11, - Name: 12, - StockSymbol: 13, - Ranking: 14, - OrganizationAffiliation: 15, - Education: 16, - Note: 17, - InstantMessaging: 18, - VideoChat: 19, - ConnectionCount: 20, - Hidden: 21, - Biography: 22, - Sound: 23, - Notification: 24, - MessageSound: 25, - MessageNotification: 26 - }; - - kindAttributeMap[ATTRIBUTE_KIND.Phone] = "phoneNumbers"; - kindAttributeMap[ATTRIBUTE_KIND.Fax] = "faxNumbers"; - kindAttributeMap[ATTRIBUTE_KIND.Pager] = "pagerNumber"; - kindAttributeMap[ATTRIBUTE_KIND.Email] = "emails"; - kindAttributeMap[ATTRIBUTE_KIND.Website] = "urls"; - kindAttributeMap[ATTRIBUTE_KIND.Profile] = "socialNetworks"; - kindAttributeMap[ATTRIBUTE_KIND.OrganizationAffiliation] = "organizations"; - kindAttributeMap[ATTRIBUTE_KIND.Education] = "education"; - kindAttributeMap[ATTRIBUTE_KIND.Note] = "note"; - kindAttributeMap[ATTRIBUTE_KIND.InstantMessaging] = "ims"; - kindAttributeMap[ATTRIBUTE_KIND.VideoChat] = "videoChat"; - kindAttributeMap[ATTRIBUTE_KIND.Sound] = "ringtone"; -} - -function populateSubKindAttributeMap() { - ATTRIBUTE_SUBKIND = { - Invalid: 0, - Other: 1, - Home: 2, - Work: 3, - PhoneMobile: 4, - FaxDirect: 5, - Blog: 6, - WebsiteResume: 7, - WebsitePortfolio: 8, - WebsitePersonal: 9, - WebsiteCompany: 10, - ProfileFacebook: 11, - ProfileTwitter: 12, - ProfileLinkedIn: 13, - ProfileGist: 14, - ProfileTungle: 15, - FamilySpouse: 16, - FamilyChild: 17, - FamilyParent: 18, - PersonManager: 19, - PersonAssistant: 20, - DateBirthday: 21, - DateAnniversary: 22, - GroupDepartment: 23, - NameGiven: 24, - NameSurname: 25, - Title: _TITLE, - NameSuffix: 27, - NameMiddle: 28, - NameNickname: 29, - NameAlias: 30, - NameDisplayName: 31, - NamePhoneticGiven: 32, - NamePhoneticSurname: 33, - StockSymbolNyse: 34, - StockSymbolNasdaq: 35, - StockSymbolTse: 36, - StockSymbolLse: 37, - StockSymbolTsx: 38, - RankingKlout: 39, - RankingTrstRank: 40, - OrganizationAffiliationName: 41, - OrganizationAffiliationPhoneticName: 42, - OrganizationAffiliationTitle: _TITLE, - StartDate: _START_DATE, - EndDate: _END_DATE, - OrganizationAffiliationDetails: 45, - EducationInstitutionName: 46, - EducationStartDate: _START_DATE, - EducationEndDate: _END_DATE, - EducationDegree: 47, - EducationConcentration: 48, - EducationActivities: 49, - EducationNotes: 50, - InstantMessagingBbmPin: 51, - InstantMessagingAim: 52, - InstantMessagingAliwangwang: 53, - InstantMessagingGoogleTalk: 54, - InstantMessagingSametime: 55, - InstantMessagingIcq: 56, - InstantMessagingIrc: 57, - InstantMessagingJabber: 58, - InstantMessagingMsLcs: 59, - InstantMessagingMsn: 60, - InstantMessagingQq: 61, - InstantMessagingSkype: 62, - InstantMessagingYahooMessenger: 63, - InstantMessagingYahooMessengerJapan: 64, - VideoChatBbPlaybook: 65, - HiddenLinkedIn: 66, - HiddenFacebook: 67, - HiddenTwitter: 68, - ConnectionCountLinkedIn: 69, - ConnectionCountFacebook: 70, - ConnectionCountTwitter: 71, - HiddenChecksum: 72, - HiddenSpeedDial: 73, - BiographyFacebook: 74, - BiographyTwitter: 75, - BiographyLinkedIn: 76, - SoundRingtone: 77, - SimContactType: 78, - EcoID: 79, - Personal: 80, - StockSymbolAll: 81, - NotificationVibration: 82, - NotificationLED: 83, - MessageNotificationVibration: 84, - MessageNotificationLED: 85, - MessageNotificationDuringCall: 86, - VideoChatPin: 87 - }; - - subKindAttributeMap[ATTRIBUTE_SUBKIND.Other] = "other"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.Home] = "home"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.Work] = "work"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.PhoneMobile] = "mobile"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.FaxDirect] = "direct"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.Blog] = "blog"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.WebsiteResume] = "resume"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.WebsitePortfolio] = "portfolio"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.WebsitePersonal] = "personal"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.WebsiteCompany] = "company"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.ProfileFacebook] = "facebook"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.ProfileTwitter] = "twitter"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.ProfileLinkedIn] = "linkedin"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.ProfileGist] = "gist"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.ProfileTungle] = "tungle"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.DateBirthday] = "birthday"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.DateAnniversary] = "anniversary"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.NameGiven] = "givenName"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.NameSurname] = "familyName"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.Title] = "honorificPrefix"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.NameSuffix] = "honorificSuffix"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.NameMiddle] = "middleName"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.NamePhoneticGiven] = "phoneticGivenName"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.NamePhoneticSurname] = "phoneticFamilyName"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.NameNickname] = "nickname"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.NameDisplayName] = "displayName"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.OrganizationAffiliationName] = "name"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.OrganizationAffiliationDetails] = "department"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.Title] = "title"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingBbmPin] = "BbmPin"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingAim] = "Aim"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingAliwangwang] = "Aliwangwang"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingGoogleTalk] = "GoogleTalk"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingSametime] = "Sametime"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingIcq] = "Icq"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingJabber] = "Jabber"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingMsLcs] = "MsLcs"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingSkype] = "Skype"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingYahooMessenger] = "YahooMessenger"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.InstantMessagingYahooMessengerJapan] = "YahooMessegerJapan"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.VideoChatBbPlaybook] = "BbPlaybook"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.SoundRingtone] = "ringtone"; - subKindAttributeMap[ATTRIBUTE_SUBKIND.Personal] = "personal"; -} - -module.exports = { - getKindAttributeMap: function () { - if (!ATTRIBUTE_KIND) { - populateKindAttributeMap(); - } - - return kindAttributeMap; - }, - getSubKindAttributeMap: function () { - if (!ATTRIBUTE_SUBKIND) { - populateSubKindAttributeMap(); - } - - return subKindAttributeMap; - } -};