You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2013/05/14 06:15:22 UTC
[15/50] [abbrv] Fix JPPS and Utils plugins directory structure
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.cpp
deleted file mode 100644
index 5392ca8..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSNotifyGroupManager.h"
-
-#include <fcntl.h>
-
-#include "PPSNotifier.h"
-
-namespace jpps {
-
-typedef std::map<std::string, PPSNotifier*>::iterator groupIter;
-typedef std::map<std::string, PPSNotifier*>::const_iterator const_groupIter;
-typedef std::pair<std::string, PPSNotifier*> groupValue;
-
-pthread_mutex_t PPSNotifyGroupManager::sm_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-PPSNotifyGroupManager::PPSNotifyGroupManager()
-{
-
-}
-
-PPSNotifyGroupManager::~PPSNotifyGroupManager()
-{
- // Delete the allocated memory for all the PPSNotifiers
- for (groupIter it = m_notifyGroups.begin(); it != m_notifyGroups.end(); it++) {
-
- if ((*it).second != NULL) {
-
- delete (*it).second;
- (*it).second = NULL;
- }
- }
-}
-
-PPSNotifyGroupManager& PPSNotifyGroupManager::getInstance()
-{
- // The one and only PPSNotifyGroupManager
- static PPSNotifyGroupManager manager;
- return manager;
-}
-
-bool PPSNotifyGroupManager::joinNotifyGroup(const std::string& path, std::string& groupId)
-{
- std::string notifyFile;
- std::string notifyPath(path);
- std::size_t nPos = notifyPath.rfind('/');
-
- // Search through the directories in the string until we find a valid .notify object
- while (nPos != std::string::npos) {
-
- // Chop off everything after the last '/' to get the path without the PPS object name
- notifyPath = notifyPath.substr(0, nPos);
-
- // Do we already have a notify group for this path?
- const_groupIter it = m_notifyGroups.find(notifyPath);
-
- // We found a match!
- if (it != m_notifyGroups.end() && (*it).second != NULL) {
-
- groupId = (*it).second->getNotifyGroupId();
- return true;
- }
-
- // Add ".notify?wait" to the notify path, to make it a real file
- notifyFile = notifyPath + "/.notify?wait";
-
- // Try to open this .notify object
- int fd = ::open(notifyFile.c_str(), O_RDONLY);
-
- // This is the .notify object to use
- if (fd >= 0) {
-
- char data[20];
- int len = ::read(fd, data, sizeof(data) - 1);
- // Terminate string to remove the newline char
- data[len > 0 ? len - 1 : 0] = '\0';
-
- PPSNotifier* pNotifier = new PPSNotifier();
- pNotifier->setNotifyGroupId(std::string(data));
- pNotifier->setNotifyOjbPath(notifyPath);
- pNotifier->setObjFd(::dup(fd));
- ::close(fd);
-
- // Add this badboy to our cache of notify groups
- m_notifyGroups.insert(groupValue(notifyPath, pNotifier));
-
- // Start the notify reading thread
- pNotifier->startNotifyLoop();
-
- groupId = pNotifier->getNotifyGroupId();
- return true;
- }
- // Keep looking
- else {
-
- nPos = notifyPath.rfind('/');
- }
- }
-
- // We didn't find a notify group
- groupId = "";
- return false;
-}
-
-} /* namespace jpps */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.h
deleted file mode 100644
index 03b0e3e..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSNotifyGroupManager.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software. Free development
- * licenses are available for evaluation and non-commercial purposes. For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others. Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSNOTIFYGROUPMANAGER_H_
-#define PPSNOTIFYGROUPMANAGER_H_
-
-#include <map>
-#include <string>
-#include <pthread.h>
-
-namespace jpps {
-
-// Forward declaration
-class PPSNotifier;
-
-
-/**
- * The PPSNotifyGroupManager is used to manage a global pool of .notify objects. PPS has a mechanism
- * where every folder can contain a special PPS object ".notify". Opening the .notify object will return
- * a group id on the first read of the .notify object. The group id is used to open the real PPS object
- * for which we desire to receive notifications. Once this is done, the .notify object is the one that will
- * receive change notifications for the real PPS object. In this model, the real PPS object DOES NOT
- * open in blocking read or ionotify/select mode. The .notify object is the one responsible for blocking
- * on read and tracking data publishing.
- *
- * This object is a global singleton - any access to it needs to be wrapped in a mutex to prevent
- * concurrency problems. Two functions mutex_lock() and mutex_unlock() are provided for this purpose.
- */
-class PPSNotifyGroupManager
-{
-public:
-
- /**
- * Destructor.
- */
- virtual ~PPSNotifyGroupManager();
-
- /**
- * Get the one and only instance of the PPSNotifier.Always wrap calls to getInstance() in a call to
- * PPSNotifyGroupManager::mutexLock()/mutexUnlock().
- */
- static PPSNotifyGroupManager& getInstance();
-
- /**
- * Use this function to get the notify group id of the "closest" .notify object in the /pps hierarchy
- * that contains path.
- *
- * The function will go backwards through the directories in path looking for a .notify object. It will return
- * the group id of the first .notify object it finds on this path. It is the responsibility of the caller
- * to have the PPS object in path join the notify group by opening the object with the "notify=groupId:val"
- * option set.
- *
- * PPSNotifyGroupManager maintains a pool of opened .notify objects. It is possible for a single .notify object
- * to have a very disparate (and numerous) set of PPS objects that it monitors. In order to tweak performance
- * it is advisable that .notify object be created in strategic directories in the /pps directory hierarchy, in
- * order to spread the load of notification monitoring. Each .notify object opened will spawn a thread that blocks
- * on reading from the .notify object. Having several .notify objects means having several threads that read
- * notifications.
- *
- * Note that joinNotifyGroup() will NOT create any .notify PPS objects. The /pps/.notify object always exists,
- * and if the /pps directory hierarchy contains no other .notify objects, /pps/.notify will end up being the
- * notification group that all objects join.
- *
- * Always wrap calls to joinNotifyGroup() in a call to PPSNotifyGroupManager::mutexLock()/mutexUnlock().
- *
- * @param The PPS object that wants to join the notify group.
- * @param groupId The id of the notify group joined. This is an output parameter.
- * @return True if a notify group was successfully joined, false otherwise. If true, then the groupId
- * variable will be set.
- */
- bool joinNotifyGroup(const std::string& path, std::string& groupId);
-
- /**
- * Returns how many notification groups the manager is managing.
- *
- * @return The number of notification groups (i.e. open .notify objects) in use.
- */
- inline std::size_t getNumGroups() const { return m_notifyGroups.size(); }
-
- /**
- * Should be used to wrap all calls to PPSNotifyGroupManager APIs. Because this is a singleton global
- * object, multiple threads may try to access this object at one time. It is therefore important to
- * mutex lock all access to this object.
- */
- static inline void mutexLock() { pthread_mutex_lock(&sm_mutex); }
-
- /**
- * Should be used to wrap all calls to PPSNotifyGroupManager APIs. Because this is a singleton global
- * object, multiple threads may try to access this object at one time. It is therefore important to
- * mutex lock all access to this object.
- */
- static inline void mutexUnlock() { pthread_mutex_unlock(&sm_mutex); }
-
-private:
-
- /**
- * Constructor. Private as part of the singleton pattern of this object.
- */
- PPSNotifyGroupManager();
-
- // Disable the copy constructor.
- PPSNotifyGroupManager(const PPSNotifyGroupManager& manager);
-
- // Disable the assignment operator.
- PPSNotifyGroupManager& operator=(const PPSNotifyGroupManager& rhs);
-
- /** This is a cache of all the .notify objects. */
- std::map<std::string, PPSNotifier*> m_notifyGroups;
-
- /** Mutex used to prevent threads from clobbering each other. */
- static pthread_mutex_t sm_mutex;
-};
-
-} /* namespace jpps */
-#endif /* PPSNOTIFYGROUPMANAGER_H_ */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSTypes.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSTypes.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSTypes.h
deleted file mode 100644
index 362d236..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/core/PPSTypes.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software. Free development
- * licenses are available for evaluation and non-commercial purposes. For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others. Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSTYPES_H_
-#define PPSTYPES_H_
-
-#include <map>
-
-namespace jpps {
-
-class PPSEvent;
-
-/**
- * A struct representing an attribute of a PPS object.
- */
-struct ppsAttribute {
-
- /** The attribute name. */
- std::string name;
- /** The attribute value. */
- std::string value;
- /** The attribute encoding. */
- std::string encoding;
- /** Flags associated to the attribute. */
- int flags;
- /** Attribute options. */
- int options;
- /** The attribute options mask. */
- int optionMask;
-};
-
-/**
- * A struct representing a PPS object.
- */
-struct ppsObject {
-
- /** The PPS object name. */
- std::string name;
- /** The PPS object flags. */
- int flags;
- /** The PPS object options. */
- int options;
- /** The PPS object option mask. */
- int optionMask;
- /** The attributes of this PPS object. */
- std::map<std::string, ppsAttribute> attributes;
-};
-
-/**
- * Typedef for ppsAttribute iterator.
- */
-typedef std::map<std::string, ppsAttribute>::iterator ppsAttrIter;
-
-/**
- * Typedef for ppsAttribute const iterator.
- */
-typedef std::map<std::string, ppsAttribute>::const_iterator const_ppsAttrIter;
-
-/**
- * A pair used to insert attributes into the map.
- */
-typedef std::pair<std::string, ppsAttribute> ppsAttrPair;
-
-/**
- * This is the definition of the notify function clients of PPSInterface use in order
- * to be informed of events the PPSInterface generates.
- *
- * @param pArg A user defined parameter. This value can be passed in to PPSInterface::setEventFunc()
- * and will be passed back with the event handler every time it is called. PPSInterface will not
- * modify this value.
- *
- * @aparam event The PPS event being broadcast.
- */
-typedef void (PPSEventFunc)(void* pArg, const PPSEvent& event);
-
-};
-
-#endif /* PPSTYPES_H_ */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.cpp
deleted file mode 100644
index 9b5d711..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "JPPSPlugin.h"
-
-#include <string>
-#include <sstream>
-
-namespace jpps {
-
-const char* JPPSPlugin::CLASS_NAME = "PPS";
-const std::string JPPSPlugin::METHOD_OPEN = "Open";
-const std::string JPPSPlugin::METHOD_CLOSE = "Close";
-const std::string JPPSPlugin::METHOD_WRITE = "Write";
-const std::string JPPSPlugin::METHOD_READ = "Read";
-const std::string JPPSPlugin::METHOD_SET_VERBOSE = "SetVerbose";
-
-JPPSPlugin::JPPSPlugin(const std::string& jnextObjectId)
-: m_jnextObjId(jnextObjectId)
-, m_ppsInterface()
-{
- // We only have one event handler, we'll use it for all events
- m_ppsInterface.callbackInit(this,
- onEvent,
- onEvent,
- onEvent,
- onEvent,
- onEvent,
- onEvent,
- onEvent);
-}
-
-JPPSPlugin::~JPPSPlugin()
-{
-
-}
-
-std::string JPPSPlugin::InvokeMethod(const std::string& strCommand)
-{
- // Parameter sanity check
- if (strCommand == "")
- return std::string(szERROR) + " JPPSPlugin::InvokeMethod() called with no method to invoke.";
-
- // Tokenize the stream of input information
- std::stringstream args(strCommand);
- std::string method;
- args >> method;
-
- // Invoke the method requested
- if (method == JPPSPlugin::METHOD_WRITE) {
- return write(args);
- }
- else if (method == JPPSPlugin::METHOD_READ) {
- return read();
- }
- else if (method == JPPSPlugin::METHOD_OPEN) {
- return open(args);
- }
- else if (method == JPPSPlugin::METHOD_CLOSE) {
- return close();
- }
- else if (method == JPPSPlugin::METHOD_SET_VERBOSE) {
- return setVerbose(args);
- }
-
- return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::InvokeMethod() - unknown method \"" + method + "\"";
-}
-
-std::string JPPSPlugin::open(std::stringstream& args)
-{
- // We don't have enough args
- if (args.eof())
- return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - invalid number of arguments.";
-
- // Get the arguments
- // 1st arg, the path
- std::string path;
- args >> path;
-
- // Missing argument
- if (args.eof())
- return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - invalid number of arguments.";
-
- // 2nd arg, the open flags (i.e. O_RDONLY O_CREAT, etc.)
- int oflags = 0;
- args >> oflags;
-
- bool bRet = m_ppsInterface.open(path, oflags);
-
- return bRet ? std::string(szOK) + m_jnextObjId : std::string(szERROR) + m_jnextObjId + " JPPSPlugin::open() - failed to open \"" + path + "\".";
-}
-
-std::string JPPSPlugin::close()
-{
- m_ppsInterface.close();
- return szOK + m_jnextObjId;
-}
-
-std::string JPPSPlugin::write(std::stringstream& args)
-{
- // We don't have enough args
- if (args.eof())
- return std::string(szERROR) + m_jnextObjId + " JPPSPlugin::write() - invalid number of arguments.";
-
- // This truncates the buffer from the current position onwards (if you don't do this, you keep
- // the method name that's at the beginning of the args stream)
- args.seekg(1, std::ios_base::cur); // Skip the initial whitespace that was between the method name and the parameter
- std::stringstream tmp;
- tmp << args.rdbuf();
-
- m_ppsInterface.write(tmp.str());
- return szOK + m_jnextObjId;
-}
-
-std::string JPPSPlugin::read() const
-{
- return std::string(szOK) + m_ppsInterface.read();
-}
-
-std::string JPPSPlugin::setVerbose(std::stringstream& args)
-{
- unsigned short verbosity = 0;
-
- // If no param was passed, default to 0, else read the value
- if (!args.eof())
- args >> verbosity;
-
- m_ppsInterface.setVerbose(verbosity);
- return szOK;
-}
-
-void JPPSPlugin::onEvent(const std::string& sEvent) const
-{
- // We have to add our object Id to the event
- std::string pluginEvent = m_jnextObjId + " " + sEvent;
- SendPluginEvent(pluginEvent.c_str(), m_pContext);
-}
-
-void JPPSPlugin::onEvent(void* pArg, const std::string& sEvent)
-{
- // Cast pArg back to JPPSPlugin and invoke onEvent()
- JPPSPlugin* pPlugin = static_cast<JPPSPlugin*>(pArg);
-
- if (pPlugin != NULL)
- pPlugin->onEvent(sEvent);
-}
-
-} /* namespace jpps */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.h
deleted file mode 100644
index 1a56ab2..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSPlugin.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software. Free development
- * licenses are available for evaluation and non-commercial purposes. For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others. Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef JPPSPLUGIN_H_
-#define JPPSPLUGIN_H_
-
-#include "../common/plugin.h"
-#include "PPSInterfaceGlue.h"
-
-namespace jpps {
-
-/**
- * JPPSPlugin is a JNext extension which provides PPS support to JavaScript.
- * This class is merely a wrapper for PPSInterfaceGlue, providing the necessary
- * JNext interface and performing string-parameter encoding and decoding.
- *
- * The intention is that this class will be replaced with a different plug-in framework.
- */
-class JPPSPlugin : public JSExt {
-
-public:
-
- // Constants
-
- /** The only class supported by this plugin. */
- static const char* CLASS_NAME;
-
- // List of object methods supported by this extension
-
- /** Open a PPS object/directory. */
- static const std::string METHOD_OPEN;
- /** Close a PPS object/directory. */
- static const std::string METHOD_CLOSE;
- /** Write a PPS object. */
- static const std::string METHOD_WRITE;
- /** Read a PPS object. */
- static const std::string METHOD_READ;
- /** Adjust output verbosity. */
- static const std::string METHOD_SET_VERBOSE;
-
- /**
- * Constructor.
- */
- JPPSPlugin(const std::string& jnextObjectId);
-
- /**
- * Destructor.
- */
- virtual ~JPPSPlugin();
-
- // Inherited from JSExt
- virtual std::string InvokeMethod(const std::string& strCommand);
- virtual inline bool CanDelete(void) { return true; }
-
- /**
- * Static callback method, changes pArg back into a JPPSPlugin and invokes
- * the non-static version of onEvent().
- */
- static void onEvent(void* pArg, const std::string& sEvent);
-
-private:
-
- // Disable the default constructor
- JPPSPlugin();
-
- /**
- * The non-static version of onEvent. Handler for the PPSInterfaceGlue class' events.
- */
- void onEvent(const std::string& sEvent) const;
-
- /**
- * Open a PPS object.
- */
- std::string open(std::stringstream& args);
-
- /**
- * Close the PPS object.
- */
- std::string close();
-
- /**
- * Write data to the PPS object.
- */
- std::string write(std::stringstream& args);
-
- /**
- * Read the cached PPS data from the last read.
- */
- std::string read() const;
-
- /**
- * Set the verbosity level for logging to slog.
- */
- std::string setVerbose(std::stringstream& args);
-
- /** A unique JNext id for this object */
- std::string m_jnextObjId;
-
- /** The PPS object. */
- PPSInterfaceGlue m_ppsInterface;
-};
-
-} /* namespace jpps */
-#endif /* JPPSPLUGIN_H_ */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.cpp
deleted file mode 100644
index 6c3bc2d..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "JPPSServerPlugin.h"
-
-#include <sstream>
-
-namespace jpps {
-
-const char* JPPSServerPlugin::CLASS_NAME = "PPSServer";
-
-const std::string JPPSServerPlugin::METHOD_OPEN = "Open";
-const std::string JPPSServerPlugin::METHOD_CLOSE = "Close";
-const std::string JPPSServerPlugin::METHOD_SET_VERBOSE = "SetVerbose";
-const std::string JPPSServerPlugin::METHOD_SEND_MESSAGE = "SendMessage";
-const std::string JPPSServerPlugin::METHOD_BROADCAST_MESSAGE = "BroadcastMessage";
-
-JPPSServerPlugin::JPPSServerPlugin(const std::string& jnextObjectId)
-: m_jnextObjId(jnextObjectId)
-, m_ppsServer()
-{
- m_ppsServer.callbackInit(this,
- onEvent,
- onEvent,
- onEvent,
- onEvent,
- onEvent,
- onEvent,
- onEvent,
- onEvent);
-}
-
-JPPSServerPlugin::~JPPSServerPlugin()
-{
-}
-
-std::string JPPSServerPlugin::InvokeMethod(const std::string& strCommand)
-{
- // Parameter sanity check
- if (strCommand == "")
- return std::string(szERROR) + " JPPSServerPlugin::InvokeMethod() called with no method to invoke.";
-
- // Tokenize the stream of input information
- std::stringstream args(strCommand);
- std::string method;
- args >> method;
-
- // Invoke the method requested
- if (method == JPPSServerPlugin::METHOD_OPEN) {
- return open(args);
- }
- else if (method == JPPSServerPlugin::METHOD_CLOSE) {
- return close();
- }
- else if (method == JPPSServerPlugin::METHOD_SET_VERBOSE) {
- return setVerbose(args);
- }
- else if (method == JPPSServerPlugin::METHOD_SEND_MESSAGE) {
- return sendMessage(args);
- }
- else if (method == JPPSServerPlugin::METHOD_BROADCAST_MESSAGE) {
- return broadcastMessage(args);
- }
-
- return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::InvokeMethod() - unknown method \"" + method + "\"";
-}
-
-std::string JPPSServerPlugin::open(std::stringstream& args)
-{
- // We don't have enough args
- if (args.eof())
- return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - invalid number of arguments.";
-
- // Get the arguments
- // 1st arg, the path
- std::string path;
- args >> path;
-
- // Missing argument
- if (args.eof())
- return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - invalid number of arguments.";
-
- // 2nd arg, the open flags (i.e. O_RDONLY O_CREAT, etc.)
- int oflags = 0;
- args >> oflags;
-
- bool bRet = m_ppsServer.open(path, oflags);
-
- return bRet ? std::string(szOK) + m_jnextObjId : std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::open() - failed to open \"" + path + "\".";
-}
-
-std::string JPPSServerPlugin::close()
-{
- m_ppsServer.close();
- return szOK + m_jnextObjId;
-}
-
-std::string JPPSServerPlugin::setVerbose(std::stringstream& args)
-{
- unsigned short verbosity = 0;
-
- // If no param was passed, default to 0, else read the value
- if (!args.eof())
- args >> verbosity;
-
- m_ppsServer.setVerbose(verbosity);
- return szOK + m_jnextObjId;
-}
-
-std::string JPPSServerPlugin::sendMessage(std::stringstream& args)
-{
- // We don't have enough args
- if (args.eof())
- return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::sendMessage() - invalid number of arguments.";
-
- // Get the arguments
- // 1st arg, the clientId
- std::string clientId;
- args >> clientId;
-
- // We don't have enough args
- if (args.eof())
- return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::sendMessage() - invalid number of arguments.";
-
- // This truncates the buffer from the current position onwards (if you don't do this, you keep
- // the method name that's at the beginning of the args stream)
- args.seekg(1, std::ios_base::cur); // Skip the whitespace that was between the clientID and the message
- std::stringstream tmp;
- tmp << args.rdbuf();
-
- m_ppsServer.sendMessage(clientId, tmp.str());
- return szOK + m_jnextObjId;
-}
-
-std::string JPPSServerPlugin::broadcastMessage(std::stringstream& args)
-{
- // We don't have enough args
- if (args.eof())
- return std::string(szERROR) + m_jnextObjId + " JPPSServerPlugin::broadcastMessage() - invalid number of arguments.";
-
- // This truncates the buffer from the current position onwards (if you don't do this, you keep
- // the method name that's at the beginning of the args stream)
- args.seekg(1, std::ios_base::cur); // Skip the whitespace that was between the method name and the message
- std::stringstream tmp;
- tmp << args.rdbuf();
-
- m_ppsServer.broadcastMessage(tmp.str());
- return szOK + m_jnextObjId;
-}
-
-void JPPSServerPlugin::onEvent(const std::string& sEvent) const
-{
- // We have to add our object Id to the event
- std::string pluginEvent = m_jnextObjId + " " + sEvent;
- SendPluginEvent(pluginEvent.c_str(), m_pContext);
-}
-
-void JPPSServerPlugin::onEvent(void* pArg, const std::string& sEvent)
-{
- // Cast pArg back to JPPSPlugin and invoke onEvent()
- JPPSServerPlugin* pPlugin = static_cast<JPPSServerPlugin*>(pArg);
-
- if (pPlugin != NULL)
- pPlugin->onEvent(sEvent);
-}
-
-} /* namespace jpps */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.h
deleted file mode 100644
index ea5b18f..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/JPPSServerPlugin.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software. Free development
- * licenses are available for evaluation and non-commercial purposes. For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others. Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef JPPSSERVERPLUGIN_H_
-#define JPPSSERVERPLUGIN_H_
-
-#include "../common/plugin.h"
-#include "PPSServerGlue.h"
-
-namespace jpps {
-
-class JPPSServerPlugin: public JSExt {
-
-public:
-
- // Constants
-
- /** The only class supported by this plugin. */
- static const char* CLASS_NAME;
-
- // List of object methods supported by this extension
-
- /** Open a PPS object/directory. */
- static const std::string METHOD_OPEN;
- /** Close a PPS object/directory. */
- static const std::string METHOD_CLOSE;
- /** Adjust output verbosity. */
- static const std::string METHOD_SET_VERBOSE;
- /** Send a message to a particular client. */
- static const std::string METHOD_SEND_MESSAGE;
- /** Send a message to all clients. */
- static const std::string METHOD_BROADCAST_MESSAGE;
-
- /**
- * Constructor.
- */
- JPPSServerPlugin(const std::string& jnextObjectId);
-
- /**
- * Destructor.
- */
- virtual ~JPPSServerPlugin();
-
- // Inherited from JSExt
- virtual std::string InvokeMethod(const std::string& strCommand);
- virtual inline bool CanDelete(void) { return true; }
-
- /**
- * Static callback method, changes pArg back into a JPPSServerPlugin and invokes
- * the non-static version of onEvent().
- */
- static void onEvent(void* pArg, const std::string& sEvent);
-
-private:
-
- // Disable default constructor.
- JPPSServerPlugin();
-
- /**
- * The non-static version of onEvent. Handler for the PPSServerGlue class' events.
- */
- void onEvent(const std::string& sEvent) const;
-
- /**
- * Open a PPS object.
- */
- std::string open(std::stringstream& args);
-
- /**
- * Close the PPS object.
- */
- std::string close();
-
- /**
- * Set the verbosity level for logging to slog.
- */
- std::string setVerbose(std::stringstream& args);
-
- /**
- * Send a message to a particular client.
- */
- std::string sendMessage(std::stringstream& args);
-
- /**
- * Send a message to all clients.
- */
- std::string broadcastMessage(std::stringstream& args);
-
- /** A unique JNext id for this object */
- std::string m_jnextObjId;
-
- /** The PPS object. */
- PPSServerGlue m_ppsServer;
-};
-
-} /* namespace jpps */
-#endif /* JPPSSERVERPLUGIN_H_ */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.cpp
deleted file mode 100644
index 83616b8..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSInterfaceGlue.h"
-
-#include <json/value.h>
-#include <json/writer.h>
-#include <json/reader.h>
-
-#include <vector>
-#include <sstream>
-
-#include <ppsparse.h>
-
-#include "../core/PPSEvent.h"
-
-namespace jpps {
-
-const std::string PPSInterfaceGlue::EVENT_OPEN = "ppsOpened";
-const std::string PPSInterfaceGlue::EVENT_OPEN_FAILED = "ppsOpenFailed";
-const std::string PPSInterfaceGlue::EVENT_FIRST_READ = "ppsFirstRead";
-const std::string PPSInterfaceGlue::EVENT_NEW_DATA = "OnChange";//"ppsNewData";
-const std::string PPSInterfaceGlue::EVENT_CLOSE = "ppsClosed";
-const std::string PPSInterfaceGlue::EVENT_WRITE_FAILED = "ppsWriteFailed";
-const std::string PPSInterfaceGlue::EVENT_READ_FAILED = "ppsReadFailed";
-
-const std::string PPSInterfaceGlue::ENCODING_N = "n";
-const std::string PPSInterfaceGlue::ENCODING_B = "b";
-const std::string PPSInterfaceGlue::ENCODING_JSON = "json";
-
-const Json::StaticString PPSInterfaceGlue::JSON_REMOVE("remove");
-const Json::StaticString PPSInterfaceGlue::JSON_CHANGED("changed");
-const Json::StaticString PPSInterfaceGlue::JSON_DATA("data");
-const Json::StaticString PPSInterfaceGlue::JSON_OBJNAME("objName");
-const Json::StaticString PPSInterfaceGlue::JSON_CHANGE_DATA("changeData");
-const Json::StaticString PPSInterfaceGlue::JSON_ALL_DATA("allData");
-
-
-PPSInterfaceGlue::PPSInterfaceGlue()
-: m_interface()
-, m_pArg(NULL)
-, m_handleOpen(NULL)
-, m_handleFirstRead(NULL)
-, m_handleNewData(NULL)
-, m_handleClose(NULL)
-, m_handleOpenFailed(NULL)
-, m_handleWriteFailed(NULL)
-, m_handleReadFailed(NULL)
-{
- m_interface.setEventFunc(onEvent, this);
-}
-
-PPSInterfaceGlue::~PPSInterfaceGlue()
-{
- m_interface.setEventFunc(NULL);
-}
-
-void PPSInterfaceGlue::callbackInit(void* pArg,
- callback* handleOpen,
- callback* handleFirstRead,
- callback* handleNewData,
- callback* handleClose,
- callback* handleOpenFailed,
- callback* handleWriteFailed,
- callback* handleReadFailed)
-{
- m_pArg = pArg;
- m_handleOpen = handleOpen;
- m_handleFirstRead = handleFirstRead;
- m_handleNewData = handleNewData;
- m_handleClose = handleClose;
- m_handleOpenFailed = handleOpenFailed;
- m_handleWriteFailed = handleWriteFailed;
- m_handleReadFailed = handleReadFailed;
-}
-
-void PPSInterfaceGlue::setVerbose(unsigned short v)
-{
- m_interface.setVerbose(v);
-}
-
-bool PPSInterfaceGlue::open(const std::string& path, int oflags)
-{
- // We don't expose the "mode" to the JS layer - always create in 0666 mode
- return m_interface.open(path, oflags, 0666, false);
-}
-
-void PPSInterfaceGlue::close()
-{
- m_interface.close();
-}
-
-void PPSInterfaceGlue::sync()
-{
- m_interface.sync();
-}
-
-void PPSInterfaceGlue::onEvent(void* pArg, const PPSEvent& event)
-{
- PPSInterfaceGlue* pGlue = static_cast<PPSInterfaceGlue*>(pArg);
-
- if (pGlue != NULL)
- pGlue->onEvent(event);
-}
-
-void PPSInterfaceGlue::onEvent(const PPSEvent& event)
-{
- callback* pFunc = NULL;
- std::string sArg;
-
- switch (event.getEventType()) {
-
- case PPSEvent::PPS_EVENT_OPENED:
- pFunc = m_handleOpen;
- sArg = EVENT_OPEN;
- break;
-
- case PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE:
- pFunc = m_handleFirstRead;
- sArg = EVENT_FIRST_READ + " " + handleNewData(event.getNewData());
- break;
-
- case PPSEvent::PPS_EVENT_NEW_DATA:
- pFunc = m_handleNewData;
- sArg = EVENT_NEW_DATA + " " + handleNewData(event.getNewData());
- break;
-
- case PPSEvent::PPS_EVENT_CLOSED:
- pFunc = m_handleClose;
- sArg = EVENT_CLOSE;
- break;
-
- case PPSEvent::PPS_EVENT_OPEN_FAILED:
- pFunc = m_handleOpenFailed;
- sArg = EVENT_OPEN_FAILED + " " + event.getMessage();
- break;
-
- case PPSEvent::PPS_EVENT_WRITE_FAILED:
- pFunc = m_handleWriteFailed;
- sArg = EVENT_WRITE_FAILED + " " + event.getMessage();
- break;
-
- case PPSEvent::PPS_EVENT_READ_FAILED:
- pFunc = m_handleReadFailed;
- sArg = EVENT_READ_FAILED + " " + event.getMessage();
- break;
- }
-
- if (pFunc != NULL)
- pFunc(m_pArg, sArg);
-}
-
-std::string PPSInterfaceGlue::handleNewData(const ppsObject& newData)
-{
- Json::Value data(Json::nullValue);
- data[JSON_CHANGE_DATA] = JSONEncodeNewData(newData);
- data[JSON_ALL_DATA] = JSONEncodeRead(m_interface.read());
-
- Json::FastWriter writer;
- return writer.write(data);
-}
-
-std::string PPSInterfaceGlue::read() const
-{
- Json::Value data = JSONEncodeRead(m_interface.read());
- Json::FastWriter writer;
- return writer.write(data);
-}
-
-Json::Value PPSInterfaceGlue::JSONEncodeRead(const ppsObject& ppsObj) const
-{
- // If the ppsObj is empty, we can't encode it
- if (ppsObj.name.empty())
- return "";
-
- Json::Value readData(Json::nullValue);
-
- for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
-
- ppsAttribute ppsAttrib = (*it).second;
-
- // An attribute was deleted: update the JSON data structure and the event data
- if (ppsAttrib.flags & PPS_DELETED) {
-
- readData.removeMember(ppsAttrib.name);
- }
- else {
-
- // The value is a number
- if (ppsAttrib.encoding == ENCODING_N) {
-
- // Convert the value to floating point
- // istringstream is locale aware - we shouldn't need to perform any special
- // processing in order to properly convert the data to a floating point
- // TODO: test that the istringstream conversion works with a locale
- // that uses alternate floating point number encoding
- std::istringstream stream(ppsAttrib.value);
- double doubleValue;
-
- // Try to convert the value to a floating point
- if (!(stream >> doubleValue)) {
-
- std::string err = EVENT_READ_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
- m_handleReadFailed(m_pArg, err);
- return "";
- }
-
- readData[ppsAttrib.name] = doubleValue;
- }
- // The value is a boolean
- else if (ppsAttrib.encoding == ENCODING_B) {
-
- readData[ppsAttrib.name] = (ppsAttrib.value == "true");
- }
- // The value is JSON data
- else if (ppsAttrib.encoding == ENCODING_JSON) {
-
- Json::Reader reader;
- reader.parse(ppsAttrib.value, readData[ppsAttrib.name]);
- }
- // Just pass the value through as a straight string
- else {
-
- readData[ppsAttrib.name] = ppsAttrib.value;
- }
- }
- }
-
- return readData;
-}
-
-Json::Value PPSInterfaceGlue::JSONEncodeNewData(const ppsObject& ppsObj) const
-{
- // If the ppsObj is empty, we can't encode it
- if (ppsObj.name.empty())
- return "";
-
- Json::Value eventData(Json::nullValue);
-
- // Set the PPS object name
- eventData[JSON_OBJNAME] = ppsObj.name.substr(1); // PR 159829 : Remove the pre-pending '@' symbol
-
- for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
-
- ppsAttribute ppsAttrib = (*it).second;
-
- // An attribute was deleted: update the JSON data structure and the event data
- if (ppsAttrib.flags & PPS_DELETED) {
-
- eventData[JSON_REMOVE][ppsAttrib.name] = true;
- }
- else {
-
- eventData[JSON_CHANGED][ppsAttrib.name] = true;
-
- // The value is a number
- if (ppsAttrib.encoding == ENCODING_N) {
-
- // Convert the value to floating point
- // istringstream is locale aware - we shouldn't need to perform any special
- // processing in order to properly convert the data to a floating point
- // TODO: test that the istringstream conversion works with a locale
- // that uses alternate floating point number encoding
- std::istringstream stream(ppsAttrib.value);
- double doubleValue;
-
- // Try to convert the value to a floating point
- if (!(stream >> doubleValue)) {
-
- std::string err = EVENT_READ_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
- m_handleReadFailed(m_pArg, err);
- return "";
- }
-
- eventData[JSON_DATA][ppsAttrib.name] = doubleValue;
- }
- // The value is a boolean
- else if (ppsAttrib.encoding == ENCODING_B) {
-
- eventData[JSON_DATA][ppsAttrib.name] = (ppsAttrib.value == "true");
- }
- // The value is JSON data
- else if (ppsAttrib.encoding == ENCODING_JSON) {
-
- Json::Reader reader;
- reader.parse(ppsAttrib.value, eventData[JSON_DATA][ppsAttrib.name]);
- }
- // Just pass the value through as a straight string
- else {
-
- eventData[JSON_DATA][ppsAttrib.name] = ppsAttrib.value;
- }
- }
- }
-
- return eventData;
-}
-
-void PPSInterfaceGlue::write(const std::string& data)
-{
- Json::Reader reader;
- Json::Value root;
-
- bool parsingSuccessful = reader.parse(data, root);
-
- // If parsing the JSON string fails, return a write error
- if (!parsingSuccessful) {
-
- std::string err = EVENT_WRITE_FAILED + " JSON failed to parse the string (\"" + data + "\") to be written. (" + reader.getFormatedErrorMessages() + ")";
- m_handleWriteFailed(m_pArg, err);
- return;
- }
-
- Json::Value::Members memberNames = root.getMemberNames();
-
- std::ostringstream output;
- output.precision(15);
-
- Json::Value member;
-
- for (unsigned int i = 0; i < memberNames.size(); i++) {
-
- output << memberNames[i] << ":";
- member = root[memberNames[i]];
-
- if (member.isObject() || member.isArray()) {
-
- Json::FastWriter writer;
- output << ENCODING_JSON << ":" << writer.write(member); // write() adds an \n
- }
- else if (member.isBool()) {
-
- output << ENCODING_B << ":" << member.asString() << std::endl;
- }
- else if (member.isNumeric()) {
-
- output << ENCODING_N << ":" << member.asDouble() << std::endl;
- }
- else if (member.isString()) {
-
- output << ":" << member.asString() << std::endl;
- }
- else {
-
- std::string err = EVENT_WRITE_FAILED + " The string passed in (\"" + data + "\") contains an invalid JSON type.";
- m_handleWriteFailed(m_pArg, err);
- return;
- }
- }
-
- m_interface.write(output.str());
-}
-
-} /* namespace jpps */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.h
deleted file mode 100644
index fafbacd..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSInterfaceGlue.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software. Free development
- * licenses are available for evaluation and non-commercial purposes. For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others. Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSINTERFACEGLUE_H_
-#define PPSINTERFACEGLUE_H_
-
-#include "../core/PPSInterface.h"
-#include "PluginTypes.h"
-
-#include <json/value.h>
-
-#include <string>
-
-namespace jpps {
-class PPSEvent;
-struct ppsObject;
-}
-
-namespace jpps {
-
-/**
- * This class bridges JavaScript and the native PPSInterface code.
- */
-class PPSInterfaceGlue {
-
-public:
-
- /**
- * Constructor.
- */
- PPSInterfaceGlue();
-
- /**
- * Destructor.
- */
- virtual ~PPSInterfaceGlue();
-
- /**
- * The browser plugin should set these handlers.
- *
- * @param pArg pArg will be passed back to each callback function when it is called.
- */
- void callbackInit(void* pArg,
- callback* handleOpen,
- callback* handleFirstRead,
- callback* handleNewData,
- callback* handleClose,
- callback* handleOpenFailed,
- callback* handleWriteFailed,
- callback* handleReadFailed);
-
- /**
- * Set the verbosity of logging to the slog.
- */
- void setVerbose(unsigned short v);
-
- /**
- * Open a PPS object.
- */
- bool open(const std::string& path, int oflags);
-
- /**
- * Write to a PPS object.
- */
- void write(const std::string& data);
-
- /**
- * Read from the PPS object. This actually returns the cached value of the last
- * onNewData event from PPSInteraface, then encodes it as JSON.
- */
- std::string read() const;
-
- /**
- * Close this PPS object.
- */
- void close();
-
- /**
- * Forces all queued I/O operations for this object to finish, synchronizing the file's state.
- * The function blocks until this is finished.
- */
- void sync();
-
- /**
- * The function that the PPSInterface will call when an event happens.
- * This is the static function that is used as a function pointer for
- * PPSInterface::setEventFunc().
- *
- * @param event The event PPSInterface is sending.
- * @param pArg A pointer to a PPSInterfaceGlue object, passed in during
- * object construction.
- */
- static void onEvent(void* pArg, const PPSEvent& event);
-
-private:
-
- /**
- * The static PPSInterfaceGlue::onEvent() calls this onEvent to do the actual work.
- */
- void onEvent(const PPSEvent& event);
-
- /**
- * Handle a new data event.
- */
- std::string handleNewData(const ppsObject& newData);
-
- /**
- * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
- * with a new data event. This structures the JSON with changed properties and the
- * data that has changed.
- */
- Json::Value JSONEncodeNewData(const ppsObject& ppsObj) const;
-
- /**
- * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
- * when a call to read() is made.
- */
- Json::Value JSONEncodeRead(const ppsObject& ppsObj) const;
-
- // String names for the various events
- static const std::string EVENT_OPEN;
- static const std::string EVENT_OPEN_FAILED;
- static const std::string EVENT_FIRST_READ;
- static const std::string EVENT_NEW_DATA;
- static const std::string EVENT_CLOSE;
- static const std::string EVENT_READ_FAILED;
- static const std::string EVENT_WRITE_FAILED;
-
- /** Custom PPS encoding value: an "n" means a real number. */
- static const std::string ENCODING_N;
- /** Custom PPS encoding value: a "b" means a boolean value. */
- static const std::string ENCODING_B;
- /** Custom PPS encoding value: the data is encoded using JSON. */
- static const std::string ENCODING_JSON;
-
- // JSON constants
- static const Json::StaticString JSON_REMOVE;
- static const Json::StaticString JSON_CHANGED;
- static const Json::StaticString JSON_DATA;
- static const Json::StaticString JSON_OBJNAME;
- static const Json::StaticString JSON_CHANGE_DATA;
- static const Json::StaticString JSON_ALL_DATA;
-
- /** The interface this object wraps. */
- PPSInterface m_interface;
-
- // Handlers for various events
- void* m_pArg;
- callback* m_handleOpen;
- callback* m_handleFirstRead;
- callback* m_handleNewData;
- callback* m_handleClose;
- callback* m_handleOpenFailed;
- callback* m_handleWriteFailed;
- callback* m_handleReadFailed;
-};
-
-} /* namespace jpps */
-#endif /* PPSINTERFACEGLUE_H_ */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.cpp
deleted file mode 100644
index 2eb4552..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "PPSServerGlue.h"
-
-#include <json/value.h>
-#include <json/writer.h>
-#include <json/reader.h>
-
-#include <sstream>
-
-#include <ppsparse.h>
-#include <fcntl.h>
-
-namespace jpps {
-
-const std::string PPSServerGlue::EVENT_OPEN = "onOpen";
-const std::string PPSServerGlue::EVENT_CLOSE = "onClose";
-const std::string PPSServerGlue::EVENT_CLIENT_CONNECT = "onClientConnect";
-const std::string PPSServerGlue::EVENT_CLIENT_DISCONNECT = "onClientDisconnect";
-const std::string PPSServerGlue::EVENT_MESSAGE = "onMessage";
-const std::string PPSServerGlue::EVENT_OPEN_FAILED = "onOpenFailed";
-const std::string PPSServerGlue::EVENT_SEND_MESSAGE_FAILED = "onSendMessageFailed";
-const std::string PPSServerGlue::EVENT_RECEIVE_MESSAGE_FAILED = "onReceiveMessageFailed";
-
-const std::string PPSServerGlue::ENCODING_N = "n";
-const std::string PPSServerGlue::ENCODING_B = "b";
-const std::string PPSServerGlue::ENCODING_JSON = "json";
-
-const Json::StaticString PPSServerGlue::JSON_DATA("data");
-const Json::StaticString PPSServerGlue::JSON_CONNECTION_ID("clientId");
-
-PPSServerGlue::PPSServerGlue()
-: m_interface()
-, m_pArg(NULL)
-, m_handleOpen(NULL)
-, m_handleClose(NULL)
-, m_handleClientConnect(NULL)
-, m_handleClientDisconnect(NULL)
-, m_handleMessage(NULL)
-, m_handleOpenFailed(NULL)
-, m_handleSendMessageFailed(NULL)
-, m_handleReceiveMessageFailed(NULL)
-{
- m_interface.setEventFunc(onEvent, this);
-}
-
-PPSServerGlue::~PPSServerGlue()
-{
- m_interface.setEventFunc(NULL);
-}
-
-void PPSServerGlue::callbackInit(void* pArg,
- callback* handleOpen,
- callback* handleClose,
- callback* handleClientConnect,
- callback* handleClientDisconnect,
- callback* handleMessage,
- callback* handleOpenFailed,
- callback* handleSendMessageFailed,
- callback* handleReceiveMessageFailed)
-{
- m_pArg = pArg;
- m_handleOpen = handleOpen;
- m_handleClose = handleClose;
- m_handleClientConnect = handleClientConnect;
- m_handleClientDisconnect = handleClientDisconnect;
- m_handleMessage = handleMessage;
- m_handleOpenFailed = handleOpenFailed;
- m_handleSendMessageFailed = handleSendMessageFailed;
- m_handleReceiveMessageFailed = handleReceiveMessageFailed;
-}
-
-
-void PPSServerGlue::setVerbose(unsigned short v)
-{
- m_interface.setVerbose(v);
-}
-
-bool PPSServerGlue::open(const std::string& path, int oflags)
-{
- // Make sure we're creating the server, if it doesn't exist
- if (!(oflags & O_CREAT))
- oflags &= O_CREAT;
-
- // We don't expose the "mode" to the JS layer - always create in 0666 mode
- return m_interface.open(path, oflags, 0666, true);
-}
-
-void PPSServerGlue::close()
-{
- m_interface.close();
-}
-
-void PPSServerGlue::sendMessage(const std::string& clientID, const std::string& msg)
-{
- std::string decodedMsg = JSONDecodeData(msg);
- std::string message(clientID + "\n" + decodedMsg);
- m_interface.write(message);
-}
-
-void PPSServerGlue::broadcastMessage(const std::string& msg)
-{
- m_interface.write(JSONDecodeData(msg));
-}
-
-void PPSServerGlue::onEvent(void* pArg, const PPSEvent& event)
-{
- PPSServerGlue* pGlue = static_cast<PPSServerGlue*>(pArg);
-
- if (pGlue != NULL)
- pGlue->onEvent(event);
-}
-
-void PPSServerGlue::onEvent(const PPSEvent& event)
-{
- callback* pFunc = NULL;
- std::string sArg;
-
- switch (event.getEventType()) {
-
- case PPSEvent::PPS_EVENT_OPENED:
- pFunc = m_handleOpen;
- sArg = EVENT_OPEN;
- break;
-
- // The server doesn't do anything with this event
- case PPSEvent::PPS_EVENT_FIRST_READ_COMPLETE:
- break;
-
- case PPSEvent::PPS_EVENT_NEW_DATA:
- {
- ppsObject data(event.getNewData());
-
- // This means a new connection
- if (data.flags & PPS_CREATED) {
- sArg = EVENT_CLIENT_CONNECT;
- pFunc = m_handleClientConnect;
- }
- // This means a connection is closed
- else if (data.flags & PPS_DELETED) {
- sArg = EVENT_CLIENT_DISCONNECT;
- pFunc = m_handleClientDisconnect;
- }
- // We're getting data from the connection
- else {
- sArg = EVENT_MESSAGE;
- pFunc = m_handleMessage;
- }
-
- sArg += " " + JSONEncodeData(data);
-
- break;
- }
-
- case PPSEvent::PPS_EVENT_CLOSED:
- pFunc = m_handleClose;
- sArg = EVENT_CLOSE;
- break;
-
- case PPSEvent::PPS_EVENT_OPEN_FAILED:
- pFunc = m_handleOpenFailed;
- sArg = EVENT_OPEN_FAILED + " " + event.getMessage();
- break;
-
- case PPSEvent::PPS_EVENT_WRITE_FAILED:
- pFunc = m_handleSendMessageFailed;
- sArg = EVENT_SEND_MESSAGE_FAILED + " " + event.getMessage();
- break;
-
- case PPSEvent::PPS_EVENT_READ_FAILED:
- pFunc = m_handleReceiveMessageFailed;
- sArg = EVENT_RECEIVE_MESSAGE_FAILED + event.getMessage();
- break;
- }
-
- if (pFunc != NULL)
- pFunc(m_pArg, sArg);
-
-}
-
-std::string PPSServerGlue::JSONEncodeData(const ppsObject& ppsObj) const
-{
- // If the ppsObj is empty, we can't encode it
- if (ppsObj.name.empty())
- return "";
-
- Json::Value eventData(Json::nullValue);
-
- // Set the client id
- // Chop off the '+' or '-' if it's there
- eventData[JSON_CONNECTION_ID] = ppsObj.name;
-
- for (const_ppsAttrIter it = ppsObj.attributes.begin(); it != ppsObj.attributes.end(); it++) {
-
- ppsAttribute ppsAttrib = (*it).second;
-
- // The value is a number
- if (ppsAttrib.encoding == ENCODING_N) {
-
- // Convert the value to floating point
- // istringstream is locale aware - we shouldn't need to perform any special
- // processing in order to properly convert the data to a floating point
- // TODO: test that the istringstream conversion works with a locale
- // that uses alternate floating point number encoding
- std::istringstream stream(ppsAttrib.value);
- double doubleValue;
-
- // Try to convert the value to a floating point
- if (!(stream >> doubleValue)) {
-
- std::string err = EVENT_RECEIVE_MESSAGE_FAILED + " Failed to convert the string \"" + ppsAttrib.value + "\" to a real number.";
- m_handleReceiveMessageFailed(m_pArg, err);
- return "";
- }
-
- eventData[JSON_DATA][ppsAttrib.name] = doubleValue;
- }
- // The value is a boolean
- else if (ppsAttrib.encoding == ENCODING_B) {
-
- eventData[JSON_DATA][ppsAttrib.name] = (ppsAttrib.value == "true");
- }
- // The value is JSON data
- else if (ppsAttrib.encoding == ENCODING_JSON) {
-
- Json::Reader reader;
- reader.parse(ppsAttrib.value, eventData[JSON_DATA][ppsAttrib.name]);
- }
- // Just pass the value through as a straight string
- else {
-
- eventData[JSON_DATA][ppsAttrib.name] = ppsAttrib.value;
- }
- }
-
- Json::FastWriter writer;
- return writer.write(eventData);
-}
-
-std::string PPSServerGlue::JSONDecodeData(const std::string& data) const
-{
- Json::Reader reader;
- Json::Value root;
-
- bool parsingSuccessful = reader.parse(data, root);
-
- // If parsing the JSON string fails, return a write error
- if (!parsingSuccessful) {
-
- std::string err = EVENT_SEND_MESSAGE_FAILED + " JSON failed to parse the string (\"" + data + "\") to be written. (" + reader.getFormatedErrorMessages() + ")";
- m_handleSendMessageFailed(m_pArg, err);
- return "";
- }
-
- Json::Value::Members memberNames = root.getMemberNames();
-
- std::ostringstream output;
- output.precision(15);
-
- Json::Value member;
-
- for (unsigned int i = 0; i < memberNames.size(); i++) {
-
- output << memberNames[i] << ":";
- member = root[memberNames[i]];
-
- if (member.isObject() || member.isArray()) {
-
- Json::FastWriter writer;
- output << ENCODING_JSON << ":" << writer.write(member);
- }
- else if (member.isBool()) {
-
- output << ENCODING_B << ":" << member.asString();
- }
- else if (member.isNumeric()) {
-
- output << ENCODING_N << ":" << member.asDouble();
- }
- else if (member.isString()) {
-
- output << ":" << member.asString();
- }
- else {
-
- std::string err = EVENT_SEND_MESSAGE_FAILED + " The string passed in (\"" + data + "\") contains an invalid JSON type.";
- m_handleSendMessageFailed(m_pArg, err);
- return "";
- }
-
- // Make sure we terminate the line
- output << std::endl;
- }
-
- return output.str();
-}
-
-} /* namespace jpps */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.h
deleted file mode 100644
index 8891829..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PPSServerGlue.h
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software. Free development
- * licenses are available for evaluation and non-commercial purposes. For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others. Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PPSSERVERGLUE_H_
-#define PPSSERVERGLUE_H_
-
-#include "../core/PPSInterface.h"
-#include "PluginTypes.h"
-
-// Forward declaration
-namespace Json {
-class StaticString;
-}
-namespace jpps {
-class PPSEvent;
-struct ppsObject;
-}
-
-namespace jpps {
-
-/**
- * Act as glue between jpps Server class an the PPSInterface.
- * This class encapsulates a PPS object as a PPS server.
- * TODO: write a better comment
- */
-class PPSServerGlue {
-
-public:
-
- /**
- * Constructor.
- */
- PPSServerGlue();
-
- /**
- * Destructor.
- */
- virtual ~PPSServerGlue();
-
- /**
- * The browser plugin should set these handlers.
- *
- * @param pArg pArg will be passed back to each callback function when it is called.
- */
- void callbackInit(void* pArg,
- callback* handleOpen,
- callback* handleClose,
- callback* handleClientConnect,
- callback* handleClientDisconnect,
- callback* handleMessage,
- callback* handleOpenFailed,
- callback* handleSendMessageFailed,
- callback* handleReceiveMessageFailed);
-
- /**
- * Set the verbosity of logging to the slog.
- */
- void setVerbose(unsigned short v);
-
- /**
- * Open a PPS server object.
- */
- bool open(const std::string& path, int oflags);
-
- /**
- * Close this PPS server object.
- */
- void close();
-
- /**
- * Send a message to a particular client.
- */
- void sendMessage(const std::string& clientID, const std::string& msg);
-
- /**
- * Send a message to all clients.
- */
- void broadcastMessage(const std::string& msg);
-
- /**
- * The function that the PPSInterface will call when an event happens.
- * This is the static function that is used as a function pointer for
- * PPSInterface::setEventFunc().
- *
- * @param event The event PPSInterface is sending.
- * @param pArg A pointer to a PPSInterfaceGlue object, passed in during
- * object construction.
- */
- static void onEvent(void* pArg, const PPSEvent& event);
-
-private:
-
- /**
- * The static PPSInterfaceGlue::onEvent() calls this onEvent to do the actual work.
- */
- void onEvent(const PPSEvent& event);
-
- /**
- * Take a ppsObject and turn it into a JSON string to send back to the JavaScript
- * with a onMessage event.
- */
- std::string JSONEncodeData(const ppsObject& ppsObj) const;
-
- /**
- * Take a JSON string and change it into a PPS consumable string.
- */
- std::string JSONDecodeData(const std::string& data) const;
-
- // String names for the various events
- static const std::string EVENT_OPEN;
- static const std::string EVENT_CLOSE;
- static const std::string EVENT_CLIENT_CONNECT;
- static const std::string EVENT_CLIENT_DISCONNECT;
- static const std::string EVENT_MESSAGE;
- static const std::string EVENT_OPEN_FAILED;
- static const std::string EVENT_SEND_MESSAGE_FAILED;
- static const std::string EVENT_RECEIVE_MESSAGE_FAILED;
-
- /** Custom PPS encoding value: an "n" means a real number. */
- static const std::string ENCODING_N;
- /** Custom PPS encoding value: a "b" means a boolean value. */
- static const std::string ENCODING_B;
- /** Custom PPS encoding value: the data is encoded using JSON. */
- static const std::string ENCODING_JSON;
-
- // JSON constants
- static const Json::StaticString JSON_DATA;
- static const Json::StaticString JSON_CONNECTION_ID;
-
- /** The interface this object wraps. */
- PPSInterface m_interface;
-
- // Handlers for various events
- void* m_pArg;
- callback* m_handleOpen;
- callback* m_handleClose;
- callback* m_handleClientConnect;
- callback* m_handleClientDisconnect;
- callback* m_handleMessage;
- callback* m_handleOpenFailed;
- callback* m_handleSendMessageFailed;
- callback* m_handleReceiveMessageFailed;
-
-};
-
-} /* namespace jpps */
-#endif /* PPSSERVERGLUE_H_ */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PluginTypes.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PluginTypes.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PluginTypes.h
deleted file mode 100644
index 9ce6b32..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/PluginTypes.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software. Free development
- * licenses are available for evaluation and non-commercial purposes. For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others. Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef PLUGINTYPES_H_
-#define PLUGINTYPES_H_
-
-namespace jpps {
-
-/**
- * Function type for setting handles between JNext plug-in and glue classes.
- */
-typedef void (callback)(void* pArg, const std::string&);
-
-}
-
-
-#endif /* PLUGINTYPES_H_ */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/pluginManifest.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/pluginManifest.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/pluginManifest.cpp
deleted file mode 100644
index e06ad4c..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/plugin/pluginManifest.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software. Free development
- * licenses are available for evaluation and non-commercial purposes. For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others. Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#include "JPPSPlugin.h"
-#include "JPPSServerPlugin.h"
-
-#include <string>
-
-/**
- * This callback must be implemented by all JSExt objects. It is invoked from
- * plugin.cpp.
- *
- * @return A comma separated list of classes supported by this JNEXT extension
- */
-char* onGetObjList(void)
-{
- static char* ppsclasses = NULL;
-
- if (ppsclasses == NULL) {
-
- // Get the length of all the strings, +1 for the ',' +1 for the \0
- int size = std::strlen(jpps::JPPSPlugin::CLASS_NAME) + std::strlen(jpps::JPPSServerPlugin::CLASS_NAME) + 1 + 1;
- ppsclasses = new char[size];
- std::strcpy(ppsclasses, jpps::JPPSPlugin::CLASS_NAME);
- std::strcat(ppsclasses, ",");
- std::strcat(ppsclasses, jpps::JPPSServerPlugin::CLASS_NAME);
- ppsclasses[size] = '\0';
- }
- // Return a comma separated list of classes known to this plugin
- return ppsclasses;
-}
-
-/**
- * This callback must be implemented by all JSExt objects. It is invoked from
- * plugin.cpp.
- *
- * @param strClassName Name of the class requested to be created Valid named are those
- * that are returned in onGetObjList
- *
- * @param strObjId The unique object id for the class
- *
- * @return A pointer to the created extension object
- */
-JSExt* onCreateObject(const std::string& strClassName, const std::string& strObjId)
-{
- // Given a class name and identifier, create the relevant object.
- if (strClassName == jpps::JPPSPlugin::CLASS_NAME) {
- return new jpps::JPPSPlugin(strObjId);;
- }
- else if (strClassName == jpps::JPPSServerPlugin::CLASS_NAME) {
- return new jpps::JPPSServerPlugin(strObjId);
- }
-
- // Any other name is invalid
- return NULL;
-}
-
-
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Logger.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Logger.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Logger.h
deleted file mode 100644
index 37a9d17..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Logger.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software. Free development
- * licenses are available for evaluation and non-commercial purposes. For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others. Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef LOGGER_H_
-#define LOGGER_H_
-
-#include <string>
-
-#include <sys/slog.h>
-#include <sys/slogcodes.h>
-
-namespace jpps {
-
-/**
- * The Logger class writes messages to the system log. It has a verbosity setting
- * in order to prevent cluttering the slog during normal operation.
- */
-class Logger {
-
-public:
-
- enum slogType {
- info = _SLOG_INFO,
- warning = _SLOG_WARNING,
- error = _SLOG_ERROR,
- critical = _SLOG_CRITICAL,
- debug = _SLOG_DEBUG1
- };
-
- /**
- * Default constructor. Sets the verbosity to 0;
- */
- Logger() : m_verbosity(0) {}
-
- /**
- * Destructor.
- */
- ~Logger() {}
-
- /**
- * Set the desired level of verbosity. A value of 0 means that only warning,
- * error and critical messages will appear in the slog. A verbosity of 1 adds
- * info messages. A verbosity of 2 adds debug messages.
- */
- inline void setVerbosity(unsigned short value) { m_verbosity = value; }
-
- /**
- * Get the current level of verbosity.
- */
- inline unsigned short getVerbosity() const { return m_verbosity; }
-
- /**
- * Used to send messages to the system log (slog).
- *
- * @param type The type of slog message.
- * @param message The message to put in the slog.
- */
- void slog(const slogType& type, const std::string& message) const {
-
- // Don't display info or debug when verbosity is set to 0
- if (m_verbosity == 0 && (type == info || type == debug)) return;
- // Don't display debug when verbosity is set to 1
- if (m_verbosity == 1 && type == debug) return;
-
- ::slogf(_SLOG_SETCODE(_SLOGC_GRAPHICS, 300), type, "%s", message.c_str());
- }
-
-private:
-
- /** The verbosity level. */
- unsigned short m_verbosity;
-};
-
-}
-
-#endif /* LOGGER_H_ */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.cpp b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.cpp
deleted file mode 100644
index 82ab5d1..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-#include "Thread.h"
-#include <pthread.h>
-#include "Logger.h"
-#include <sstream>
-#include <string.h>
-#include <errno.h>
-
-namespace jpps {
-
-Thread::Thread()
-: m_threadID(-1)
-{
- // Init the thread with all defaults
- pthread_attr_init(&m_attrib);
-}
-
-Thread::~Thread()
-{
- // Dispose of the thread attributes
- pthread_attr_destroy(&m_attrib);
-}
-
-void Thread::start(void* (*start_routine)(void*), void* arg, const std::string& thread_name)
-{
- // If this thread is already started, you can't start a new one
- if (m_threadID != -1) {
- return;
- }
-
- // Create a new thread
- if (pthread_create(&m_threadID, &m_attrib, start_routine, arg) != 0) {
-
- std::ostringstream ostream;
- ostream << "Thread::start() Failed - Failed to create a new thread. "
- << " (" << errno << ": " << strerror(errno) << ")";
-
- Logger logger;
- logger.slog(Logger::warning, ostream.str());
- }
-
- if (!thread_name.empty())
- pthread_setname_np(m_threadID, thread_name.c_str());
-}
-
-void Thread::stop()
-{
- // If the thread wasn't running, we can't stop it
- if (m_threadID == -1) {
- return;
- }
-
- // Cancel the thread
- if (pthread_cancel(m_threadID) != 0) {
-
- std::ostringstream ostream;
- ostream << "Thread::stop() Failed - Failed to cancel thread " << m_threadID << "."
- << " (" << errno << ": " << strerror(errno) << ")";
-
- Logger logger;
- logger.slog(Logger::warning, ostream.str());
- }
-
- // Reset the thread ID
- m_threadID = -1;
-}
-
-} /* namespace jpps */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.h
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.h b/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.h
deleted file mode 100644
index 79cc62a..0000000
--- a/blackberry10/bin/templates/project/plugins/JPPS/src/blackberry10/native/src/utils/Thread.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
- */
-
-/*
- * $QNXLicenseC:
- * Copyright 2009, QNX Software Systems. All Rights Reserved.
- *
- * You must obtain a written license from and pay applicable license fees to QNX
- * Software Systems before you may reproduce, modify or distribute this software,
- * or any work that includes all or part of this software. Free development
- * licenses are available for evaluation and non-commercial purposes. For more
- * information visit http://licensing.qnx.com or email licensing@qnx.com.
- *
- * This file may contain contributions from others. Please review this entire
- * file for other proprietary rights or license notices, as well as the QNX
- * Development Suite License Guide at http://licensing.qnx.com/license-guide/
- * for other information.
- * $
- */
-
-#ifndef THREAD_H_
-#define THREAD_H_
-
-#include <sys/types.h>
-#include <string>
-
-namespace jpps {
-
-/**
- * Simple wrapper to simplify thread management.
- */
-class Thread {
-
-public:
-
- /**
- * Constructor.
- */
- Thread();
-
- /**
- * Destructor.
- */
- virtual ~Thread();
-
- /**
- * Start a thread with the given function. If the thread is already running and has not
- * been stopped, this does nothing.
- */
- void start(void* (*start_routine)(void*), void* arg, const std::string& thread_name = "");
-
- /**
- * Stop the thread. If the thread isn't running, this does nothing.
- */
- void stop();
-
- /**
- * Is the thread running?
- */
- inline bool isRunning() const { return (m_threadID >= 0); }
-
-private:
-
- /** The id of this thread. */
- pthread_t m_threadID;
-
- /** The attributes of this thread. */
- pthread_attr_t m_attrib;
-};
-
-} /* namespace jpps */
-#endif /* THREAD_H_ */
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/Makefile b/blackberry10/bin/templates/project/plugins/Utils/Makefile
deleted file mode 100644
index 0e22650..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/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/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/native/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/Makefile b/blackberry10/bin/templates/project/plugins/Utils/native/Makefile
new file mode 100644
index 0000000..0cc5eae
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/native/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/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/native/common.mk
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/common.mk b/blackberry10/bin/templates/project/plugins/Utils/native/common.mk
new file mode 100644
index 0000000..90a43db
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/native/common.mk
@@ -0,0 +1,18 @@
+ifndef QCONFIG
+QCONFIG=qconfig.mk
+endif
+include $(QCONFIG)
+
+NAME=utils
+LDFLAGS+=-Wl,-h,libutils.so
+
+include ../../../../../../meta.mk
+
+SRCS+=$(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_reader.cpp \
+ $(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_value.cpp \
+ $(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_writer.cpp \
+ webworks_utils.cpp
+
+include $(MKFILES_ROOT)/qtargets.mk
+
+LIBS += socket
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/native/device/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/device/libutils.so b/blackberry10/bin/templates/project/plugins/Utils/native/device/libutils.so
new file mode 100644
index 0000000..126d02c
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/Utils/native/device/libutils.so differ
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/native/simulator/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/simulator/libutils.so b/blackberry10/bin/templates/project/plugins/Utils/native/simulator/libutils.so
new file mode 100644
index 0000000..392ad33
Binary files /dev/null and b/blackberry10/bin/templates/project/plugins/Utils/native/simulator/libutils.so differ
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.cpp b/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.cpp
new file mode 100644
index 0000000..68397a1
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.cpp
@@ -0,0 +1,55 @@
+/*
+ * 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 <resolv.h>
+#include <sstream>
+#include <string>
+
+#include "webworks_utils.hpp"
+
+namespace webworks {
+
+std::string Utils::intToStr(const int val)
+{
+ std::string s;
+ std::stringstream out;
+ out << val;
+ return out.str();
+}
+
+int Utils::strToInt(const std::string& val) {
+ int number;
+
+ if (!(std::istringstream(val) >> number)) {
+ return -1;
+ }
+ return number;
+}
+
+std::string Utils::toBase64(const unsigned char *input, const size_t size)
+{
+ size_t outputSize = size * 4;
+ char *output = new char[outputSize];
+ outputSize = b64_ntop(input, size, output, outputSize);
+ output[outputSize] = 0;
+
+ std::string outputString(output);
+ delete output;
+
+ return outputString;
+}
+
+} // namespace webworks
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.hpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.hpp b/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.hpp
new file mode 100644
index 0000000..4ab2ca7
--- /dev/null
+++ b/blackberry10/bin/templates/project/plugins/Utils/native/webworks_utils.hpp
@@ -0,0 +1,34 @@
+/*
+ * 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 WW_UTILS_HPP_
+#define WW_UTILS_HPP_
+
+#include <string.h>
+#include <string>
+
+namespace webworks {
+
+class Utils {
+public:
+ static std::string intToStr(const int val);
+ static int strToInt(const std::string& val);
+ static std::string toBase64(const unsigned char *input, const size_t size);
+};
+
+} // namespace webworks
+
+#endif // WW_UTILS_HPP_
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/Makefile b/blackberry10/bin/templates/project/plugins/Utils/src/Makefile
deleted file mode 100644
index 0e22650..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/src/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/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/Makefile b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/Makefile
deleted file mode 100644
index 0e22650..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/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/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/Makefile
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/Makefile b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/Makefile
deleted file mode 100644
index 0cc5eae..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/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/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/common.mk
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/common.mk b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/common.mk
deleted file mode 100644
index 90a43db..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/common.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-ifndef QCONFIG
-QCONFIG=qconfig.mk
-endif
-include $(QCONFIG)
-
-NAME=utils
-LDFLAGS+=-Wl,-h,libutils.so
-
-include ../../../../../../meta.mk
-
-SRCS+=$(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_reader.cpp \
- $(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_value.cpp \
- $(WEBWORKS_DIR)/dependencies/JsonCpp/jsoncpp-src-0.6.0-rc2/src/lib_json/json_writer.cpp \
- webworks_utils.cpp
-
-include $(MKFILES_ROOT)/qtargets.mk
-
-LIBS += socket
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/device/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/device/libutils.so b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/device/libutils.so
deleted file mode 100644
index 126d02c..0000000
Binary files a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/device/libutils.so and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/simulator/libutils.so
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/simulator/libutils.so b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/simulator/libutils.so
deleted file mode 100644
index 392ad33..0000000
Binary files a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/simulator/libutils.so and /dev/null differ
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.cpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.cpp b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.cpp
deleted file mode 100644
index 68397a1..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.cpp
+++ /dev/null
@@ -1,55 +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.
- */
-
-#include <resolv.h>
-#include <sstream>
-#include <string>
-
-#include "webworks_utils.hpp"
-
-namespace webworks {
-
-std::string Utils::intToStr(const int val)
-{
- std::string s;
- std::stringstream out;
- out << val;
- return out.str();
-}
-
-int Utils::strToInt(const std::string& val) {
- int number;
-
- if (!(std::istringstream(val) >> number)) {
- return -1;
- }
- return number;
-}
-
-std::string Utils::toBase64(const unsigned char *input, const size_t size)
-{
- size_t outputSize = size * 4;
- char *output = new char[outputSize];
- outputSize = b64_ntop(input, size, output, outputSize);
- output[outputSize] = 0;
-
- std::string outputString(output);
- delete output;
-
- return outputString;
-}
-
-} // namespace webworks
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/b3960ef0/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.hpp
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.hpp b/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.hpp
deleted file mode 100644
index 4ab2ca7..0000000
--- a/blackberry10/bin/templates/project/plugins/Utils/src/blackberry10/native/webworks_utils.hpp
+++ /dev/null
@@ -1,34 +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.
- */
-
-#ifndef WW_UTILS_HPP_
-#define WW_UTILS_HPP_
-
-#include <string.h>
-#include <string>
-
-namespace webworks {
-
-class Utils {
-public:
- static std::string intToStr(const int val);
- static int strToInt(const std::string& val);
- static std::string toBase64(const unsigned char *input, const size_t size);
-};
-
-} // namespace webworks
-
-#endif // WW_UTILS_HPP_