You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2014/07/30 21:06:21 UTC

[04/38] git commit: BB10: Add dummy Globalization implementation.

BB10: Add dummy Globalization implementation.

* All methods are now return a generic unsupported error.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/commit/6ab70440
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/6ab70440
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/6ab70440

Branch: refs/heads/lyon-g11n
Commit: 6ab70440c80214d0a65a09c7facc6b9edeee2bcb
Parents: f9abc8b
Author: Lianghui Chen <li...@blackberry.com>
Authored: Wed Jul 23 11:31:20 2014 -0400
Committer: Lianghui Chen <li...@blackberry.com>
Committed: Mon Jul 28 15:10:45 2014 -0400

----------------------------------------------------------------------
 .../native/src/globalization_js.cpp             | 25 ++++++
 .../native/src/globalization_ndk.cpp            | 83 ++++++++++++++++++++
 .../native/src/globalization_ndk.hpp            | 24 ++++++
 3 files changed, 132 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/6ab70440/src/blackberry10/native/src/globalization_js.cpp
----------------------------------------------------------------------
diff --git a/src/blackberry10/native/src/globalization_js.cpp b/src/blackberry10/native/src/globalization_js.cpp
index a496a1d..c195584 100644
--- a/src/blackberry10/native/src/globalization_js.cpp
+++ b/src/blackberry10/native/src/globalization_js.cpp
@@ -126,6 +126,31 @@ string GlobalizationJS::InvokeMethod(const string& command) {
 	std::string arg = command.substr(callbackIndex + 1, command.length());
 
 	// based on the command given, run the appropriate method in globalizationndk.cpp
+    if (strCommand == "getPreferredLanguage") {
+        return m_pGlobalizationController->getPreferredLanguage();
+    } else if (strCommand == "getLocaleName") {
+        return m_pGlobalizationController->getLocaleName();
+    } else if (strCommand == "dateToString") {
+        return m_pGlobalizationController->dateToString(arg);
+    } else if (strCommand == "stringToDate") {
+        return m_pGlobalizationController->stringToDate(arg);
+    } else if (strCommand == "getDatePattern") {
+        return m_pGlobalizationController->getDatePattern(arg);
+    } else if (strCommand == "getDateNames") {
+        return m_pGlobalizationController->getDateNames(arg);
+    } else if (strCommand == "isDayLightSavingsTime") {
+        return m_pGlobalizationController->isDayLightSavingsTime(arg);
+    } else if (strCommand == "getFirstDayOfWeek") {
+        return m_pGlobalizationController->getFirstDayOfWeek();
+    } else if (strCommand == "numberToString") {
+        return m_pGlobalizationController->numberToString(arg);
+    } else if (strCommand == "stringToNumber") {
+        return m_pGlobalizationController->stringToNumber(arg);
+    } else if (strCommand == "getNumberPattern") {
+        return m_pGlobalizationController->getNumberPattern(arg);
+    } else if (strCommand == "getCurrencyPattern") {
+        return m_pGlobalizationController->getCurrencyPattern(arg);
+	}
 
 	strCommand.append(";");
 	strCommand.append(command);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/6ab70440/src/blackberry10/native/src/globalization_ndk.cpp
----------------------------------------------------------------------
diff --git a/src/blackberry10/native/src/globalization_ndk.cpp b/src/blackberry10/native/src/globalization_ndk.cpp
index 4b13c58..715850e 100644
--- a/src/blackberry10/native/src/globalization_ndk.cpp
+++ b/src/blackberry10/native/src/globalization_ndk.cpp
@@ -20,8 +20,31 @@
 #include "globalization_ndk.hpp"
 #include "globalization_js.hpp"
 
+/*
+ * The following constants are defined based on Cordova Globalization
+ * plugin definition. They should match exactly.
+ * https://github.com/apache/cordova-plugin-globalization/blob/master/doc/index.md
+*/
+const int UNKNOWN_ERROR = 0;
+const int FORMATTING_ERROR = 1;
+const int PARSING_ERROR = 2;
+const int PATTERN_ERROR = 3;
+
 namespace webworks {
 
+std::string errorInJson(int code, const std::string& message)
+{
+    Json::Value error;
+    error["code"] = code;
+    error["message"] = message;
+
+    Json::Value root;
+    root["error"] = error;
+
+    Json::FastWriter writer;
+    return writer.write(root);
+}
+
 GlobalizationNDK::GlobalizationNDK(GlobalizationJS *parent) {
 	m_pParent = parent;
 }
@@ -29,4 +52,64 @@ GlobalizationNDK::GlobalizationNDK(GlobalizationJS *parent) {
 GlobalizationNDK::~GlobalizationNDK() {
 }
 
+std::string GlobalizationNDK::getPreferredLanguage()
+{
+    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+}
+
+std::string GlobalizationNDK::getLocaleName()
+{
+    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+}
+
+std::string GlobalizationNDK::dateToString(const std::string& args)
+{
+    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+}
+
+std::string GlobalizationNDK::stringToDate(const std::string& args)
+{
+    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+}
+
+std::string GlobalizationNDK::getDatePattern(const std::string& args)
+{
+    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+}
+
+std::string GlobalizationNDK::getDateNames(const std::string& args)
+{
+    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+}
+
+std::string GlobalizationNDK::isDayLightSavingsTime(const std::string& args)
+{
+    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+}
+
+std::string GlobalizationNDK::getFirstDayOfWeek()
+{
+    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+}
+
+std::string GlobalizationNDK::numberToString(const std::string& args)
+{
+    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+}
+
+std::string GlobalizationNDK::stringToNumber(const std::string& args)
+{
+    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+}
+
+std::string GlobalizationNDK::getNumberPattern(const std::string& args)
+{
+    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+}
+
+std::string GlobalizationNDK::getCurrencyPattern(const std::string& args)
+{
+    return errorInJson(UNKNOWN_ERROR, "Not supported!");
+}
+
 } /* namespace webworks */

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/6ab70440/src/blackberry10/native/src/globalization_ndk.hpp
----------------------------------------------------------------------
diff --git a/src/blackberry10/native/src/globalization_ndk.hpp b/src/blackberry10/native/src/globalization_ndk.hpp
index 57fbe60..d6a5b10 100644
--- a/src/blackberry10/native/src/globalization_ndk.hpp
+++ b/src/blackberry10/native/src/globalization_ndk.hpp
@@ -30,6 +30,30 @@ public:
 
 	// The extension methods are defined here
 
+    std::string getPreferredLanguage();
+
+    std::string getLocaleName();
+
+    std::string dateToString(const std::string& args);
+
+    std::string stringToDate(const std::string& args);
+
+    std::string getDatePattern(const std::string& args);
+
+    std::string getDateNames(const std::string& args);
+
+    std::string isDayLightSavingsTime(const std::string& args);
+
+    std::string getFirstDayOfWeek();
+
+    std::string numberToString(const std::string& args);
+
+    std::string stringToNumber(const std::string& args);
+
+    std::string getNumberPattern(const std::string& args);
+
+    std::string getCurrencyPattern(const std::string& args);
+
 private:
 	GlobalizationJS *m_pParent;
 };