2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 * @author Pawel Misiak (p.misiak@samsung.com)
27 #ifndef WRT_PLUGINS_TIZEN_JS_MESSAGE_ATTACHMENT_H_
28 #define WRT_PLUGINS_TIZEN_JS_MESSAGE_ATTACHMENT_H_
30 #include <JavaScriptCore/JavaScript.h>
31 #include <CommonsJavaScript/PrivateObject.h>
32 #include <API/Messaging/IMessagingService.h>
33 #include <API/Messaging/IMessage.h>
38 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Messaging::IAttachmentPtr>::Type JSMessageAttachmentPrivate; //IAttachmentPtr
40 class JSMessageAttachment
42 static JSClassRef m_jsClassRef;
45 static const JSClassDefinition* getClassInfo();
46 static JSClassRef getClassRef();
47 static JSObjectRef createJS( JSContextRef context, const Api::Messaging::IAttachmentPtr &msg);
52 * The callback invoked when an object is first created.
54 static void initialize(JSContextRef context,
58 * The callback invoked when an object is finalized.
60 static void finalize(JSObjectRef object);
62 static bool hasProperty(JSContextRef context,
64 JSStringRef propertyName);
68 * Get MIME Type of Attachment File. readonly
70 static JSValueRef getMIMEType(JSContextRef context,
72 JSStringRef propertyName,
73 JSValueRef* exception);
76 static JSValueRef getMessageID(JSContextRef context,
78 JSStringRef propertyName,
79 JSValueRef* exception);
81 static JSValueRef getContentLocation(JSContextRef context,
83 JSStringRef propertyName,
84 JSValueRef* exception);
86 static JSValueRef getContentID(JSContextRef context,
88 JSStringRef propertyName,
89 JSValueRef* exception);
92 static JSValueRef getLoaded(JSContextRef context,
94 JSStringRef propertyName,
95 JSValueRef* exception);
97 static JSValueRef getFile(JSContextRef context,
99 JSStringRef propertyName,
100 JSValueRef* exception);
103 * returns private object or throws WrtDeviceApis::Commons::NullPointerException
105 static JSMessageAttachmentPrivate* getPrivate(JSObjectRef value);
108 * extracts Api Message representation
109 * throws WrtDeviceApis::Commons::NullPointerException if there's no private object
110 * throws WrtDeviceApis::Commons::ConversionException if it's not possible to convert to JSObjectRef
112 static Api::Messaging::IAttachmentPtr getAttachment(JSContextRef context,
116 * extracts Api Message representation
117 * throws WrtDeviceApis::Commons::NullPointerException if there's no private object
119 static Api::Messaging::IAttachmentPtr getAttachment(JSContextRef context,
123 * This structure describes a statically declared function property.
125 static JSStaticFunction m_function[];
128 * This structure contains properties and callbacks that define a type of object.
130 static JSClassDefinition m_classInfo;
133 * This member variable contains the initialization values for the static properties of this class.
134 * The values are given according to the data structure JSPropertySpec
136 static JSStaticValue m_property[];
143 #endif //WRT_PLUGINS_TIZEN_JS_MESSAGE_ATTACHMENT_H_