Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E583A109F5 for ; Wed, 24 Jul 2013 22:39:42 +0000 (UTC) Received: (qmail 37297 invoked by uid 500); 24 Jul 2013 22:39:42 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 37254 invoked by uid 500); 24 Jul 2013 22:39:42 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 37035 invoked by uid 99); 24 Jul 2013 22:39:42 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Jul 2013 22:39:42 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 385CD8B4296; Wed, 24 Jul 2013 22:39:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anis@apache.org To: commits@cordova.apache.org Date: Wed, 24 Jul 2013 22:39:51 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [11/18] git commit: [CB-4341] Adding a fix to make subdirectories work within a local plugin dependency - Includes the integration of integration specs which test installation of plugins with dependencies [CB-4341] Adding a fix to make subdirectories work within a local plugin dependency - Includes the integration of integration specs which test installation of plugins with dependencies Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/21b6d79b Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/21b6d79b Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/21b6d79b Branch: refs/heads/plugman-registry Commit: 21b6d79b32a3dbce29e85d1b67f547351a1bf11b Parents: f2fa751 Author: Jeffrey Heifetz Authored: Mon Jul 22 15:23:46 2013 -0400 Committer: Jeffrey Heifetz Committed: Tue Jul 23 14:53:43 2013 -0400 ---------------------------------------------------------------------- .gitignore | 2 + spec/install.spec.js | 8 +- spec/integration.spec.js | 85 + spec/plugins/Contacts/plugin.xml | 143 ++ .../Contacts/src/android/ContactAccessor.java | 198 ++ .../src/android/ContactAccessorSdk5.java | 2183 ++++++++++++++++++ .../Contacts/src/android/ContactManager.java | 122 + .../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 ++ spec/plugins/Contacts/src/blackberry10/index.js | 374 +++ .../Contacts/src/blackberry10/plugin.xml | 41 + spec/plugins/Contacts/src/ios/CDVContact.h | 136 ++ spec/plugins/Contacts/src/ios/CDVContact.m | 1752 ++++++++++++++ spec/plugins/Contacts/src/ios/CDVContacts.h | 151 ++ spec/plugins/Contacts/src/ios/CDVContacts.m | 593 +++++ spec/plugins/Contacts/src/wp/Contacts.cs | 664 ++++++ spec/plugins/Contacts/www/Contact.js | 177 ++ spec/plugins/Contacts/www/ContactAddress.js | 46 + spec/plugins/Contacts/www/ContactError.js | 42 + spec/plugins/Contacts/www/ContactField.js | 37 + spec/plugins/Contacts/www/ContactFindOptions.js | 34 + spec/plugins/Contacts/www/ContactName.js | 41 + .../plugins/Contacts/www/ContactOrganization.js | 44 + spec/plugins/Contacts/www/contacts.js | 76 + spec/plugins/Contacts/www/ios/Contact.js | 51 + spec/plugins/Contacts/www/ios/contacts.js | 62 + spec/plugins/dependencies/B/plugin.xml | 8 +- spec/plugins/dependencies/E/plugin.xml | 57 - spec/plugins/dependencies/E/src/android/E.java | 0 .../dependencies/E/src/ios/EPluginCommand.h | 0 .../dependencies/E/src/ios/EPluginCommand.m | 0 spec/plugins/dependencies/E/www/plugin-e.js | 0 spec/plugins/dependencies/subdir/E/plugin.xml | 57 + .../dependencies/subdir/E/src/android/E.java | 0 .../subdir/E/src/ios/EPluginCommand.h | 0 .../subdir/E/src/ios/EPluginCommand.m | 0 .../dependencies/subdir/E/www/plugin-e.js | 0 .../blackberry10/native/device/chrome/.gitkeep | 0 .../native/device/plugins/jnext/auth.txt | 3 + .../native/simulator/chrome/.gitkeep | 0 .../native/simulator/plugins/jnext/auth.txt | 3 + src/install.js | 2 + 51 files changed, 7849 insertions(+), 64 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/21b6d79b/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 9daa824..7dbb168 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .DS_Store node_modules +.gitkeep +.tmp http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/21b6d79b/spec/install.spec.js ---------------------------------------------------------------------- diff --git a/spec/install.spec.js b/spec/install.spec.js index 33bfcc8..c48db9a 100644 --- a/spec/install.spec.js +++ b/spec/install.spec.js @@ -103,17 +103,19 @@ describe('install', function() { expect(proc.calls.length).toEqual(3); }); it('should fetch any dependent plugins if missing', function() { - var s = spyOn(plugman, 'fetch').andCallFake(function(id, dir, opts, cb) { + var deps_dir = path.join(plugins_dir, 'dependencies'), + s = spyOn(plugman, 'fetch').andCallFake(function(id, dir, opts, cb) { cb(false, path.join(dir, id)); }); exists.andReturn(false); // Plugin A depends on C & D - install('android', temp, 'A', path.join(plugins_dir, 'dependencies'), {}); + install('android', temp, 'A', deps_dir, {}); + expect(s).toHaveBeenCalledWith('C', deps_dir, { link: false, subdir: undefined, git_ref: undefined}, jasmine.any(Function)); expect(s.calls.length).toEqual(3); }); }); }); - + describe('failure', function() { it('should throw if platform is unrecognized', function() { expect(function() { http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/21b6d79b/spec/integration.spec.js ---------------------------------------------------------------------- diff --git a/spec/integration.spec.js b/spec/integration.spec.js new file mode 100644 index 0000000..54b578e --- /dev/null +++ b/spec/integration.spec.js @@ -0,0 +1,85 @@ +var plugman = require('../plugman'), + path = require('path'), + fs = require('fs'), + shell = require('shelljs'), + temp = path.join(__dirname, "..", ".tmp"), + plugins_dir = path.join(temp, 'plugins'); + +describe("integration", function () { + beforeEach(function () { + if ( !fs.existsSync(temp)) { + shell.mkdir("-p", temp); + } + }); + describe("local non-root depdencies", function () { + var project_src = path.join(__dirname, "projects", "android_one", "*"), + plugin_src = path.join(__dirname, "plugins", "dependencies", "B"), + project_dir = path.join(temp, "android"); + + beforeEach(function () { + shell.cp("-rf", project_src, project_dir); + }); + + it("should install dependencies from github", function () { + var flag = false, + installData; + + runs(function () { + plugman.install('android', project_dir, plugin_src, plugins_dir, {}, function (error) { + expect(error).not.toBeDefined(); + flag = true; + }); + }); + waitsFor(function () { return flag; }, "plugman install to finish", 10000); + runs(function () { + installData = require(path.join(plugins_dir, "android.json")); + expect(installData.installed_plugins).toEqual({ 'B': { PACKAGE_NAME: 'com.alunny.childapp'}}); + expect(installData.dependent_plugins).toEqual({ + 'D' : { PACKAGE_NAME: 'com.alunny.childapp'}, + 'E': { PACKAGE_NAME: 'com.alunny.childapp'} + }); + }); + //Cleanup + this.after(function () { + shell.rm("-rf", project_dir); + }); + }); + }); + + describe("blackberry10", function () { + var project_src = path.join(__dirname, "projects", "blackberry10", "*"), + plugin_src = path.join(__dirname, "plugins", "Contacts"), + project_dir = path.join(temp, "blackberry10"); + + beforeEach(function () { + shell.cp("-rf", project_src, project_dir); + }); + + it("should install dependencies from github", function () { + var flag = false, + installData; + + runs(function () { + plugman.install('blackberry10', project_dir, plugin_src, plugins_dir, {}, function (error) { + expect(error).not.toBeDefined(); + flag = true; + }); + }); + waitsFor(function () { return flag; }, "plugman install to finish", 10000); + runs(function () { + installData = require(path.join(plugins_dir, "blackberry10.json")); + expect(installData.installed_plugins).toEqual({ 'org.apache.cordova.core.contacts': { PACKAGE_NAME: 'cordovaExample'}}); + expect(installData.dependent_plugins).toEqual({ + 'com.blackberry.utils' : { PACKAGE_NAME: 'cordovaExample'}, + 'org.apache.cordova.blackberry10.pimlib': { PACKAGE_NAME: 'cordovaExample'} + }); + }); + //Cleanup + this.after(function () { + shell.rm("-rf", project_dir); + shell.rm("-rf", temp); + }); + }); + }); + +}); http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/21b6d79b/spec/plugins/Contacts/plugin.xml ---------------------------------------------------------------------- diff --git a/spec/plugins/Contacts/plugin.xml b/spec/plugins/Contacts/plugin.xml new file mode 100644 index 0000000..7328f1a --- /dev/null +++ b/spec/plugins/Contacts/plugin.xml @@ -0,0 +1,143 @@ + + + + Contacts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + access_pimdomain_contacts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/21b6d79b/spec/plugins/Contacts/src/android/ContactAccessor.java ---------------------------------------------------------------------- diff --git a/spec/plugins/Contacts/src/android/ContactAccessor.java b/spec/plugins/Contacts/src/android/ContactAccessor.java new file mode 100644 index 0000000..24ef9c6 --- /dev/null +++ b/spec/plugins/Contacts/src/android/ContactAccessor.java @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * 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. + */ + +package org.apache.cordova.core; + +import java.util.HashMap; + +import android.util.Log; +import android.webkit.WebView; + +import org.apache.cordova.CordovaInterface; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +/** + * This abstract class defines SDK-independent API for communication with + * Contacts Provider. The actual implementation used by the application depends + * on the level of API available on the device. If the API level is Cupcake or + * Donut, we want to use the {@link ContactAccessorSdk3_4} class. If it is + * Eclair or higher, we want to use {@link ContactAccessorSdk5}. + */ +public abstract class ContactAccessor { + + protected final String LOG_TAG = "ContactsAccessor"; + protected CordovaInterface mApp; + protected WebView mView; + + /** + * Check to see if the data associated with the key is required to + * be populated in the Contact object. + * @param key + * @param map created by running buildPopulationSet. + * @return true if the key data is required + */ + protected boolean isRequired(String key, HashMap map) { + Boolean retVal = map.get(key); + return (retVal == null) ? false : retVal.booleanValue(); + } + + /** + * Create a hash map of what data needs to be populated in the Contact object + * @param fields the list of fields to populate + * @return the hash map of required data + */ + protected HashMap buildPopulationSet(JSONArray fields) { + HashMap map = new HashMap(); + + String key; + try { + if (fields.length() == 1 && fields.getString(0).equals("*")) { + map.put("displayName", true); + map.put("name", true); + map.put("nickname", true); + map.put("phoneNumbers", true); + map.put("emails", true); + map.put("addresses", true); + map.put("ims", true); + map.put("organizations", true); + map.put("birthday", true); + map.put("note", true); + map.put("urls", true); + map.put("photos", true); + map.put("categories", true); + } + else { + for (int i=0; i