242 /// played. This is where the movie playing specific shutdown code |
246 /// played. This is where the movie playing specific shutdown code |
243 /// goes. |
247 /// goes. |
244 void |
248 void |
245 nsPluginInstance::shut() |
249 nsPluginInstance::shut() |
246 { |
250 { |
247 D("[ns] shut"); |
251 D("[ns] shut"); |
248 } |
252 } |
249 |
253 |
250 NPError |
254 NPError |
251 nsPluginInstance::SetWindow(NPWindow* aWindow) |
255 nsPluginInstance::SetWindow(NPWindow* aWindow) |
252 { |
256 { |
253 D("[ns] SetWindow"); |
257 D("[ns] SetWindow"); |
254 |
258 |
255 if(!aWindow) |
259 if(!aWindow) |
256 { |
260 { |
257 return NPERR_INVALID_PARAM; |
261 return NPERR_INVALID_PARAM; |
258 } |
262 } |
259 |
263 |
260 return NPERR_NO_ERROR; |
264 return NPERR_NO_ERROR; |
261 } |
265 } |
262 |
266 |
263 NPError |
267 NPError |
264 nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue) |
268 nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue) |
265 { |
269 { |
266 return NS_PluginGetValue(aVariable, aValue); |
270 return NS_PluginGetValue(aVariable, aValue); |
267 } |
271 } |
268 |
272 |
269 /// \brief Write a status message |
273 /// \brief Write a status message |
270 /// |
274 /// |
271 /// This writes a status message to the status line at the bottom of |
275 /// This writes a status message to the status line at the bottom of |
272 /// the browser window and the console firefox was started from. |
276 /// the browser window and the console firefox was started from. |
273 NPError |
277 NPError |
274 nsPluginInstance::WriteStatus(const char *msg) const |
278 nsPluginInstance::WriteStatus(const char *msg) const |
275 { |
279 { |
276 NPN_Status(_instance, msg); |
280 NPN_Status(_instance, msg); |
277 std::cout << msg << std::endl; |
281 std::cout << msg << std::endl; |
278 |
282 |
279 return NPERR_NO_ERROR; |
283 return NPERR_NO_ERROR; |
280 } |
284 } |
281 |
285 |
282 NPError |
286 NPError |
283 nsPluginInstance::NewStream(NPMIMEType /*type*/, NPStream* stream, |
287 nsPluginInstance::NewStream(NPMIMEType /*type*/, NPStream* stream, |
284 NPBool /*seekable*/, uint16* /*stype*/) |
288 NPBool /*seekable*/, uint16* /*stype*/) |
285 { |
289 { |
286 D("[ns] NewStream"); |
290 D("[ns] NewStream"); |
287 return NPERR_NO_ERROR; |
291 return NPERR_NO_ERROR; |
288 } |
292 } |
289 |
293 |
290 NPError |
294 NPError |
291 nsPluginInstance::DestroyStream(NPStream* /*stream*/, NPError /*reason*/) |
295 nsPluginInstance::DestroyStream(NPStream* /*stream*/, NPError /*reason*/) |
292 { |
296 { |
293 D("[ns] DestroyStream"); |
297 D("[ns] DestroyStream"); |
294 return NPERR_NO_ERROR; |
298 return NPERR_NO_ERROR; |
295 } |
299 } |
296 |
300 |
297 int32_t |
301 int32_t |
298 nsPluginInstance::WriteReady(NPStream* /* stream */ ) |
302 nsPluginInstance::WriteReady(NPStream* /* stream */ ) |
299 { |
303 { |
300 D("[ns] WriteReady"); |
304 D("[ns] WriteReady"); |
301 return 0x0fffffff; |
305 return 0x0fffffff; |
302 } |
306 } |
303 |
307 |
304 int32_t |
308 int32_t |
305 nsPluginInstance::Write(NPStream* /*stream*/, int32_t /*offset*/, int32_t len, |
309 nsPluginInstance::Write(NPStream* /*stream*/, int32_t /*offset*/, int32_t len, |
306 void* buffer) |
310 void* buffer) |
307 { |
311 { |
308 D("[ns] Write: len=" << len); |
312 D("[ns] Write: len=" << len); |
309 return len; |
313 return len; |
310 } |
314 } |
311 |
315 |
312 typedef struct { |
316 typedef struct { |
313 NPP instance; |
317 NPP instance; |
314 TuioEventData data; |
318 TuioEventData data; |
315 } Event; |
319 } Event; |
316 |
320 |
317 void test(void* ev) |
321 void test(void* ev) |
318 { |
322 { |
319 D("ev=" << ev); |
323 D("ev=" << ev); |
320 Event* event = (Event*)ev; |
324 Event* event = (Event*)ev; |
321 D("event=" << event); |
325 D("event=" << event); |
322 std::stringstream ss; |
326 std::stringstream ss; |
323 ss << "javascript:tuio_callback("; |
327 ss << "javascript:tuio_callback("; |
324 ss << event->data.type << ", "; |
328 ss << event->data.type << ", "; |
325 ss << event->data.sid << ", "; |
329 ss << event->data.sid << ", "; |
326 ss << event->data.fid << ", "; |
330 ss << event->data.fid << ", "; |
327 ss << event->data.x << ", "; |
331 ss << event->data.x << ", "; |
328 ss << event->data.y << ", "; |
332 ss << event->data.y << ", "; |
329 ss << event->data.z << ", "; |
333 ss << event->data.z << ", "; |
330 ss << event->data.a << ", "; |
334 ss << event->data.a << ", "; |
331 if(event->data.code == NULL || event->data.code == "") |
335 if(event->data.code == NULL || event->data.code == "") |
332 ss << "\"\");"; |
336 ss << "\"\");"; |
333 else |
337 else |
334 ss << "\"" << event->data.code << "\"" << ");"; |
338 ss << "\"" << event->data.code << "\"" << ");"; |
335 |
339 |
336 NPN_GetURL(event->instance, ss.str().c_str(), "_self"); |
340 NPN_GetURL(event->instance, ss.str().c_str(), "_self"); |
337 |
341 |
338 delete event; |
342 delete event; |
339 } |
343 } |
340 |
344 |
341 void nsPluginInstance::event(TuioEventData data) |
345 void nsPluginInstance::event(TuioEventData data) |
342 { |
346 { |
343 D("[event] callback: type=" << data.type |
347 D("[event] callback: type=" << data.type |
344 << ", sid=" << data.sid << ", fid=" << data.fid |
348 << ", sid=" << data.sid << ", fid=" << data.fid |
345 << ", x=" << data.x << ", y=" << data.y |
349 << ", x=" << data.x << ", y=" << data.y |
346 << ", z=" << data.z << ", a=" << data.a |
350 << ", z=" << data.z << ", a=" << data.a |
347 << ", code=" << "\"" << data.code << "\""); |
351 << ", code=" << "\"" << data.code << "\""); |
348 |
352 |
349 Event* ev = new Event(); |
353 Event* ev = new Event(); |
350 ev->instance = _instance; |
354 ev->instance = _instance; |
351 ev->data = data; |
355 ev->data = data; |
352 |
356 |
353 NPN_PluginThreadAsyncCall(_instance, test, ev); |
357 NPN_PluginThreadAsyncCall(_instance, test, ev); |
354 } |
358 } |
355 |
359 |
356 // Local Variables: |
360 // Local Variables: |
357 // mode: C++ |
361 // mode: C++ |
358 // indent-tabs-mode: t |
362 // indent-tabs-mode: t |