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:23 UTC

[06/38] git commit: BB10: Remove unused codes.

BB10: Remove unused codes.


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/bdaf847f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/tree/bdaf847f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/diff/bdaf847f

Branch: refs/heads/lyon-g11n
Commit: bdaf847f40335cbf82c43b4f99093669641954da
Parents: a0724b4
Author: Lianghui Chen <li...@blackberry.com>
Authored: Wed Jul 23 10:17:45 2014 -0400
Committer: Lianghui Chen <li...@blackberry.com>
Committed: Mon Jul 28 15:10:45 2014 -0400

----------------------------------------------------------------------
 .../native/src/globalization_js.cpp             |  19 ---
 .../native/src/globalization_ndk.cpp            | 128 -------------------
 .../native/src/globalization_ndk.hpp            |  25 ----
 3 files changed, 172 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/bdaf847f/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 d0e2208..a40b44e 100644
--- a/src/blackberry10/native/src/globalization_js.cpp
+++ b/src/blackberry10/native/src/globalization_js.cpp
@@ -15,7 +15,6 @@
  */
 
 #include <string>
-#include "../public/tokenizer.h"
 #include "globalization_js.hpp"
 #include "globalization_ndk.hpp"
 
@@ -80,24 +79,6 @@ 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 == "testString") {
-		return m_pGlobalizationController->globalizationTestString();
-	} else if (strCommand == "testStringInput") {
-		return m_pGlobalizationController->globalizationTestString(arg);
-	} else if (strCommand == "globalizationProperty") {
-		// if arg exists we are setting property
-		if (arg != strCommand) {
-			m_pGlobalizationController->setGlobalizationProperty(arg);
-		} else {
-			return m_pGlobalizationController->getGlobalizationProperty();
-		}
-	} else if (strCommand == "testAsync") {
-		m_pGlobalizationController->globalizationTestAsync(callbackId, arg);
-	} else if (strCommand == "globalizationStartThread") {
-		return m_pGlobalizationController->globalizationStartThread(callbackId);
-	} else if (strCommand == "globalizationStopThread") {
-		return m_pGlobalizationController->globalizationStopThread();
-	}
 
 	strCommand.append(";");
 	strCommand.append(command);

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/bdaf847f/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 e25ae19..4b13c58 100644
--- a/src/blackberry10/native/src/globalization_ndk.cpp
+++ b/src/blackberry10/native/src/globalization_ndk.cpp
@@ -15,10 +15,8 @@
  */
 
 #include <string>
-#include <sstream>
 #include <json/reader.h>
 #include <json/writer.h>
-#include <pthread.h>
 #include "globalization_ndk.hpp"
 #include "globalization_js.hpp"
 
@@ -26,135 +24,9 @@ namespace webworks {
 
 GlobalizationNDK::GlobalizationNDK(GlobalizationJS *parent) {
 	m_pParent = parent;
-	globalizationProperty = 50;
-	globalizationThreadCount = 1;
-	m_thread = 0;
-	pthread_cond_t cond  = PTHREAD_COND_INITIALIZER;
-	pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-	threadHalt = true;
 }
 
 GlobalizationNDK::~GlobalizationNDK() {
 }
 
-// These methods are the true native code we intend to reach from WebWorks
-std::string GlobalizationNDK::globalizationTestString() {
-	return "Globalization Test Function";
-}
-
-// Take in input and return a value
-std::string GlobalizationNDK::globalizationTestString(const std::string& inputString) {
-	return "Globalization Test Function, got: " + inputString;
-}
-
-// Get an integer property
-std::string GlobalizationNDK::getGlobalizationProperty() {
-	stringstream ss;
-	ss << globalizationProperty;
-	return ss.str();
-}
-
-// set an integer property
-void GlobalizationNDK::setGlobalizationProperty(const std::string& inputString) {
-	globalizationProperty = (int) strtoul(inputString.c_str(), NULL, 10);
-}
-
-// Asynchronous callback with JSON data input and output
-void GlobalizationNDK::globalizationTestAsync(const std::string& callbackId, const std::string& inputString) {
-	// Parse the arg string as JSON
-	Json::FastWriter writer;
-	Json::Reader reader;
-	Json::Value root;
-	bool parse = reader.parse(inputString, root);
-
-	if (!parse) {
-		Json::Value error;
-		error["result"] = "Cannot parse JSON object";
-		m_pParent->NotifyEvent(callbackId + " " + writer.write(error));
-	} else {
-		root["result"] = root["value1"].asInt() + root["value2"].asInt();
-		m_pParent->NotifyEvent(callbackId + " " + writer.write(root));
-	}
-}
-
-// Thread functions
-// The following functions are for controlling a Thread in the extension
-
-// The actual thread (must appear before the startThread method)
-// Loops and runs the callback method
-void* GlobalizationThread(void* parent) {
-	GlobalizationNDK *pParent = static_cast<GlobalizationNDK *>(parent);
-
-	// Loop calls the callback function and continues until stop is set
-	while (!pParent->isThreadHalt()) {
-		sleep(1);
-		pParent->globalizationThreadCallback();
-	}
-
-	return NULL;
-}
-
-// Starts the thread and returns a message on status
-std::string GlobalizationNDK::globalizationStartThread(const std::string& callbackId) {
-	if (!m_thread) {
-		int rc;
-	    rc = pthread_mutex_lock(&mutex);
-	    threadHalt = false;
-	    rc = pthread_cond_signal(&cond);
-	    rc = pthread_mutex_unlock(&mutex);
-
-		pthread_attr_t thread_attr;
-		pthread_attr_init(&thread_attr);
-		pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE);
-
-		pthread_create(&m_thread, &thread_attr, GlobalizationThread,
-				static_cast<void *>(this));
-		pthread_attr_destroy(&thread_attr);
-		threadCallbackId = callbackId;
-		return "Thread Started";
-	} else {
-		return "Thread Running";
-	}
-}
-
-// Sets the stop value
-std::string GlobalizationNDK::globalizationStopThread() {
-	int rc;
-	// Request thread to set prevent sleep to false and terminate
-	rc = pthread_mutex_lock(&mutex);
-	threadHalt = true;
-	rc = pthread_cond_signal(&cond);
-	rc = pthread_mutex_unlock(&mutex);
-
-    // Wait for the thread to terminate.
-    void *exit_status;
-    rc = pthread_join(m_thread, &exit_status) ;
-
-	// Clean conditional variable and mutex
-	pthread_cond_destroy(&cond);
-	pthread_mutex_destroy(&mutex);
-
-	m_thread = 0;
-	threadHalt = true;
-	return "Thread stopped";
-}
-
-// The callback method that sends an event through JNEXT
-void GlobalizationNDK::globalizationThreadCallback() {
-	Json::FastWriter writer;
-	Json::Value root;
-	root["threadCount"] = globalizationThreadCount++;
-	m_pParent->NotifyEvent(threadCallbackId + " " + writer.write(root));
-}
-
-// getter for the stop value
-bool GlobalizationNDK::isThreadHalt() {
-	int rc;
-	bool isThreadHalt;
-	rc = pthread_mutex_lock(&mutex);
-	isThreadHalt = threadHalt;
-	rc = pthread_mutex_unlock(&mutex);
-	return isThreadHalt;
-}
-
 } /* namespace webworks */

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/bdaf847f/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 50f0555..57fbe60 100644
--- a/src/blackberry10/native/src/globalization_ndk.hpp
+++ b/src/blackberry10/native/src/globalization_ndk.hpp
@@ -18,7 +18,6 @@
 #define GLOBALIZATIONNDK_HPP_
 
 #include <string>
-#include <pthread.h>
 
 class GlobalizationJS;
 
@@ -30,33 +29,9 @@ public:
 	virtual ~GlobalizationNDK();
 
 	// The extension methods are defined here
-	std::string globalizationTestString();
-
-	std::string globalizationTestString(const std::string& inputString);
-
-	std::string getGlobalizationProperty();
-
-	void setGlobalizationProperty(const std::string& inputString);
-
-	void globalizationTestAsync(const std::string& callbackId, const std::string& inputString);
-
-	std::string globalizationStartThread(const std::string& callbackId);
-
-	std::string globalizationStopThread();
-
-	bool isThreadHalt();
-
-	void globalizationThreadCallback();
 
 private:
 	GlobalizationJS *m_pParent;
-	int globalizationProperty;
-	int globalizationThreadCount;
-	bool threadHalt;
-	std::string threadCallbackId;
-	pthread_t m_thread;
-	pthread_cond_t cond;
-	pthread_mutex_t mutex;
 };
 
 } // namespace webworks