You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/04/25 20:12:27 UTC
[4/6] CB-6521: Remove development branch
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/fc255252/src/android/ContactManager.java
----------------------------------------------------------------------
diff --git a/src/android/ContactManager.java b/src/android/ContactManager.java
deleted file mode 100644
index a50d799..0000000
--- a/src/android/ContactManager.java
+++ /dev/null
@@ -1,122 +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.
-*/
-package org.apache.cordova.contacts;
-
-import org.apache.cordova.CallbackContext;
-import org.apache.cordova.CordovaPlugin;
-import org.apache.cordova.PluginResult;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import android.util.Log;
-
-public class ContactManager extends CordovaPlugin {
-
- private ContactAccessor contactAccessor;
- private static final String LOG_TAG = "Contact Query";
-
- public static final int UNKNOWN_ERROR = 0;
- public static final int INVALID_ARGUMENT_ERROR = 1;
- public static final int TIMEOUT_ERROR = 2;
- public static final int PENDING_OPERATION_ERROR = 3;
- public static final int IO_ERROR = 4;
- public static final int NOT_SUPPORTED_ERROR = 5;
- public static final int PERMISSION_DENIED_ERROR = 20;
-
- /**
- * Constructor.
- */
- public ContactManager() {
- }
-
- /**
- * Executes the request and returns PluginResult.
- *
- * @param action The action to execute.
- * @param args JSONArray of arguments for the plugin.
- * @param callbackContext The callback context used when calling back into JavaScript.
- * @return True if the action was valid, false otherwise.
- */
- public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
- /**
- * Check to see if we are on an Android 1.X device. If we are return an error as we
- * do not support this as of Cordova 1.0.
- */
- if (android.os.Build.VERSION.RELEASE.startsWith("1.")) {
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, ContactManager.NOT_SUPPORTED_ERROR));
- return true;
- }
-
- /**
- * Only create the contactAccessor after we check the Android version or the program will crash
- * older phones.
- */
- if (this.contactAccessor == null) {
- this.contactAccessor = new ContactAccessorSdk5(this.cordova);
- }
-
- if (action.equals("search")) {
- final JSONArray filter = args.getJSONArray(0);
- final JSONObject options = args.getJSONObject(1);
- this.cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- JSONArray res = contactAccessor.search(filter, options);
- callbackContext.success(res);
- }
- });
- }
- else if (action.equals("save")) {
- final JSONObject contact = args.getJSONObject(0);
- this.cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- JSONObject res = null;
- String id = contactAccessor.save(contact);
- if (id != null) {
- try {
- res = contactAccessor.getContactById(id);
- } catch (JSONException e) {
- Log.e(LOG_TAG, "JSON fail.", e);
- }
- }
- if (res != null) {
- callbackContext.success(res);
- } else {
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, UNKNOWN_ERROR));
- }
- }
- });
- }
- else if (action.equals("remove")) {
- final String contactId = args.getString(0);
- this.cordova.getThreadPool().execute(new Runnable() {
- public void run() {
- if (contactAccessor.remove(contactId)) {
- callbackContext.success();
- } else {
- callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, UNKNOWN_ERROR));
- }
- }
- });
- }
- else {
- return false;
- }
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/fc255252/src/blackberry10/ContactActivity.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/ContactActivity.js b/src/blackberry10/ContactActivity.js
deleted file mode 100644
index 0205194..0000000
--- a/src/blackberry10/ContactActivity.js
+++ /dev/null
@@ -1,31 +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 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;
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/fc255252/src/blackberry10/ContactAddress.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/ContactAddress.js b/src/blackberry10/ContactAddress.js
deleted file mode 100644
index 30e9cbd..0000000
--- a/src/blackberry10/ContactAddress.js
+++ /dev/null
@@ -1,35 +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 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-plugin-contacts/blob/fc255252/src/blackberry10/ContactError.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/ContactError.js b/src/blackberry10/ContactError.js
deleted file mode 100644
index a44a546..0000000
--- a/src/blackberry10/ContactError.js
+++ /dev/null
@@ -1,35 +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 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-plugin-contacts/blob/fc255252/src/blackberry10/ContactField.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/ContactField.js b/src/blackberry10/ContactField.js
deleted file mode 100644
index 9651700..0000000
--- a/src/blackberry10/ContactField.js
+++ /dev/null
@@ -1,32 +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 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-plugin-contacts/blob/fc255252/src/blackberry10/ContactFindOptions.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/ContactFindOptions.js b/src/blackberry10/ContactFindOptions.js
deleted file mode 100644
index 6f8ccfe..0000000
--- a/src/blackberry10/ContactFindOptions.js
+++ /dev/null
@@ -1,55 +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.
- *
-*/
-
-/**
- * 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-plugin-contacts/blob/fc255252/src/blackberry10/ContactName.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/ContactName.js b/src/blackberry10/ContactName.js
deleted file mode 100644
index 80136c9..0000000
--- a/src/blackberry10/ContactName.js
+++ /dev/null
@@ -1,44 +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.
- *
-*/
-
-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-plugin-contacts/blob/fc255252/src/blackberry10/ContactNews.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/ContactNews.js b/src/blackberry10/ContactNews.js
deleted file mode 100644
index e47a4cd..0000000
--- a/src/blackberry10/ContactNews.js
+++ /dev/null
@@ -1,31 +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 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;
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/fc255252/src/blackberry10/ContactOrganization.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/ContactOrganization.js b/src/blackberry10/ContactOrganization.js
deleted file mode 100644
index fc953f2..0000000
--- a/src/blackberry10/ContactOrganization.js
+++ /dev/null
@@ -1,27 +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 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;
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/fc255252/src/blackberry10/ContactPhoto.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/ContactPhoto.js b/src/blackberry10/ContactPhoto.js
deleted file mode 100644
index 4604710..0000000
--- a/src/blackberry10/ContactPhoto.js
+++ /dev/null
@@ -1,28 +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 ContactPhoto = function (originalFilePath, pref) {
- this.originalFilePath = originalFilePath || "";
- this.pref = pref || false;
- this.largeFilePath = "";
- this.smallFilePath = "";
-};
-
-module.exports = ContactPhoto;
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/fc255252/src/blackberry10/contactConsts.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/contactConsts.js b/src/blackberry10/contactConsts.js
deleted file mode 100644
index ef25206..0000000
--- a/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;
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/fc255252/src/blackberry10/contactUtils.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/contactUtils.js b/src/blackberry10/contactUtils.js
deleted file mode 100644
index e1f7d67..0000000
--- a/src/blackberry10/contactUtils.js
+++ /dev/null
@@ -1,228 +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 self,
- ContactFindOptions = require("./ContactFindOptions"),
- ContactError = require("./ContactError"),
- ContactName = require("./ContactName"),
- ContactOrganization = require("./ContactOrganization"),
- ContactAddress = require("./ContactAddress"),
- ContactField = require("./ContactField"),
- contactConsts = require("./contactConsts"),
- ContactPhoto = require("./ContactPhoto"),
- ContactNews = require("./ContactNews"),
- ContactActivity = require("./ContactActivity");
-
-function populateFieldArray(contactProps, field, ClassName) {
- if (contactProps[field]) {
- var list = [],
- obj;
-
- contactProps[field].forEach(function (args) {
- if (ClassName === ContactField) {
- list.push(new ClassName(args.type, args.value));
- } else if (ClassName === ContactPhoto) {
- obj = new ContactPhoto(args.originalFilePath, args.pref);
- obj.largeFilePath = args.largeFilePath;
- obj.smallFilePath = args.smallFilePath;
- list.push(obj);
- } else if (ClassName === ContactNews) {
- obj = new ContactNews(args);
- list.push(obj);
- } else if (ClassName === ContactActivity) {
- obj = new ContactActivity(args);
- list.push(obj);
- } else {
- list.push(new ClassName(args));
- }
- });
- contactProps[field] = list;
- }
-}
-
-function populateDate(contactProps, field) {
- if (contactProps[field]) {
- contactProps[field] = new Date(contactProps[field]);
- }
-}
-
-function validateFindArguments(findOptions) {
- var error = false;
-
- // findOptions is mandatory
- if (!findOptions) {
- error = true;
- } else {
- // findOptions.filter is optional
- if (findOptions.filter) {
- findOptions.filter.forEach(function (f) {
- switch (f.fieldName) {
- case ContactFindOptions.SEARCH_FIELD_GIVEN_NAME:
- case ContactFindOptions.SEARCH_FIELD_FAMILY_NAME:
- case ContactFindOptions.SEARCH_FIELD_ORGANIZATION_NAME:
- case ContactFindOptions.SEARCH_FIELD_PHONE:
- case ContactFindOptions.SEARCH_FIELD_EMAIL:
- case ContactFindOptions.SEARCH_FIELD_BBMPIN:
- case ContactFindOptions.SEARCH_FIELD_LINKEDIN:
- case ContactFindOptions.SEARCH_FIELD_TWITTER:
- case ContactFindOptions.SEARCH_FIELD_VIDEO_CHAT:
- break;
- default:
- error = true;
- }
-
- if (!f.fieldValue) {
- error = true;
- }
- });
- }
-
- //findOptions.limit is optional
- if (findOptions.limit) {
- if (typeof findOptions.limit !== "number") {
- error = true;
- }
- }
-
- //findOptions.favorite is optional
- if (findOptions.favorite) {
- if (typeof findOptions.favorite !== "boolean") {
- error = true;
- }
- }
-
- // findOptions.sort is optional
- if (!error && findOptions.sort && Array.isArray(findOptions.sort)) {
- findOptions.sort.forEach(function (s) {
- switch (s.fieldName) {
- case ContactFindOptions.SORT_FIELD_GIVEN_NAME:
- case ContactFindOptions.SORT_FIELD_FAMILY_NAME:
- case ContactFindOptions.SORT_FIELD_ORGANIZATION_NAME:
- break;
- default:
- error = true;
- }
-
- if (s.desc === undefined || typeof s.desc !== "boolean") {
- error = true;
- }
- });
- }
-
- if (!error && findOptions.includeAccounts) {
- if (!Array.isArray(findOptions.includeAccounts)) {
- error = true;
- } else {
- findOptions.includeAccounts.forEach(function (acct) {
- if (!error && (!acct.id || window.isNaN(window.parseInt(acct.id, 10)))) {
- error = true;
- }
- });
- }
- }
-
- if (!error && findOptions.excludeAccounts) {
- if (!Array.isArray(findOptions.excludeAccounts)) {
- error = true;
- } else {
- findOptions.excludeAccounts.forEach(function (acct) {
- if (!error && (!acct.id || window.isNaN(window.parseInt(acct.id, 10)))) {
- error = true;
- }
- });
- }
- }
- }
- return !error;
-}
-
-function validateContactsPickerFilter(filter) {
- var isValid = true,
- availableFields = {};
-
- if (typeof(filter) === "undefined") {
- isValid = false;
- } else {
- if (filter && Array.isArray(filter)) {
- availableFields = contactConsts.getKindAttributeMap();
- filter.forEach(function (e) {
- isValid = isValid && Object.getOwnPropertyNames(availableFields).reduce(
- function (found, key) {
- return found || availableFields[key] === e;
- }, false);
- });
- }
- }
-
- return isValid;
-}
-
-function validateContactsPickerOptions(options) {
- var isValid = false,
- mode = options.mode;
-
- if (typeof(options) === "undefined") {
- isValid = false;
- } else {
- isValid = mode === ContactPickerOptions.MODE_SINGLE || mode === ContactPickerOptions.MODE_MULTIPLE || mode === ContactPickerOptions.MODE_ATTRIBUTE;
-
- // if mode is attribute, fields must be defined
- if (mode === ContactPickerOptions.MODE_ATTRIBUTE && !validateContactsPickerFilter(options.fields)) {
- isValid = false;
- }
- }
-
- return isValid;
-}
-
-self = module.exports = {
- populateContact: function (contact) {
- if (contact.name) {
- contact.name = new ContactName(contact.name);
- }
-
- populateFieldArray(contact, "addresses", ContactAddress);
- populateFieldArray(contact, "organizations", ContactOrganization);
- populateFieldArray(contact, "emails", ContactField);
- populateFieldArray(contact, "phoneNumbers", ContactField);
- populateFieldArray(contact, "faxNumbers", ContactField);
- populateFieldArray(contact, "pagerNumbers", ContactField);
- populateFieldArray(contact, "ims", ContactField);
- populateFieldArray(contact, "socialNetworks", ContactField);
- populateFieldArray(contact, "urls", ContactField);
- populateFieldArray(contact, "photos", ContactPhoto);
- populateFieldArray(contact, "news", ContactNews);
- populateFieldArray(contact, "activities", ContactActivity);
- // TODO categories
-
- populateDate(contact, "birthday");
- populateDate(contact, "anniversary");
- },
- invokeErrorCallback: function (errorCallback, code) {
- if (errorCallback) {
- errorCallback(new ContactError(code));
- }
- },
- validateFindArguments: validateFindArguments,
- validateContactsPickerFilter: validateContactsPickerFilter,
- validateContactsPickerOptions: validateContactsPickerOptions
-};
-
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/fc255252/src/blackberry10/index.js
----------------------------------------------------------------------
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
deleted file mode 100644
index 09a4bd2..0000000
--- a/src/blackberry10/index.js
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * Copyright 2013 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 pimContacts,
- contactUtils = require("./contactUtils"),
- contactConsts = require("./contactConsts"),
- ContactError = require("./ContactError"),
- ContactName = require("./ContactName"),
- ContactFindOptions = require("./ContactFindOptions"),
- noop = function () {};
-
-function getAccountFilters(options) {
- if (options.includeAccounts) {
- options.includeAccounts = options.includeAccounts.map(function (acct) {
- return acct.id.toString();
- });
- }
-
- if (options.excludeAccounts) {
- options.excludeAccounts = options.excludeAccounts.map(function (acct) {
- return acct.id.toString();
- });
- }
-}
-
-function populateSearchFields(fields) {
- var i,
- l,
- key,
- searchFieldsObject = {},
- searchFields = [];
-
- for (i = 0, l = fields.length; i < l; i++) {
- if (fields[i] === "*") {
- searchFieldsObject[ContactFindOptions.SEARCH_FIELD_GIVEN_NAME] = true;
- searchFieldsObject[ContactFindOptions.SEARCH_FIELD_FAMILY_NAME] = true;
- searchFieldsObject[ContactFindOptions.SEARCH_FIELD_PHONE] = true;
- searchFieldsObject[ContactFindOptions.SEARCH_FIELD_EMAIL] = true;
- searchFieldsObject[ContactFindOptions.SEARCH_FIELD_ORGANIZATION_NAME] = true;
- } else if (fields[i] === "displayName" || fields[i] === "name") {
- searchFieldsObject[ContactFindOptions.SEARCH_FIELD_GIVEN_NAME] = true;
- searchFieldsObject[ContactFindOptions.SEARCH_FIELD_FAMILY_NAME] = true;
- } else if (fields[i] === "nickname") {
- // not supported by Cascades
- } else if (fields[i] === "phoneNumbers") {
- searchFieldsObject[ContactFindOptions.SEARCH_FIELD_PHONE] = true;
- } else if (fields[i] === "emails") {
- searchFieldsObject[ContactFindOptions.SEARCH_FIELD_EMAIL] = true;
- } else if (field === "addresses") {
- // not supported by Cascades
- } else if (field === "ims") {
- // not supported by Cascades
- } else if (field === "organizations") {
- searchFieldsObject[ContactFindOptions.SEARCH_FIELD_ORGANIZATION_NAME] = true;
- } else if (field === "birthday") {
- // not supported by Cascades
- } else if (field === "note") {
- // not supported by Cascades
- } else if (field === "photos") {
- // not supported by Cascades
- } else if (field === "categories") {
- // not supported by Cascades
- } else if (field === "urls") {
- // not supported by Cascades
- }
- }
-
- for (key in searchFieldsObject) {
- if (searchFieldsObject.hasOwnProperty(key)) {
- searchFields.push(window.parseInt(key));
- }
- }
-
- return searchFields;
-}
-
-function convertBirthday(birthday) {
- //Convert date string from native to milliseconds since epoch for cordova-js
- var birthdayInfo;
- if (birthday) {
- birthdayInfo = birthday.split("-");
- return new Date(birthdayInfo[0], birthdayInfo[1] - 1, birthdayInfo[2]).getTime();
- } else {
- return null;
- }
-}
-
-function processJnextSaveData(result, JnextData) {
- var data = JnextData,
- birthdayInfo;
-
- if (data._success === true) {
- data.birthday = convertBirthday(data.birthday);
- result.callbackOk(data, false);
- } else {
- result.callbackError(data.code, false);
- }
-}
-
-function processJnextRemoveData(result, JnextData) {
- var data = JnextData;
-
- if (data._success === true) {
- result.callbackOk(data);
- } else {
- result.callbackError(ContactError.UNKNOWN_ERROR, false);
- }
-}
-
-function processJnextFindData(eventId, eventHandler, JnextData) {
- var data = JnextData,
- i,
- l,
- more = false,
- resultsObject = {},
- birthdayInfo;
-
- if (data.contacts) {
- for (i = 0, l = data.contacts.length; i < l; i++) {
- data.contacts[i].birthday = convertBirthday(data.contacts[i].birthday);
- data.contacts[i].name = new ContactName(data.contacts[i].name);
- }
- } else {
- data.contacts = []; // if JnextData.contacts return null, return an empty array
- }
-
- if (data._success === true) {
- eventHandler.error = false;
- }
-
- if (eventHandler.multiple) {
- // Concatenate results; do not add the same contacts
- for (i = 0, l = eventHandler.searchResult.length; i < l; i++) {
- resultsObject[eventHandler.searchResult[i].id] = true;
- }
-
- for (i = 0, l = data.contacts.length; i < l; i++) {
- if (resultsObject[data.contacts[i].id]) {
- // Already existing
- } else {
- eventHandler.searchResult.push(data.contacts[i]);
- }
- }
-
- // check if more search is required
- eventHandler.searchFieldIndex++;
- if (eventHandler.searchFieldIndex < eventHandler.searchFields.length) {
- more = true;
- }
- } else {
- eventHandler.searchResult = data.contacts;
- }
-
- if (more) {
- pimContacts.getInstance().invokeJnextSearch(eventId);
- } else {
- if (eventHandler.error) {
- eventHandler.result.callbackError(data.code, false);
- } else {
- eventHandler.result.callbackOk(eventHandler.searchResult, false);
- }
- }
-}
-
-module.exports = {
- search: function (successCb, failCb, args, env) {
- var cordovaFindOptions = {},
- result = new PluginResult(args, env),
- key;
-
- for (key in args) {
- if (args.hasOwnProperty(key)) {
- cordovaFindOptions[key] = JSON.parse(decodeURIComponent(args[key]));
- }
- }
-
- pimContacts.getInstance().find(cordovaFindOptions, result, processJnextFindData);
- result.noResult(true);
- },
- save: function (successCb, failCb, args, env) {
- var attributes = {},
- result = new PluginResult(args, env),
- key,
- nativeEmails = [];
-
- attributes = JSON.parse(decodeURIComponent(args[0]));
-
- //convert birthday format for our native .so file
- if (attributes.birthday) {
- attributes.birthday = new Date(attributes.birthday).toDateString();
- }
-
- if (attributes.emails) {
- attributes.emails.forEach(function (email) {
- if (email.value) {
- if (email.type) {
- nativeEmails.push({ "type" : email.type, "value" : email.value });
- } else {
- nativeEmails.push({ "type" : "home", "value" : email.value });
- }
- }
- });
- attributes.emails = nativeEmails;
- }
-
- if (attributes.id !== null) {
- attributes.id = window.parseInt(attributes.id);
- }
-
- attributes._eventId = result.callbackId;
- pimContacts.getInstance().save(attributes, result, processJnextSaveData);
- result.noResult(true);
- },
- remove: function (successCb, failCb, args, env) {
- var result = new PluginResult(args, env),
- attributes = {
- "contactId": window.parseInt(JSON.parse(decodeURIComponent(args[0]))),
- "_eventId": result.callbackId
- };
-
- if (!window.isNaN(attributes.contactId)) {
- pimContacts.getInstance().remove(attributes, result, processJnextRemoveData);
- result.noResult(true);
- } else {
- result.error(ContactError.UNKNOWN_ERROR);
- result.noResult(false);
- }
- }
-};
-
-///////////////////////////////////////////////////////////////////
-// JavaScript wrapper for JNEXT plugin
-///////////////////////////////////////////////////////////////////
-
-JNEXT.PimContacts = function ()
-{
- var self = this,
- hasInstance = false;
-
- self.find = function (cordovaFindOptions, pluginResult, handler) {
- //register find eventHandler for when JNEXT onEvent fires
- self.eventHandlers[cordovaFindOptions.callbackId] = {
- "result" : pluginResult,
- "action" : "find",
- "multiple" : cordovaFindOptions[1].filter ? true : false,
- "fields" : cordovaFindOptions[0],
- "searchFilter" : cordovaFindOptions[1].filter,
- "searchFields" : cordovaFindOptions[1].filter ? populateSearchFields(cordovaFindOptions[0]) : null,
- "searchFieldIndex" : 0,
- "searchResult" : [],
- "handler" : handler,
- "error" : true
- };
-
- self.invokeJnextSearch(cordovaFindOptions.callbackId);
- return "";
- };
-
- self.invokeJnextSearch = function(eventId) {
- var jnextArgs = {},
- findHandler = self.eventHandlers[eventId];
-
- jnextArgs._eventId = eventId;
- jnextArgs.fields = findHandler.fields;
- jnextArgs.options = {};
- jnextArgs.options.filter = [];
-
- if (findHandler.multiple) {
- jnextArgs.options.filter.push({
- "fieldName" : findHandler.searchFields[findHandler.searchFieldIndex],
- "fieldValue" : findHandler.searchFilter
- });
- //findHandler.searchFieldIndex++;
- }
-
- JNEXT.invoke(self.m_id, "find " + JSON.stringify(jnextArgs));
- }
-
- self.getContact = function (args) {
- return JSON.parse(JNEXT.invoke(self.m_id, "getContact " + JSON.stringify(args)));
- };
-
- self.save = function (args, pluginResult, handler) {
- //register save eventHandler for when JNEXT onEvent fires
- self.eventHandlers[args._eventId] = {
- "result" : pluginResult,
- "action" : "save",
- "handler" : handler
- };
- JNEXT.invoke(self.m_id, "save " + JSON.stringify(args));
- return "";
- };
-
- self.remove = function (args, pluginResult, handler) {
- //register remove eventHandler for when JNEXT onEvent fires
- self.eventHandlers[args._eventId] = {
- "result" : pluginResult,
- "action" : "remove",
- "handler" : handler
- };
- JNEXT.invoke(self.m_id, "remove " + JSON.stringify(args));
- return "";
- };
-
- self.getId = function () {
- return self.m_id;
- };
-
- self.getContactAccounts = function () {
- var value = JNEXT.invoke(self.m_id, "getContactAccounts");
- return JSON.parse(value);
- };
-
- self.init = function () {
- if (!JNEXT.require("libpimcontacts")) {
- return false;
- }
-
- self.m_id = JNEXT.createObject("libpimcontacts.PimContacts");
-
- if (self.m_id === "") {
- return false;
- }
-
- JNEXT.registerEvents(self);
- };
-
- // Handle data coming back from JNEXT native layer. Each async function registers a handler and a PluginResult object.
- // When JNEXT fires onEvent we parse the result string back into JSON and trigger the appropriate handler (eventHandlers map
- // uses callbackId as key), along with the actual data coming back from the native layer. Each function may have its own way of
- // processing native data so we do not do any processing here.
-
- self.onEvent = function (strData) {
- var arData = strData.split(" "),
- strEventDesc = arData[0],
- eventHandler,
- args = {};
-
- if (strEventDesc === "result") {
- args.result = escape(strData.split(" ").slice(2).join(" "));
- eventHandler = self.eventHandlers[arData[1]];
- if (eventHandler.action === "save" || eventHandler.action === "remove") {
- eventHandler.handler(eventHandler.result, JSON.parse(decodeURIComponent(args.result)));
- } else if (eventHandler.action === "find") {
- eventHandler.handler(arData[1], eventHandler, JSON.parse(decodeURIComponent(args.result)));
- }
- }
- };
-
- self.m_id = "";
- self.eventHandlers = {};
-
- self.getInstance = function () {
- if (!hasInstance) {
- self.init();
- hasInstance = true;
- }
- return self;
- };
-};
-
-pimContacts = new JNEXT.PimContacts();
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/fc255252/src/firefoxos/ContactsProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/ContactsProxy.js b/src/firefoxos/ContactsProxy.js
deleted file mode 100644
index a5b6667..0000000
--- a/src/firefoxos/ContactsProxy.js
+++ /dev/null
@@ -1,464 +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.
- *
-*/
-
-// Cordova contact definition:
-// http://cordova.apache.org/docs/en/2.5.0/cordova_contacts_contacts.md.html#Contact
-// FxOS contact definition:
-// https://developer.mozilla.org/en-US/docs/Web/API/mozContact
-
-
-var Contact = require('./Contact');
-var ContactField = require('./ContactField');
-var ContactAddress = require('./ContactAddress');
-var ContactName = require('./ContactName');
-
-// XXX: a hack to check if id is "empty". Cordova inserts a
-// string "this string is supposed to be a unique identifier that will
-// never show up on a device" if id is empty
-function _hasId(id) {
- if (!id || id.indexOf(' ') >= 0) {
- return false;
- }
- return true;
-}
-
-// Extend mozContact prototype to provide update from Cordova
-function updateFromCordova(contact, fromContact) {
-
- function exportContactFieldArray(contactFieldArray, key) {
- if (!key) {
- key = 'value';
- }
- var arr = [];
- for (var i=0; i < contactFieldArray.length; i++) {
- arr.push(contactFieldArray[i][key]);
- };
- return arr;
- }
-
- function exportAddress(addresses) {
- // TODO: check moz address format
- var arr = [];
-
- for (var i=0; i < addresses.length; i++) {
- var addr = {};
- for (var key in addresses[i]) {
- if (key == 'formatted' || key == 'id') {
- continue;
- } else if (key == 'type') {
- addr[key] = [addresses[i][key]];
- } else if (key == 'country') {
- addr['countryName'] = addresses[i][key];
- } else {
- addr[key] = addresses[i][key];
- }
- }
- arr.push(addr);
- }
- return arr;
- }
-
- function exportContactField(data) {
- var contactFields = [];
- for (var i=0; i < data.length; i++) {
- var item = data[i];
- if (item.value) {
- var itemData = {value: item.value};
- if (item.type) {
- itemData.type = [item.type];
- }
- if (item.pref) {
- itemData.pref = item.pref;
- }
- contactFields.push(itemData);
- }
- }
- return contactFields;
- }
- // adding simple fields [contactField, eventualMozContactField]
- var nameFields = [['givenName'], ['familyName'],
- ['honorificPrefix'], ['honorificSuffix'],
- ['middleName', 'additionalName']];
- var baseArrayFields = [['displayName', 'name'], ['nickname']];
- var baseStringFields = [];
- var j = 0; while(field = nameFields[j++]) {
- if (fromContact.name[field[0]]) {
- contact[field[1] || field[0]] = fromContact.name[field[0]].split(' ');
- }
- }
- j = 0; while(field = baseArrayFields[j++]) {
- if (fromContact[field[0]]) {
- contact[field[1] || field[0]] = fromContact[field[0]].split(' ');
- }
- }
- j = 0; while(field = baseStringFields[j++]) {
- if (fromContact[field[0]]) {
- contact[field[1] || field[0]] = fromContact[field[0]];
- }
- }
- if (fromContact.birthday) {
- contact.bday = new Date(fromContact.birthday);
- }
- if (fromContact.emails) {
- var emails = exportContactField(fromContact.emails)
- contact.email = emails;
- }
- if (fromContact.categories) {
- contact.category = exportContactFieldArray(fromContact.categories);
- }
- if (fromContact.addresses) {
- contact.adr = exportAddress(fromContact.addresses);
- }
- if (fromContact.phoneNumbers) {
- contact.tel = exportContactField(fromContact.phoneNumbers);
- }
- if (fromContact.organizations) {
- // XXX: organizations are saved in 2 arrays - org and jobTitle
- // depending on the usecase it might generate issues
- // where wrong title will be added to an organization
- contact.org = exportContactFieldArray(fromContact.organizations, 'name');
- contact.jobTitle = exportContactFieldArray(fromContact.organizations, 'title');
- }
- if (fromContact.note) {
- contact.note = [fromContact.note];
- }
-}
-
-
-// Extend Cordova Contact prototype to provide update from FFOS contact
-Contact.prototype.updateFromMozilla = function(moz) {
- function exportContactField(data) {
- var contactFields = [];
- for (var i=0; i < data.length; i++) {
- var item = data[i];
- var itemData = new ContactField(item.type, item.value, item.pref);
- contactFields.push(itemData);
- }
- return contactFields;
- }
-
- function makeContactFieldFromArray(data) {
- var contactFields = [];
- for (var i=0; i < data.length; i++) {
- var itemData = new ContactField(null, data[i]);
- contactFields.push(itemData);
- }
- return contactFields;
- }
-
- function exportAddresses(addresses) {
- // TODO: check moz address format
- var arr = [];
-
- for (var i=0; i < addresses.length; i++) {
- var addr = {};
- for (var key in addresses[i]) {
- if (key == 'countryName') {
- addr['country'] = addresses[i][key];
- } else if (key == 'type') {
- addr[key] = addresses[i][key].join(' ');
- } else {
- addr[key] = addresses[i][key];
- }
- }
- arr.push(addr);
- }
- return arr;
- }
-
- function createOrganizations(orgs, jobs) {
- orgs = (orgs) ? orgs : [];
- jobs = (jobs) ? jobs : [];
- var max_length = Math.max(orgs.length, jobs.length);
- var organizations = [];
- for (var i=0; i < max_length; i++) {
- organizations.push(new ContactOrganization(
- null, null, orgs[i] || null, null, jobs[i] || null));
- }
- return organizations;
- }
-
- function createFormatted(name) {
- var fields = ['honorificPrefix', 'givenName', 'middleName',
- 'familyName', 'honorificSuffix'];
- var f = '';
- for (var i = 0; i < fields.length; i++) {
- if (name[fields[i]]) {
- if (f) {
- f += ' ';
- }
- f += name[fields[i]];
- }
- }
- return f;
- }
-
-
- if (moz.id) {
- this.id = moz.id;
- }
- var nameFields = [['givenName'], ['familyName'],
- ['honorificPrefix'], ['honorificSuffix'],
- ['additionalName', 'middleName']];
- var baseArrayFields = [['name', 'displayName'], 'nickname', ['note']];
- var baseStringFields = [];
- var name = new ContactName();
- var j = 0; while(field = nameFields[j++]) {
- if (moz[field[0]]) {
- name[field[1] || field[0]] = moz[field[0]].join(' ');
- }
- }
- this.name = name;
- j = 0; while(field = baseArrayFields[j++]) {
- if (moz[field[0]]) {
- this[field[1] || field[0]] = moz[field[0]].join(' ');
- }
- }
- j = 0; while(field = baseStringFields[j++]) {
- if (moz[field[0]]) {
- this[field[1] || field[0]] = moz[field[0]];
- }
- }
- // emails
- if (moz.email) {
- this.emails = exportContactField(moz.email);
- }
- // categories
- if (moz.category) {
- this.categories = makeContactFieldFromArray(moz.category);
- }
-
- // addresses
- if (moz.adr) {
- this.addresses = exportAddresses(moz.adr);
- }
-
- // phoneNumbers
- if (moz.tel) {
- this.phoneNumbers = exportContactField(moz.tel);
- }
- // birthday
- if (moz.bday) {
- this.birthday = Date.parse(moz.bday);
- }
- // organizations
- if (moz.org || moz.jobTitle) {
- // XXX: organizations array is created from org and jobTitle
- this.organizations = createOrganizations(moz.org, moz.jobTitle);
- }
- // construct a read-only formatted value
- this.name.formatted = createFormatted(this.name);
-
- /* Find out how to translate these parameters
- // photo: Blob
- // url: Array with metadata (?)
- // impp: exportIM(contact.ims), TODO: find the moz impp definition
- // anniversary
- // sex
- // genderIdentity
- // key
- */
-}
-
-
-function createMozillaFromCordova(successCB, errorCB, contact) {
- var moz;
- // get contact if exists
- if (_hasId(contact.id)) {
- var search = navigator.mozContacts.find({
- filterBy: ['id'], filterValue: contact.id, filterOp: 'equals'});
- search.onsuccess = function() {
- moz = search.result[0];
- updateFromCordova(moz, contact);
- successCB(moz);
- };
- search.onerror = errorCB;
- return;
- }
-
- // create empty contact
- moz = new mozContact();
- // if ('init' in moz) {
- // 1.2 and below compatibility
- // moz.init();
- // }
- updateFromCordova(moz, contact);
- successCB(moz);
-}
-
-
-function createCordovaFromMozilla(moz) {
- var contact = new Contact();
- contact.updateFromMozilla(moz);
- return contact;
-}
-
-
-// However API requires the ability to save multiple contacts, it is
-// used to save only one element array
-function saveContacts(successCB, errorCB, contacts) {
- // a closure which is holding the right moz contact
- function makeSaveSuccessCB(moz) {
- return function(result) {
- // create contact from FXOS contact (might be different than
- // the original one due to differences in API)
- var contact = createCordovaFromMozilla(moz);
- // call callback
- successCB(contact);
- }
- }
- var i=0;
- var contact;
- while(contact = contacts[i++]){
- var moz = createMozillaFromCordova(function(moz) {
- var request = navigator.mozContacts.save(moz);
- // success and/or fail will be called every time a contact is saved
- request.onsuccess = makeSaveSuccessCB(moz);
- request.onerror = errorCB;
- }, function() {}, contact);
- }
-}
-
-
-// API provides a list of ids to be removed
-function remove(successCB, errorCB, ids) {
- var i=0;
- var id;
- for (var i=0; i < ids.length; i++){
- // throw an error if no id provided
- if (!_hasId(ids[i])) {
- console.error('FFOS: Attempt to remove unsaved contact');
- errorCB(0);
- return;
- }
- // check if provided id actually exists
- var search = navigator.mozContacts.find({
- filterBy: ['id'], filterValue: ids[i], filterOp: 'equals'});
- search.onsuccess = function() {
- if (search.result.length === 0) {
- console.error('FFOS: Attempt to remove a non existing contact');
- errorCB(0);
- return;
- }
- var moz = search.result[0];
- var request = navigator.mozContacts.remove(moz);
- request.onsuccess = successCB;
- request.onerror = errorCB;
- };
- search.onerror = errorCB;
- }
-}
-
-
-var mozContactSearchFields = [['name', 'displayName'], ['givenName'],
- ['familyName'], ['email'], ['tel'], ['jobTitle'], ['note'],
- ['tel', 'phoneNumbers'], ['email', 'emails']];
-// Searching by nickname and additionalName is forbidden in 1.3 and below
-// Searching by name is forbidden in 1.2 and below
-
-// finds if a key is allowed and returns FFOS name if different
-function getMozSearchField(key) {
- if (mozContactSearchFields.indexOf([key]) >= 0) {
- return key;
- }
- for (var i=0; i < mozContactSearchFields.length; i++) {
- if (mozContactSearchFields[i].length > 1) {
- if (mozContactSearchFields[i][1] === key) {
- return mozContactSearchFields[i][0];
- }
- }
- }
- return false;
-}
-
-
-function _getAll(successCB, errorCB, params) {
- // [contactField, eventualMozContactField]
- var getall = navigator.mozContacts.getAll({});
- var contacts = [];
-
- getall.onsuccess = function() {
- if (getall.result) {
- contacts.push(createCordovaFromMozilla(getall.result));
- getall.continue();
- } else {
- successCB(contacts);
- }
- };
- getall.onerror = errorCB;
-}
-
-
-function search(successCB, errorCB, params) {
- var options = params[1] || {};
- if (!options.filter) {
- return _getAll(successCB, errorCB, params);
- }
- var filterBy = [];
- // filter and translate fields
- for (var i=0; i < params[0].length; i++) {
- var searchField = params[0][i];
- var mozField = getMozSearchField(searchField);
- if (searchField === 'name') {
- // Cordova uses name for search by all name fields.
- filterBy.push('givenName');
- filterBy.push('familyName');
- continue;
- }
- if (searchField === 'displayName' && 'init' in new mozContact()) {
- // ``init`` in ``mozContact`` indicates FFOS version 1.2 or below
- // Searching by name (in moz) is then forbidden
- console.log('FFOS ContactProxy: Unable to search by displayName on FFOS 1.2');
- continue;
- }
- if (mozField) {
- filterBy.push(mozField);
- } else {
- console.log('FXOS ContactProxy: inallowed field passed to search filtered out: ' + searchField);
- }
- }
-
- var mozOptions = {filterBy: filterBy, filterOp: 'startsWith'};
- if (!options.multiple) {
- mozOptions.filterLimit = 1;
- }
- mozOptions.filterValue = options.filter;
- var request = navigator.mozContacts.find(mozOptions);
- request.onsuccess = function() {
- var contacts = [];
- var mozContacts = request.result;
- var moz = mozContacts[0];
- for (var i=0; i < mozContacts.length; i++) {
- contacts.push(createCordovaFromMozilla(mozContacts[i]));
- }
- successCB(contacts);
- };
- request.onerror = errorCB;
-}
-
-
-module.exports = {
- save: saveContacts,
- remove: remove,
- search: search
-};
-
-require("cordova/firefoxos/commandProxy").add("Contacts", module.exports);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/fc255252/src/ios/CDVContact.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVContact.h b/src/ios/CDVContact.h
deleted file mode 100644
index 5187efc..0000000
--- a/src/ios/CDVContact.h
+++ /dev/null
@@ -1,136 +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.
- */
-
-#import <Foundation/Foundation.h>
-#import <AddressBook/ABAddressBook.h>
-#import <AddressBookUI/AddressBookUI.h>
-
-enum CDVContactError {
- UNKNOWN_ERROR = 0,
- INVALID_ARGUMENT_ERROR = 1,
- TIMEOUT_ERROR = 2,
- PENDING_OPERATION_ERROR = 3,
- IO_ERROR = 4,
- NOT_SUPPORTED_ERROR = 5,
- PERMISSION_DENIED_ERROR = 20
-};
-typedef NSUInteger CDVContactError;
-
-@interface CDVContact : NSObject {
- ABRecordRef record; // the ABRecord associated with this contact
- NSDictionary* returnFields; // dictionary of fields to return when performing search
-}
-
-@property (nonatomic, assign) ABRecordRef record;
-@property (nonatomic, strong) NSDictionary* returnFields;
-
-+ (NSDictionary*)defaultABtoW3C;
-+ (NSDictionary*)defaultW3CtoAB;
-+ (NSSet*)defaultW3CtoNull;
-+ (NSDictionary*)defaultObjectAndProperties;
-+ (NSDictionary*)defaultFields;
-
-+ (NSDictionary*)calcReturnFields:(NSArray*)fields;
-- (id)init;
-- (id)initFromABRecord:(ABRecordRef)aRecord;
-- (bool)setFromContactDict:(NSDictionary*)aContact asUpdate:(BOOL)bUpdate;
-
-+ (BOOL)needsConversion:(NSString*)W3Label;
-+ (CFStringRef)convertContactTypeToPropertyLabel:(NSString*)label;
-+ (NSString*)convertPropertyLabelToContactType:(NSString*)label;
-+ (BOOL)isValidW3ContactType:(NSString*)label;
-- (bool)setValue:(id)aValue forProperty:(ABPropertyID)aProperty inRecord:(ABRecordRef)aRecord asUpdate:(BOOL)bUpdate;
-
-- (NSDictionary*)toDictionary:(NSDictionary*)withFields;
-- (NSNumber*)getDateAsNumber:(ABPropertyID)datePropId;
-- (NSObject*)extractName;
-- (NSObject*)extractMultiValue:(NSString*)propertyId;
-- (NSObject*)extractAddresses;
-- (NSObject*)extractIms;
-- (NSObject*)extractOrganizations;
-- (NSObject*)extractPhotos;
-
-- (NSMutableDictionary*)translateW3Dict:(NSDictionary*)dict forProperty:(ABPropertyID)prop;
-- (bool)setMultiValueStrings:(NSArray*)fieldArray forProperty:(ABPropertyID)prop inRecord:(ABRecordRef)person asUpdate:(BOOL)bUpdate;
-- (bool)setMultiValueDictionary:(NSArray*)array forProperty:(ABPropertyID)prop inRecord:(ABRecordRef)person asUpdate:(BOOL)bUpdate;
-- (ABMultiValueRef)allocStringMultiValueFromArray:array;
-- (ABMultiValueRef)allocDictMultiValueFromArray:array forProperty:(ABPropertyID)prop;
-- (BOOL)foundValue:(NSString*)testValue inFields:(NSDictionary*)searchFields;
-- (BOOL)testStringValue:(NSString*)testValue forW3CProperty:(NSString*)property;
-- (BOOL)testDateValue:(NSString*)testValue forW3CProperty:(NSString*)property;
-- (BOOL)searchContactFields:(NSArray*)fields forMVStringProperty:(ABPropertyID)propId withValue:testValue;
-- (BOOL)testMultiValueStrings:(NSString*)testValue forProperty:(ABPropertyID)propId ofType:(NSString*)type;
-- (NSArray*)valuesForProperty:(ABPropertyID)propId inRecord:(ABRecordRef)aRecord;
-- (NSArray*)labelsForProperty:(ABPropertyID)propId inRecord:(ABRecordRef)aRecord;
-- (BOOL)searchContactFields:(NSArray*)fields forMVDictionaryProperty:(ABPropertyID)propId withValue:(NSString*)testValue;
-
-@end
-
-// generic ContactField types
-#define kW3ContactFieldType @"type"
-#define kW3ContactFieldValue @"value"
-#define kW3ContactFieldPrimary @"pref"
-// Various labels for ContactField types
-#define kW3ContactWorkLabel @"work"
-#define kW3ContactHomeLabel @"home"
-#define kW3ContactOtherLabel @"other"
-#define kW3ContactPhoneFaxLabel @"fax"
-#define kW3ContactPhoneMobileLabel @"mobile"
-#define kW3ContactPhonePagerLabel @"pager"
-#define kW3ContactUrlBlog @"blog"
-#define kW3ContactUrlProfile @"profile"
-#define kW3ContactImAIMLabel @"aim"
-#define kW3ContactImICQLabel @"icq"
-#define kW3ContactImMSNLabel @"msn"
-#define kW3ContactImYahooLabel @"yahoo"
-#define kW3ContactFieldId @"id"
-// special translation for IM field value and type
-#define kW3ContactImType @"type"
-#define kW3ContactImValue @"value"
-
-// Contact object
-#define kW3ContactId @"id"
-#define kW3ContactName @"name"
-#define kW3ContactFormattedName @"formatted"
-#define kW3ContactGivenName @"givenName"
-#define kW3ContactFamilyName @"familyName"
-#define kW3ContactMiddleName @"middleName"
-#define kW3ContactHonorificPrefix @"honorificPrefix"
-#define kW3ContactHonorificSuffix @"honorificSuffix"
-#define kW3ContactDisplayName @"displayName"
-#define kW3ContactNickname @"nickname"
-#define kW3ContactPhoneNumbers @"phoneNumbers"
-#define kW3ContactAddresses @"addresses"
-#define kW3ContactAddressFormatted @"formatted"
-#define kW3ContactStreetAddress @"streetAddress"
-#define kW3ContactLocality @"locality"
-#define kW3ContactRegion @"region"
-#define kW3ContactPostalCode @"postalCode"
-#define kW3ContactCountry @"country"
-#define kW3ContactEmails @"emails"
-#define kW3ContactIms @"ims"
-#define kW3ContactOrganizations @"organizations"
-#define kW3ContactOrganizationName @"name"
-#define kW3ContactTitle @"title"
-#define kW3ContactDepartment @"department"
-#define kW3ContactBirthday @"birthday"
-#define kW3ContactNote @"note"
-#define kW3ContactPhotos @"photos"
-#define kW3ContactCategories @"categories"
-#define kW3ContactUrls @"urls"