summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml/plugins')
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp26
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp2
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/TypedArray.h11
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp14
-rw-r--r--src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h4
-rw-r--r--src/uscxml/plugins/element/file/FileElement.cpp2
-rw-r--r--src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp3
-rw-r--r--src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.cpp5
-rw-r--r--src/uscxml/plugins/invoker/im/IMInvoker.cpp3
-rw-r--r--src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h6
11 files changed, 68 insertions, 10 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp
index 64f7028..3a3d373 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp
@@ -25,6 +25,7 @@ JSClassRef JSCArrayBuffer::Tmpl;
JSStaticValue JSCArrayBuffer::staticValues[] = {
{ "byteLength", byteLengthAttrGetter, 0, kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly },
+ { "mimeType", mimeTypeAttrGetter, mimeTypeAttrSetter, kJSPropertyAttributeDontDelete },
{ 0, 0, 0, 0 }
};
@@ -69,6 +70,31 @@ JSValueRef JSCArrayBuffer::byteLengthAttrGetter(JSContextRef ctx, JSObjectRef ob
}
+JSValueRef JSCArrayBuffer::mimeTypeAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) {
+ struct JSCArrayBufferPrivate* privData = (struct JSCArrayBufferPrivate*)JSObjectGetPrivate(object);
+
+ JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->getMimeType().c_str());
+ JSValueRef retVal = JSValueMakeString(ctx, stringRef);
+ JSStringRelease(stringRef);
+ return retVal;
+}
+
+
+bool JSCArrayBuffer::mimeTypeAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) {
+ struct JSCArrayBufferPrivate* privData = (struct JSCArrayBufferPrivate*)JSObjectGetPrivate(thisObj);
+
+ JSStringRef stringReflocalMimeType = JSValueToStringCopy(ctx, value, exception);
+ size_t localMimeTypeMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalMimeType);
+ char* localMimeTypeBuffer = new char[localMimeTypeMaxSize];
+ JSStringGetUTF8CString(stringReflocalMimeType, localMimeTypeBuffer, localMimeTypeMaxSize);
+ std::string localMimeType(localMimeTypeBuffer);
+ JSStringRelease(stringReflocalMimeType);
+ free(localMimeTypeBuffer);
+
+ privData->nativeObj->setMimeType(localMimeType);
+ return true;
+}
+
JSValueRef JSCArrayBuffer::sliceCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
struct JSCArrayBufferPrivate* privData = (struct JSCArrayBufferPrivate*)JSObjectGetPrivate(thisObj);
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h
index b7817f5..7d75e63 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h
@@ -43,6 +43,8 @@ public:
static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
static JSValueRef byteLengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);
+ static JSValueRef mimeTypeAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);
+ static bool mimeTypeAttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
static JSStaticValue staticValues[];
diff --git a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp
index 6d5b415..591a48a 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.cpp
@@ -42,7 +42,7 @@ ArrayBuffer::ArrayBuffer(boost::shared_ptr<Blob> buffer) : _buffer(buffer) {
}
ArrayBuffer::ArrayBuffer(void* data, unsigned int size) {
- _buffer = boost::shared_ptr<Blob>(new Blob(data, size));
+ _buffer = boost::shared_ptr<Blob>(new Blob(data, size, "application/octet-stream"));
}
unsigned long ArrayBuffer::getByteLength() {
diff --git a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h
index 56d2332..cee1ed9 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/TypedArray.h
@@ -93,6 +93,17 @@ public:
// memcpy(_buffer->_data + index * sizeof(unsigned char), &value, sizeof(unsigned char));
// }
+ std::string getMimeType() {
+ if (_buffer)
+ return _buffer->mimeType;
+ return "";
+ }
+
+ void setMimeType(const std::string& mimeType) {
+ if (_buffer)
+ _buffer->mimeType = mimeType;
+ }
+
boost::shared_ptr<Blob> _buffer;
};
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp
index a4fc18a..8eccc66 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.cpp
@@ -62,6 +62,20 @@ v8::Handle<v8::Value> V8ArrayBuffer::byteLengthAttrGetter(v8::Local<v8::String>
return v8::Integer::New(privData->nativeObj->getByteLength());
}
+v8::Handle<v8::Value> V8ArrayBuffer::mimeTypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
+ v8::Local<v8::Object> self = info.Holder();
+ struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferPrivate >(self->GetInternalField(0));
+
+ return v8::String::New(privData->nativeObj->getMimeType().c_str());
+}
+
+void V8ArrayBuffer::mimeTypeAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
+ v8::Local<v8::Object> self = info.Holder();
+ struct V8ArrayBufferPrivate* privData = V8DOM::toClassPtr<V8ArrayBufferPrivate >(self->GetInternalField(0));
+ v8::String::AsciiValue localMimeType(value);
+ privData->nativeObj->setMimeType(*localMimeType);
+}
+
v8::Handle<v8::Value> V8ArrayBuffer::sliceCallback(const v8::Arguments& args) {
v8::Local<v8::Object> self = args.Holder();
diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h
index 695947d..5745095 100644
--- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h
+++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ArrayBuffer.h
@@ -45,6 +45,8 @@ public:
static v8::Handle<v8::Value> isViewCallback(const v8::Arguments&);
static v8::Handle<v8::Value> byteLengthAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
+ static v8::Handle<v8::Value> mimeTypeAttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);
+ static void mimeTypeAttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
static v8::Handle<v8::Value> constructor(const v8::Arguments&);
static v8::Persistent<v8::FunctionTemplate> Constr;
@@ -71,6 +73,8 @@ public:
instance->SetAccessor(v8::String::NewSymbol("byteLength"), V8ArrayBuffer::byteLengthAttrGetter, 0,
v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None));
+ instance->SetAccessor(v8::String::NewSymbol("mimeType"), V8ArrayBuffer::mimeTypeAttrGetter, V8ArrayBuffer::mimeTypeAttrSetter,
+ v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None));
prototype->Set(v8::String::NewSymbol("slice"),
v8::FunctionTemplate::New(V8ArrayBuffer::sliceCallback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete));
diff --git a/src/uscxml/plugins/element/file/FileElement.cpp b/src/uscxml/plugins/element/file/FileElement.cpp
index a630a8a..2237f86 100644
--- a/src/uscxml/plugins/element/file/FileElement.cpp
+++ b/src/uscxml/plugins/element/file/FileElement.cpp
@@ -200,7 +200,7 @@ void FileElement::enterElement(const Arabica::DOM::Node<std::string>& node) {
switch (_type) {
case BINARY:
- event.data.compound["content"] = Data(fileContents, fileStat.st_size, 1);
+ event.data.compound["content"] = Data(fileContents, fileStat.st_size, "application/octet-stream", true);
break;
case TEXT:
event.data.compound["content"] = Data(fileContents, Data::VERBATIM);
diff --git a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp
index 374c287..3d25543 100644
--- a/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp
+++ b/src/uscxml/plugins/invoker/ffmpeg/FFMPEGInvoker.cpp
@@ -222,8 +222,7 @@ void FFMPEGInvoker::finish(EncodingContext* ctx, const SendRequest& req) {
Event event;
event.name = "render.done";
event.data.compound["context"] = context;
- event.data.compound["movie"] = Data(movieBuffer, length, true);
- event.data.compound["mimetype"] = Data("video/mpeg", Data::VERBATIM);
+ event.data.compound["movie"] = Data(movieBuffer, length, "video/mpeg", true);
event.data.compound["filename"] = Data(std::string("movie.") + ctx->extension, Data::VERBATIM);
returnEvent(event);
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.cpp
index 3fbcc36..7be93f3 100644
--- a/src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.cpp
+++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/converter/OSGConverter.cpp
@@ -33,6 +33,7 @@
#include <osg/ShapeDrawable>
#include <boost/lexical_cast.hpp>
+#include <boost/algorithm/string.hpp>
#ifdef BUILD_AS_PLUGINS
#include <Pluma/Connector.hpp>
@@ -239,7 +240,7 @@ void OSGConverter::process(const SendRequest& req) {
std::ofstream outFile(dest.c_str());
outFile << ss.str();
}
- Data content(ss.str().c_str(), ss.str().size(), false);
+ Data content(ss.str().c_str(), ss.str().size(), URL::getMimeType(format), false);
reportSuccess(req, content);
return;
}
@@ -619,7 +620,7 @@ void OSGConverter::NameRespectingWriteToFile::operator()(const osg::Image& image
#endif
Data content;
- content.compound[format] = Data(buffer, length, false);
+ content.compound[format] = Data(buffer, length, URL::getMimeType(format), false);
// save image as a raw rgba as well for ffmpeg - we are using the mpb format for now
// osg::ref_ptr<osgDB::ReaderWriter> writerRGBA = osgDB::Registry::instance()->getReaderWriterForExtension("rgba");
diff --git a/src/uscxml/plugins/invoker/im/IMInvoker.cpp b/src/uscxml/plugins/invoker/im/IMInvoker.cpp
index 1624b49..d1063bd 100644
--- a/src/uscxml/plugins/invoker/im/IMInvoker.cpp
+++ b/src/uscxml/plugins/invoker/im/IMInvoker.cpp
@@ -20,6 +20,7 @@
#include "IMInvoker.h"
#include <glog/logging.h>
#include "uscxml/UUID.h"
+#include <boost/algorithm/string.hpp>
#ifdef BUILD_AS_PLUGINS
#include <Pluma/Connector.hpp>
@@ -475,7 +476,7 @@ Data IMInvoker::buddyToData(PurpleBuddy *buddy) {
if (icon) {
size_t iconSize = 0;
gconstpointer iconData = purple_buddy_icon_get_data(icon, &iconSize);
- data.compound["icon"] = Data((char*)iconData, iconSize, false);
+ data.compound["icon"] = Data((char*)iconData, iconSize, "application/octet-stream", false);
}
PurplePresence* presence = purple_buddy_get_presence(buddy);
diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h
index 7c0e217..f26955e 100644
--- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h
+++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.h
@@ -32,7 +32,7 @@ namespace uscxml {
class Interpreter;
class USCXMLInvoker;
-
+
class USCXMLInvoker :
public InvokerImpl,
public boost::enable_shared_from_this<USCXMLInvoker> {
@@ -43,7 +43,7 @@ public:
virtual void push(const SendRequest& event);
USCXMLInvoker* _invoker;
};
-
+
USCXMLInvoker();
virtual ~USCXMLInvoker();
virtual boost::shared_ptr<InvokerImpl> create(InterpreterImpl* interpreter);
@@ -60,7 +60,7 @@ public:
virtual void send(const SendRequest& req);
virtual void cancel(const std::string sendId);
virtual void invoke(const InvokeRequest& req);
-
+
protected:
bool _cancelled;
ParentQueue _parentQueue;