incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tim...@apache.org
Subject webworks commit: [CB-1678] - added simple echo plugin
Date Wed, 24 Oct 2012 01:10:34 GMT
Updated Branches:
  refs/heads/bb10_ext_qnx feba03c38 -> 939ad4e51


[CB-1678] - added simple echo plugin


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/commit/939ad4e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/tree/939ad4e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/diff/939ad4e5

Branch: refs/heads/bb10_ext_qnx
Commit: 939ad4e51a6928312d01ea6aea97ac4929521a71
Parents: feba03c
Author: Tim Kim <tim.kim@nitobi.com>
Authored: Tue Oct 23 18:10:18 2012 -0700
Committer: Tim Kim <tim.kim@nitobi.com>
Committed: Tue Oct 23 18:10:18 2012 -0700

----------------------------------------------------------------------
 build.xml                                          |    2 +-
 framework/ext-qnx/Makefile                         |    8 -
 framework/ext-qnx/common.mk                        |   39 --
 framework/ext-qnx/cordova/echo/Makefile            |    8 +
 framework/ext-qnx/cordova/echo/common.mk           |   39 ++
 framework/ext-qnx/cordova/echo/js/client.js        |   24 ++
 framework/ext-qnx/cordova/echo/js/index.js         |   70 ++++
 framework/ext-qnx/cordova/echo/js/manifest.json    |    5 +
 framework/ext-qnx/cordova/echo/nto/Makefile        |    8 +
 framework/ext-qnx/cordova/echo/nto/arm/Makefile    |    8 +
 .../ext-qnx/cordova/echo/nto/arm/so.le-v7/Makefile |    1 +
 .../ext-qnx/cordova/echo/nto/arm/so.le-v7/echo.o   |  Bin 0 -> 15288 bytes
 .../cordova/echo/nto/arm/so.le-v7/libecho.so       |  Bin 0 -> 47613 bytes
 .../cordova/echo/nto/arm/so.le-v7/libechoS.a       |  Bin 0 -> 107282 bytes
 .../ext-qnx/cordova/echo/nto/arm/so.le-v7/plugin.o |  Bin 0 -> 63776 bytes
 .../cordova/echo/nto/arm/so.le-v7/tokenizer.o      |  Bin 0 -> 22044 bytes
 framework/ext-qnx/cordova/echo/public/plugin.cpp   |  320 +++++++++++++++
 framework/ext-qnx/cordova/echo/public/plugin.h     |   70 ++++
 .../ext-qnx/cordova/echo/public/tokenizer.cpp      |  222 ++++++++++
 framework/ext-qnx/cordova/echo/public/tokenizer.h  |   55 +++
 framework/ext-qnx/cordova/echo/src/echo.cpp        |   87 ++++
 framework/ext-qnx/cordova/echo/src/echo.hpp        |   39 ++
 framework/ext-qnx/nto/Makefile                     |    8 -
 framework/ext-qnx/nto/arm/Makefile                 |    8 -
 framework/ext-qnx/nto/arm/so.le-v7/Makefile        |    1 -
 25 files changed, 957 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index e9976bc..5c299e2 100644
--- a/build.xml
+++ b/build.xml
@@ -96,7 +96,7 @@
     <!-- BUILD QNX EXTENSION -->
     
     <target name="build-qnx-extension">
-
+        
         <!-- Copy Ext -->
         <mkdir dir="${build.dir}/${qnx.ext.path}" />
         <copy todir="${build.dir}/${qnx.ext.path}">

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/Makefile
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/Makefile b/framework/ext-qnx/Makefile
deleted file mode 100644
index 1f25400..0000000
--- a/framework/ext-qnx/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=OS
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/common.mk
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/common.mk b/framework/ext-qnx/common.mk
deleted file mode 100644
index f6d862c..0000000
--- a/framework/ext-qnx/common.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-ifndef QCONFIG
-QCONFIG=qconfig.mk
-endif
-include $(QCONFIG)
-
-USEFILE=
-
-EXTRA_SRCVPATH+=$(PROJECT_ROOT)/public \
-    $(PROJECT_ROOT)/src \
-    
-# Extra include path for libfreetype and for target overrides and patches
-EXTRA_INCVPATH+=$(QNX_TARGET)/usr/include/freetype2 \
-	$(QNX_TARGET)/../target-override/usr/include
-
-# Extra library search path for target overrides and patches
-EXTRA_LIBVPATH+=$(QNX_TARGET)/../target-override/$(CPUVARDIR)/lib \
-	$(QNX_TARGET)/../target-override/$(CPUVARDIR)/usr/lib
-
-# Compiler options for enhanced security and recording the compiler options in release builds
-CCFLAGS+=-fstack-protector-all -D_FORTIFY_SOURCE=2 \
-	$(if $(filter g so shared,$(VARIANTS)),,-fPIE) \
-	$(if $(filter g,$(VARIANTS)),,-frecord-gcc-switches)
-
-# Linker options for enhanced security
-LDFLAGS+=-Wl,-z,relro -Wl,-z,now $(if $(filter g so shared,$(VARIANTS)),,-pie)
-
-# Add your required library names, here
-LIBS+=
-
-include $(MKFILES_ROOT)/qmacros.mk
-
-# Suppress the _g suffix from the debug variant
-BUILDNAME=$(IMAGE_PREF_$(BUILD_TYPE))$(NAME)$(IMAGE_SUFF_$(BUILD_TYPE))
-BUILDNAME_SAR=$(IMAGE_PREF_AR)$(NAME)S$(IMAGE_SUFF_AR)
-
-include $(MKFILES_ROOT)/qtargets.mk
-
-OPTIMIZE_TYPE_g=none
-OPTIMIZE_TYPE=$(OPTIMIZE_TYPE_$(filter g, $(VARIANTS)))

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/Makefile
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/Makefile b/framework/ext-qnx/cordova/echo/Makefile
new file mode 100644
index 0000000..1f25400
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/Makefile
@@ -0,0 +1,8 @@
+LIST=OS
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/common.mk
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/common.mk b/framework/ext-qnx/cordova/echo/common.mk
new file mode 100644
index 0000000..f6d862c
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/common.mk
@@ -0,0 +1,39 @@
+ifndef QCONFIG
+QCONFIG=qconfig.mk
+endif
+include $(QCONFIG)
+
+USEFILE=
+
+EXTRA_SRCVPATH+=$(PROJECT_ROOT)/public \
+    $(PROJECT_ROOT)/src \
+    
+# Extra include path for libfreetype and for target overrides and patches
+EXTRA_INCVPATH+=$(QNX_TARGET)/usr/include/freetype2 \
+	$(QNX_TARGET)/../target-override/usr/include
+
+# Extra library search path for target overrides and patches
+EXTRA_LIBVPATH+=$(QNX_TARGET)/../target-override/$(CPUVARDIR)/lib \
+	$(QNX_TARGET)/../target-override/$(CPUVARDIR)/usr/lib
+
+# Compiler options for enhanced security and recording the compiler options in release builds
+CCFLAGS+=-fstack-protector-all -D_FORTIFY_SOURCE=2 \
+	$(if $(filter g so shared,$(VARIANTS)),,-fPIE) \
+	$(if $(filter g,$(VARIANTS)),,-frecord-gcc-switches)
+
+# Linker options for enhanced security
+LDFLAGS+=-Wl,-z,relro -Wl,-z,now $(if $(filter g so shared,$(VARIANTS)),,-pie)
+
+# Add your required library names, here
+LIBS+=
+
+include $(MKFILES_ROOT)/qmacros.mk
+
+# Suppress the _g suffix from the debug variant
+BUILDNAME=$(IMAGE_PREF_$(BUILD_TYPE))$(NAME)$(IMAGE_SUFF_$(BUILD_TYPE))
+BUILDNAME_SAR=$(IMAGE_PREF_AR)$(NAME)S$(IMAGE_SUFF_AR)
+
+include $(MKFILES_ROOT)/qtargets.mk
+
+OPTIMIZE_TYPE_g=none
+OPTIMIZE_TYPE=$(OPTIMIZE_TYPE_$(filter g, $(VARIANTS)))

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/js/client.js
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/js/client.js b/framework/ext-qnx/cordova/echo/js/client.js
new file mode 100644
index 0000000..d50e3ad
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/js/client.js
@@ -0,0 +1,24 @@
+/*
+* 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 _self = {},
+    _ID = require("./manifest.json").namespace;
+
+_self.doEcho = function () {
+    return window.webworks.execSync(_ID, "doEcho", null);
+};
+
+module.exports = _self;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/js/index.js
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/js/index.js b/framework/ext-qnx/cordova/echo/js/index.js
new file mode 100644
index 0000000..3c8702c
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/js/index.js
@@ -0,0 +1,70 @@
+/*
+ * 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 echoJNext,
+    _event = require("../../lib/event");
+
+module.exports = {
+    doEcho: function (success, fail, args, env) {
+        try {
+            success(echoJNext.getEchoJNext());
+        } catch (e) {
+            fail(-1, e);
+        }
+    }
+};
+
+///////////////////////////////////////////////////////////////////
+// JavaScript wrapper for JNEXT plugin
+///////////////////////////////////////////////////////////////////
+
+JNEXT.EchoJNext = function ()
+{   
+    var _self = this;
+
+    _self.getEchoJNext = function () {
+        return JNEXT.invoke(_self._id, "doEcho");
+    };
+
+    _self.getId = function () {
+        return _self._id;
+    };
+
+    _self.init = function () {
+        if (!JNEXT.require("echoJnext")) {
+            return false;
+        }
+
+        _self._id = JNEXT.createObject("echoJnext.Echo");
+
+        if (!_self._id || _self._id === "") {
+            return false;
+        }
+
+        JNEXT.registerEvents(_self);
+    };
+
+    _self.onEvent = function (strData) {
+        var arData = strData.split(" "),
+            strEventId = arData[0],
+            arg = arData[1];
+    };
+    
+    _self._id = "";
+    
+    _self.init();
+};
+
+echoJNext = new JNEXT.EchoJNext();

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/js/manifest.json
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/js/manifest.json b/framework/ext-qnx/cordova/echo/js/manifest.json
new file mode 100644
index 0000000..d14e79e
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/js/manifest.json
@@ -0,0 +1,5 @@
+{
+    "global": false,
+    "namespace": "cordova.echo",
+    "dependencies": []
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/nto/Makefile
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/nto/Makefile b/framework/ext-qnx/cordova/echo/nto/Makefile
new file mode 100644
index 0000000..0cc5eae
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/nto/Makefile
@@ -0,0 +1,8 @@
+LIST=CPU
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/nto/arm/Makefile
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/nto/arm/Makefile b/framework/ext-qnx/cordova/echo/nto/arm/Makefile
new file mode 100644
index 0000000..0e22650
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/nto/arm/Makefile
@@ -0,0 +1,8 @@
+LIST=VARIANT
+ifndef QRECURSE
+QRECURSE=recurse.mk
+ifdef QCONFIG
+QRDIR=$(dir $(QCONFIG))
+endif
+endif
+include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/Makefile
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/Makefile b/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/Makefile
new file mode 100644
index 0000000..0f9d7b9
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/Makefile
@@ -0,0 +1 @@
+include ../../../common.mk

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/echo.o
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/echo.o b/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/echo.o
new file mode 100644
index 0000000..e179b43
Binary files /dev/null and b/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/echo.o differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/libecho.so
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/libecho.so b/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/libecho.so
new file mode 100755
index 0000000..cd2d647
Binary files /dev/null and b/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/libecho.so differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/libechoS.a
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/libechoS.a b/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/libechoS.a
new file mode 100644
index 0000000..64f0861
Binary files /dev/null and b/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/libechoS.a differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/plugin.o
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/plugin.o b/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/plugin.o
new file mode 100644
index 0000000..75a3db0
Binary files /dev/null and b/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/plugin.o differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/tokenizer.o
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/tokenizer.o b/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/tokenizer.o
new file mode 100644
index 0000000..811b0a3
Binary files /dev/null and b/framework/ext-qnx/cordova/echo/nto/arm/so.le-v7/tokenizer.o differ

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/public/plugin.cpp
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/public/plugin.cpp b/framework/ext-qnx/cordova/echo/public/plugin.cpp
new file mode 100644
index 0000000..6906275
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/public/plugin.cpp
@@ -0,0 +1,320 @@
+#include "plugin.h"
+#include "tokenizer.h"
+
+#ifdef _WINDOWS
+#include <windows.h>
+BOOL APIENTRY DllMain( HANDLE hModule,
+                       DWORD ul_reason_for_call,
+                       LPVOID lpReserved )
+{
+    return TRUE;
+}
+#else
+#include <errno.h>
+#include <string.h>
+
+extern int errno;
+#endif
+
+SendPluginEv SendPluginEvent;
+
+string g_GetSysErrMsg( void )
+{
+    string strError = "Unknown";
+    // Problem loading
+#ifdef _WINDOWS
+    int nErrorCode = GetLastError();
+    LPTSTR s;
+    if ( ::FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+    NULL, nErrorCode, 0, ( LPTSTR ) &s, 0, NULL ) )
+    {
+        strError = s;
+    }
+    else
+    {
+        char szBuf[ 20 ];
+        _snprintf_s( szBuf, _countof(szBuf), 19, "%d", nErrorCode );
+        strError = szBuf;
+    }
+#else
+    char szError[80];
+    if ( strerror_r( errno, szError, sizeof(szError)  ) )
+    {
+        strError = "no description found";
+    }
+    else
+    {
+        strError = szError;
+    }
+#endif
+    return strError;
+}
+
+void g_sleep( unsigned int mseconds )
+{
+#ifdef _WINDOWS
+    Sleep( mseconds );
+#else
+    usleep( mseconds * 1000 );
+#endif
+}
+
+string& g_trim( string& str )
+{
+    // Whitespace characters
+    char whspc[] = " \t\r\n\v\f";
+
+    // Whack off first part
+    size_t pos = str.find_first_not_of( whspc );
+
+    if ( pos != string::npos )
+        str.replace( 0, pos, "" );
+
+    // Whack off trailing stuff
+    pos = str.find_last_not_of( whspc );
+
+    if ( pos != string::npos )
+        str.replace( pos + 1, str.length() - pos, "" );
+
+    return str;
+}
+
+void g_tokenize( const string& str, const string& delimiters, vector<string>&
tokens )
+{
+    tokenize( str, tokens, delimiters );
+}
+
+char* SetEventFunc( SendPluginEv funcPtr )
+{
+    static char * szObjList = onGetObjList();
+    SendPluginEvent = funcPtr;
+    return szObjList;
+}
+
+
+const int nMAXSIZE = 512;
+char* g_pszRetVal = NULL;
+
+//-----------------------------------------------------------
+// Map from an object Id to an object instance
+//-----------------------------------------------------------
+typedef std::map<string, JSExt*> StringToJExt_T;
+
+//-----------------------------------------------------------
+// Map from a browser context to an id mapping
+//-----------------------------------------------------------
+typedef std::map<void*, StringToJExt_T*> VoidToMap_T;
+
+VoidToMap_T g_context2Map;
+
+class GlobalSharedModule
+{
+
+public:
+    GlobalSharedModule( void )
+    {
+        g_pszRetVal = new char[ nMAXSIZE ];
+    }
+
+    ~GlobalSharedModule()
+    {
+        delete [] g_pszRetVal;
+
+        VoidToMap_T::iterator posMaps;
+
+        for ( posMaps = g_context2Map.begin(); posMaps != g_context2Map.end(); ++posMaps
)
+        {
+            StringToJExt_T& id2Obj = *posMaps->second;
+            StringToJExt_T::iterator posMap;
+
+            for ( posMap = id2Obj.begin(); posMap != id2Obj.end(); ++posMap )
+            {
+                JSExt* pJSExt = posMap->second;
+
+                if ( pJSExt->CanDelete() )
+                {
+                    delete pJSExt;
+                }
+            }
+
+            id2Obj.erase( id2Obj.begin(), id2Obj.end() );
+        }
+
+        g_context2Map.erase( g_context2Map.begin(), g_context2Map.end() );
+    }
+};
+
+GlobalSharedModule g_sharedModule;
+
+char* g_str2global( const string& strRetVal )
+{
+    int nLen = strRetVal.size();
+
+    if ( nLen >= nMAXSIZE )
+    {
+        delete [] g_pszRetVal;
+        g_pszRetVal = new char[ nLen + 1 ];
+    }
+
+    else
+    {
+        // To minimaize the number of memory reallocations, the assumption
+        // is that in most times this will be the case
+        delete [] g_pszRetVal;
+        g_pszRetVal = new char[ nMAXSIZE ];
+    }
+
+    strcpy( g_pszRetVal, strRetVal.c_str() );
+    return g_pszRetVal;
+}
+
+bool g_unregisterObject( const string& strObjId, void* pContext )
+{
+    // Called by the plugin extension implementation
+    // if the extension handles the deletion of its object
+
+    StringToJExt_T * pID2Obj = NULL;
+
+    VoidToMap_T::iterator iter = g_context2Map.find( pContext );
+
+    if ( iter != g_context2Map.end() )
+    {
+        pID2Obj = iter->second;
+    }
+    else
+    {
+        return false;
+    }
+
+    StringToJExt_T& mapID2Obj = *pID2Obj;
+
+    StringToJExt_T::iterator r = mapID2Obj.find( strObjId );
+
+    if ( r == mapID2Obj.end() )
+    {
+        return false;
+    }
+
+    mapID2Obj.erase( strObjId );
+    return true;
+}
+
+char* InvokeFunction( const char* szCommand, void* pContext )
+{
+    StringToJExt_T * pID2Obj = NULL;
+
+    VoidToMap_T::iterator iter = g_context2Map.find( pContext );
+
+    if ( iter != g_context2Map.end() )
+    {
+        pID2Obj = iter->second;
+    }
+    else
+    {
+        pID2Obj = new StringToJExt_T;
+        g_context2Map[ pContext ] = pID2Obj;
+    }
+
+    StringToJExt_T& mapID2Obj = *pID2Obj;
+
+    string strFullCommand = szCommand;
+    vector<string> arParams;
+    g_tokenize( strFullCommand, " ", arParams );
+    string strCommand = arParams[ 0 ];
+    string strRetVal = szERROR;
+
+    if ( strCommand == szCREATE )
+    {
+        string strClassName = arParams[ 1 ];
+        string strObjId = arParams[ 2 ];
+
+        StringToJExt_T::iterator r = mapID2Obj.find( strObjId );
+
+        if ( r != mapID2Obj.end() )
+        {
+            strRetVal += strObjId;
+            strRetVal += " :Object already exists.";
+            return g_str2global( strRetVal );
+        }
+
+        JSExt* pJSExt = onCreateObject( strClassName, strObjId );
+
+        if ( pJSExt == NULL )
+        {
+            strRetVal += strObjId;
+            strRetVal += " :Unknown object type ";
+            strRetVal += strClassName;
+            return g_str2global( strRetVal );
+        }
+
+        pJSExt->m_pContext = pContext;
+        mapID2Obj[ strObjId ] = pJSExt;
+
+        strRetVal = szOK;
+        strRetVal += strObjId;
+        return g_str2global( strRetVal );
+    }
+    else
+    if ( strCommand == szINVOKE )
+    {
+        string strObjId = arParams[ 1 ];
+        string strMethod = arParams[ 2 ];
+
+        StringToJExt_T::iterator r = mapID2Obj.find( strObjId );
+
+        if ( r == mapID2Obj.end() )
+        {
+            strRetVal += strObjId;
+            strRetVal += " :No object found for id.";
+            return g_str2global( strRetVal );
+        }
+
+        JSExt* pJSExt = r->second;
+
+        size_t nLoc = strFullCommand.find( strObjId );
+
+        if ( nLoc == string::npos )
+        {
+            strRetVal += strObjId;
+            strRetVal += " :Internal InvokeMethod error.";
+            return g_str2global( strRetVal );
+        }
+
+        if ( strMethod == szDISPOSE )
+        {
+            StringToJExt_T::iterator r = mapID2Obj.find( strObjId );
+
+            if ( r == mapID2Obj.end() )
+            {
+                strRetVal = szERROR;
+                strRetVal += strObjId;
+                return g_str2global( strRetVal );
+            }
+
+            JSExt * pJSExt = mapID2Obj[ strObjId ];
+
+            if ( pJSExt->CanDelete() )
+            {
+                delete pJSExt;
+            }
+
+            mapID2Obj.erase( strObjId );
+            strRetVal = szOK;
+            strRetVal += strObjId;
+            return g_str2global( strRetVal );
+        }
+
+        size_t nSuffixLoc = nLoc + strObjId.size();
+        string strInvoke = strFullCommand.substr( nSuffixLoc );
+        strInvoke = g_trim( strInvoke );
+        strRetVal = pJSExt->InvokeMethod( strInvoke );
+        return g_str2global( strRetVal );
+    }
+
+    strRetVal += " :Unknown command ";
+    strRetVal += strCommand;
+    return g_str2global( strRetVal );
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/public/plugin.h
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/public/plugin.h b/framework/ext-qnx/cordova/echo/public/plugin.h
new file mode 100644
index 0000000..4ef7116
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/public/plugin.h
@@ -0,0 +1,70 @@
+#ifndef _PLUGIN_H
+#define _PLUGIN_H
+
+#include <map>
+#include <string>
+#include <vector>
+#include <unistd.h>
+//#include "tokenizer.h"
+
+using namespace std;
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//%% Functions exported by this DLL
+//%% Should always be only SetEventFunc and InvokeFunction
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+// g++ requires extern "C" otherwise the names of SetEventFunc and InvokeFunction
+// are mangled C++ style. MS Visual Studio doesn't seem to care though.
+extern "C"
+{
+    typedef void (*SendPluginEv)( const char* szEvent, void* pContext );
+    char* SetEventFunc(SendPluginEv funcPtr);
+    char* InvokeFunction( const char* szCommand, void* pContext );
+}
+
+// JNEXT Framework function of the form:
+// typedef void (*SendPluginEv)( const char* szEvent );
+// used to notify JavaScript of an asynchronous event
+extern SendPluginEv SendPluginEvent;
+
+/////////////////////////////////////////////////////////////////////////
+// Constants and methods common to all JNEXT extensions types
+/////////////////////////////////////////////////////////////////////////
+#define szERROR         "Error "
+#define szOK            "Ok "
+
+#define szDISPOSE       "Dispose"
+#define szINVOKE        "InvokeMethod"
+#define szCREATE        "CreateObj"
+
+/////////////////////////////////////////////////////////////////////////
+// Utility functions
+/////////////////////////////////////////////////////////////////////////
+string& g_trim( string& str );
+void g_tokenize(const string& str,const string& delimiters, vector<string>&
tokens);
+char* g_str2static( const string& strRetVal );
+void g_sleep( unsigned int mseconds );
+bool g_unregisterObject( const string& strObjId, void* pContext );
+
+
+/////////////////////////////////////////////////////////////////////////
+// Abstract extension object
+/////////////////////////////////////////////////////////////////////////
+class JSExt
+{
+public:
+    virtual ~JSExt() {};
+    virtual string InvokeMethod( const string& strCommand ) = 0;
+    virtual bool CanDelete( void ) = 0;
+    virtual void TryDelete( void ) {}
+public:
+    void* m_pContext;
+};
+
+/////////////////////////////////////////////////////////////////////////
+// Callback functions to be implemented by the plugin implementation
+/////////////////////////////////////////////////////////////////////////
+extern char* onGetObjList( void );
+extern JSExt* onCreateObject( const string& strClassName, const string& strObjId
);
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/public/tokenizer.cpp
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/public/tokenizer.cpp b/framework/ext-qnx/cordova/echo/public/tokenizer.cpp
new file mode 100644
index 0000000..4a39573
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/public/tokenizer.cpp
@@ -0,0 +1,222 @@
+/************************************************************************
+The zlib/libpng License
+
+Copyright (c) 2006 Joerg Wiedenmann
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from
+the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented;
+you must not claim that you wrote the original software.
+If you use this software in a product, an acknowledgment
+in the product documentation would be appreciated but is
+not required.
+
+2. Altered source versions must be plainly marked as such,
+and must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source distribution.
+
+***********************************************************************/
+
+/********************************************************************
+	created:	2006-01-28
+	filename: 	tokenizer.cpp
+	author:		J�rg Wiedenmann
+	
+	purpose:	A tokenizer function which provides a very
+				customizable way of breaking up strings.
+
+	history:	2006-01-28, Original version
+				2006-03-04, Fixed a small parsing bug, thanks Elias.
+*********************************************************************/
+
+#include "tokenizer.h"
+
+using namespace std;
+
+void tokenize ( const string& str, vector<string>& result,
+			   const string& delimiters, const string& delimiters_preserve,
+			   const string& quote, const string& esc )
+{
+	// clear the vector
+	if ( false == result.empty() )
+	{
+		result.clear();
+	}
+
+	string::size_type pos = 0; // the current position (char) in the string
+	char ch = 0; // buffer for the current character
+	char delimiter = 0;	// the buffer for the delimiter char which
+							// will be added to the tokens if the delimiter
+							// is preserved
+	char current_quote = 0; // the char of the current open quote
+	bool quoted = false; // indicator if there is an open quote
+	string token;  // string buffer for the token
+	bool token_complete = false; // indicates if the current token is
+								 // read to be added to the result vector
+	string::size_type len = str.length();  // length of the input-string
+
+	// for every char in the input-string
+	while ( len > pos )
+	{
+		// get the character of the string and reset the delimiter buffer
+		ch = str.at(pos);
+		delimiter = 0;
+
+		// assume ch isn't a delimiter
+		bool add_char = true;
+
+		// check ...
+
+		// ... if the delimiter is an escaped character
+		bool escaped = false; // indicates if the next char is protected
+		if ( false == esc.empty() ) // check if esc-chars are  provided
+		{
+			if ( string::npos != esc.find_first_of(ch) )
+			{
+				// get the escaped char
+				++pos;
+				if ( pos < len ) // if there are more chars left
+				{
+					// get the next one
+					ch = str.at(pos);
+
+					// add the escaped character to the token
+					add_char = true;
+				}
+				else // cannot get any more characters
+				{
+					// don't add the esc-char
+					add_char = false;
+				}
+
+				// ignore the remaining delimiter checks
+				escaped = true;
+			}
+		}
+
+		// ... if the delimiter is a quote
+		if ( false == quote.empty() && false == escaped )
+		{
+			// if quote chars are provided and the char isn't protected
+			if ( string::npos != quote.find_first_of(ch) )
+			{
+				// if not quoted, set state to open quote and set
+				// the quote character
+				if ( false == quoted )
+				{
+					quoted = true;
+					current_quote = ch;
+
+					// don't add the quote-char to the token
+					add_char = false;
+				}
+				else // if quote is open already
+				{
+					// check if it is the matching character to close it
+					if ( current_quote == ch )
+					{
+						// close quote and reset the quote character
+						quoted = false;
+						current_quote = 0;
+
+						// don't add the quote-char to the token
+						add_char = false;
+					}
+				} // else
+			}
+		}
+
+		// ... if the delimiter isn't preserved
+		if ( false == delimiters.empty() && false == escaped &&
+			 false == quoted )
+		{
+			// if a delimiter is provided and the char isn't protected by
+			// quote or escape char
+			if ( string::npos != delimiters.find_first_of(ch) )
+			{
+				// if ch is a delimiter and the token string isn't empty
+				// the token is complete
+				if ( false == token.empty() ) // BUGFIX: 2006-03-04
+				{
+					token_complete = true;
+				}
+
+				// don't add the delimiter to the token
+				add_char = false;
+			}
+		}
+
+		// ... if the delimiter is preserved - add it as a token
+		bool add_delimiter = false;
+		if ( false == delimiters_preserve.empty() && false == escaped &&
+			 false == quoted )
+		{
+			// if a delimiter which will be preserved is provided and the
+			// char isn't protected by quote or escape char
+			if ( string::npos != delimiters_preserve.find_first_of(ch) )
+			{
+				// if ch is a delimiter and the token string isn't empty
+				// the token is complete
+				if ( false == token.empty() ) // BUGFIX: 2006-03-04
+				{
+					token_complete = true;
+				}
+
+				// don't add the delimiter to the token
+				add_char = false;
+
+				// add the delimiter
+				delimiter = ch;
+				add_delimiter = true;
+			}
+		}
+
+
+		// add the character to the token
+		if ( true == add_char )
+		{
+			// add the current char
+			token.push_back( ch );
+		}
+
+		// add the token if it is complete
+		if ( true == token_complete && false == token.empty() )
+		{
+			// add the token string
+			result.push_back( token );
+
+			// clear the contents
+			token.clear();
+
+			// build the next token
+			token_complete = false;
+		}
+
+		// add the delimiter
+		if ( true == add_delimiter )
+		{
+			// the next token is the delimiter
+			string delim_token;
+			delim_token.push_back( delimiter );
+			result.push_back( delim_token );
+
+			// REMOVED: 2006-03-04, Bugfix
+		}
+
+		// repeat for the next character
+		++pos;
+	} // while
+
+	// add the final token
+	if ( false == token.empty() )
+	{
+		result.push_back( token );
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/public/tokenizer.h
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/public/tokenizer.h b/framework/ext-qnx/cordova/echo/public/tokenizer.h
new file mode 100644
index 0000000..75f567c
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/public/tokenizer.h
@@ -0,0 +1,55 @@
+/************************************************************************
+The zlib/libpng License
+
+Copyright (c) 2006 Joerg Wiedenmann
+
+This software is provided 'as-is', without any express or implied warranty.
+In no event will the authors be held liable for any damages arising from
+the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented;
+	you must not claim that you wrote the original software.
+	If you use this software in a product, an acknowledgment
+	in the product documentation would be appreciated but is
+	not required.
+
+2. Altered source versions must be plainly marked as such,
+	and must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source distribution.
+
+***********************************************************************/
+
+/********************************************************************
+	created:	2006-01-28
+	filename: 	tokenizer.cpp
+	author:		J�rg Wiedenmann
+
+	purpose:	A tokenizer function which provides a very
+				customizable way of breaking up strings.
+*********************************************************************/
+
+#include <vector>
+#include <string>
+using namespace std;
+
+// Function to break up a string into tokens
+//
+// Parameters:
+//-----------
+// str = the input string that will be tokenized
+// result = the tokens for str
+// delimiters = the delimiter characters
+// delimiters preserve = same as above, but the delimiter characters
+//		will be put into the result as a token
+// quote = characters to protect the enclosed characters
+// esc = characters to protect a single character
+//
+
+void tokenize ( const string& str, vector<string>& result,
+			const string& delimiters, const string& delimiters_preserve = "",
+			const string& quote = "\"", const string& esc = "\\" );

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/src/echo.cpp
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/src/echo.cpp b/framework/ext-qnx/cordova/echo/src/echo.cpp
new file mode 100644
index 0000000..3becd52
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/src/echo.cpp
@@ -0,0 +1,87 @@
+/*
+* 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.
+*/
+
+#include <string>
+#include <sstream>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "echo.hpp"
+
+using namespace std;
+
+/**
+ * Default constructor.
+ */
+Echo::Echo(const std::string& id) : m_id(id) {
+}
+
+/**
+ * Memory destructor.
+ */
+Echo::~Echo() {
+}
+
+/**
+ * This method returns the list of objects implemented by this native
+ * extension.
+ */
+char* onGetObjList() {
+    static char name[] = "Echo";
+    return name;
+}
+
+/**
+ * This method is used by JNext to instantiate the Memory object when
+ * an object is created on the JavaScript server side.
+ */
+JSExt* onCreateObject(const string& className, const string& id) {
+    if (className == "Echo") {
+        return new Echo(id);
+    }
+
+    return NULL;
+}
+
+/**
+ * Method used by JNext to determine if the object can be deleted.
+ */
+bool Echo::CanDelete() {
+    return true;
+}
+
+/**
+ * It will be called from JNext JavaScript side with passed string.
+ * This method implements the interface for the JavaScript to native binding
+ * for invoking native code. This method is triggered when JNext.invoke is
+ * called on the JavaScript side with this native objects id.
+ */
+string Echo::InvokeMethod(const string& command) {
+    // Determine which function should be executed
+    if (command == "doEcho") {
+        return doEcho("hi");
+    }else{
+        return "Unsupported Method";
+    }
+}
+
+/**
+ * Method that sends off Event message
+ */
+string Echo::doEcho(const std::string& message) {
+    return message;
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/cordova/echo/src/echo.hpp
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/cordova/echo/src/echo.hpp b/framework/ext-qnx/cordova/echo/src/echo.hpp
new file mode 100644
index 0000000..f545cdb
--- /dev/null
+++ b/framework/ext-qnx/cordova/echo/src/echo.hpp
@@ -0,0 +1,39 @@
+/*
+* 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.
+*/
+#ifndef ECHO_HPP_
+#define ECHO_HPP_
+
+#include <string>
+#include <pthread.h>
+#include "../public/plugin.h"
+
+class Echo: public JSExt {
+
+public:
+    explicit Echo(const std::string& id);
+    virtual ~Echo();
+
+// Interfaces of JSExt
+    virtual bool CanDelete();
+    virtual std::string InvokeMethod(const std::string& command);
+
+private:
+    std::string doEcho(const std::string& message);
+
+    std::string m_id;
+};
+
+#endif /* ECHO_HPP_ */

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/nto/Makefile
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/nto/Makefile b/framework/ext-qnx/nto/Makefile
deleted file mode 100644
index 0cc5eae..0000000
--- a/framework/ext-qnx/nto/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=CPU
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/nto/arm/Makefile
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/nto/arm/Makefile b/framework/ext-qnx/nto/arm/Makefile
deleted file mode 100644
index 0e22650..0000000
--- a/framework/ext-qnx/nto/arm/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LIST=VARIANT
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/939ad4e5/framework/ext-qnx/nto/arm/so.le-v7/Makefile
----------------------------------------------------------------------
diff --git a/framework/ext-qnx/nto/arm/so.le-v7/Makefile b/framework/ext-qnx/nto/arm/so.le-v7/Makefile
deleted file mode 100644
index 0f9d7b9..0000000
--- a/framework/ext-qnx/nto/arm/so.le-v7/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-include ../../../common.mk


Mime
View raw message