front_idill/extern/fajran-npTuioClient/src/plugin.cpp
changeset 28 9ccef81f02ab
parent 27 6c08d4d7219e
--- a/front_idill/extern/fajran-npTuioClient/src/plugin.cpp	Thu Apr 12 13:09:46 2012 +0200
+++ b/front_idill/extern/fajran-npTuioClient/src/plugin.cpp	Thu Apr 12 15:33:25 2012 +0200
@@ -15,6 +15,10 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
+/*
+    Modified by alexandre.bastien@iri.centrepompidou.fr to manage TUIO strings.
+*/
+
 #include "plugin.h"
 
 #include <cstring>
@@ -40,10 +44,10 @@
 
 void tuio_callback(TuioEventData data)
 {
-	std::set<nsPluginInstance*>::iterator iter;
-	for (iter = instances.begin(); iter != instances.end(); iter++) {
-		(*iter)->event(data);
-	}
+    std::set<nsPluginInstance*>::iterator iter;
+    for (iter = instances.begin(); iter != instances.end(); iter++) {
+        (*iter)->event(data);
+    }
 }
 
 void
@@ -86,7 +90,7 @@
 
     plugInitialized = TRUE;
 
-	tuio_start(80);
+    tuio_start(80);
 
     return NPERR_NO_ERROR;
 }
@@ -112,7 +116,7 @@
     plugInitialized = FALSE;
 #endif
 
-	tuio_stop();
+    tuio_stop();
 }
 
 
@@ -187,8 +191,8 @@
     :
     nsPluginInstanceBase(),
     _instance(data->instance),
-	_port(3333),
-	_callback("tuio_callback")
+    _port(3333),
+    _callback("tuio_callback")
 {
     for (size_t i=0, n=data->argc; i<n; ++i)
     {
@@ -215,13 +219,13 @@
         }
     }
 
-	instances.insert(this);
+    instances.insert(this);
 }
 
 /// \brief Destructor
 nsPluginInstance::~nsPluginInstance()
 {
-	instances.erase(this);
+    instances.erase(this);
 }
 
 /// \brief Initialize an instance of the plugin object
@@ -232,7 +236,7 @@
 NPBool
 nsPluginInstance::init(NPWindow* aWindow)
 {
-	D("[ns] init");
+    D("[ns] init");
     return TRUE;
 }
 
@@ -244,26 +248,26 @@
 void
 nsPluginInstance::shut()
 {
-	D("[ns] shut");
+    D("[ns] shut");
 }
 
 NPError
 nsPluginInstance::SetWindow(NPWindow* aWindow)
 {
-	D("[ns] SetWindow");
+    D("[ns] SetWindow");
 
-	if(!aWindow)
-	{
-		return NPERR_INVALID_PARAM;
-	}
+    if(!aWindow)
+    {
+        return NPERR_INVALID_PARAM;
+    }
 
-	return NPERR_NO_ERROR;
+    return NPERR_NO_ERROR;
 }
 
 NPError
 nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
 {
-	return NS_PluginGetValue(aVariable, aValue);
+    return NS_PluginGetValue(aVariable, aValue);
 }
 
 /// \brief Write a status message
@@ -273,84 +277,84 @@
 NPError
 nsPluginInstance::WriteStatus(const char *msg) const
 {
-	NPN_Status(_instance, msg);
-	std::cout << msg << std::endl;
+    NPN_Status(_instance, msg);
+    std::cout << msg << std::endl;
 
-	return NPERR_NO_ERROR;
+    return NPERR_NO_ERROR;
 }
 
 NPError
 nsPluginInstance::NewStream(NPMIMEType /*type*/, NPStream* stream,
                             NPBool /*seekable*/, uint16* /*stype*/)
 {
-	D("[ns] NewStream");
-	return NPERR_NO_ERROR;
+    D("[ns] NewStream");
+    return NPERR_NO_ERROR;
 }
 
 NPError
 nsPluginInstance::DestroyStream(NPStream* /*stream*/, NPError /*reason*/)
 {
-	D("[ns] DestroyStream");
-	return NPERR_NO_ERROR;
+    D("[ns] DestroyStream");
+    return NPERR_NO_ERROR;
 }
 
 int32_t
 nsPluginInstance::WriteReady(NPStream* /* stream */ )
 {
-	D("[ns] WriteReady");
-	return 0x0fffffff;
+    D("[ns] WriteReady");
+    return 0x0fffffff;
 }
 
 int32_t
 nsPluginInstance::Write(NPStream* /*stream*/, int32_t /*offset*/, int32_t len,
         void* buffer)
 {
-	D("[ns] Write: len=" << len);
-	return len;
+    D("[ns] Write: len=" << len);
+    return len;
 }
 
 typedef struct {
-	NPP instance;
-	TuioEventData data;
+    NPP instance;
+    TuioEventData data;
 } Event;
 
 void test(void* ev)
 {
-	D("ev=" << ev);
-	Event* event = (Event*)ev;
-	D("event=" << event);
-	std::stringstream ss;
-	ss << "javascript:tuio_callback(";
-	ss << event->data.type << ", ";
-	ss << event->data.sid << ", ";
-	ss << event->data.fid << ", ";
-	ss << event->data.x << ", ";
-	ss << event->data.y << ", ";
-	ss << event->data.z << ", ";
-	ss << event->data.a << ", ";
-	if(event->data.code == NULL || event->data.code == "")
-		ss << "\"\");";
-	else
-		ss << "\"" << event->data.code << "\"" << ");";
-	
-	NPN_GetURL(event->instance, ss.str().c_str(), "_self");
+    D("ev=" << ev);
+    Event* event = (Event*)ev;
+    D("event=" << event);
+    std::stringstream ss;
+    ss << "javascript:tuio_callback(";
+    ss << event->data.type << ", ";
+    ss << event->data.sid << ", ";
+    ss << event->data.fid << ", ";
+    ss << event->data.x << ", ";
+    ss << event->data.y << ", ";
+    ss << event->data.z << ", ";
+    ss << event->data.a << ", ";
+    if(event->data.code == NULL || event->data.code == "")
+        ss << "\"\");";
+    else
+        ss << "\"" << event->data.code << "\"" << ");";
+    
+    NPN_GetURL(event->instance, ss.str().c_str(), "_self");
 
-	delete event;
+    delete event;
 }
 
 void nsPluginInstance::event(TuioEventData data)
 {
-	D("[event] callback: type=" << data.type
-	<< ", sid=" << data.sid << ", fid=" << data.fid
-	<< ", x=" << data.x << ", y=" << data.y
-	<< ", z=" << data.z << ", a=" << data.a
-	<< ", code=" << "\"" << data.code << "\"");
-	
-	Event* ev = new Event();
-	ev->instance = _instance;
-	ev->data = data;
+    D("[event] callback: type=" << data.type
+    << ", sid=" << data.sid << ", fid=" << data.fid
+    << ", x=" << data.x << ", y=" << data.y
+    << ", z=" << data.z << ", a=" << data.a
+    << ", code=" << "\"" << data.code << "\"");
+    
+    Event* ev = new Event();
+    ev->instance = _instance;
+    ev->data = data;
 
-	NPN_PluginThreadAsyncCall(_instance, test, ev);
+    NPN_PluginThreadAsyncCall(_instance, test, ev);
 }
 
 // Local Variables: