Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Messaging / JSMessageAttachment.h
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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. 
15 */
16
17
18 /**
19  *
20  *
21  * @file       JSMessage.h
22  * @author     Pawel Misiak (p.misiak@samsung.com)
23  * @version    0.1
24  * @brief
25  */
26
27 #ifndef WRT_PLUGINS_TIZEN_JS_MESSAGE_ATTACHMENT_H_
28 #define WRT_PLUGINS_TIZEN_JS_MESSAGE_ATTACHMENT_H_
29
30 #include <JavaScriptCore/JavaScript.h>
31 #include <CommonsJavaScript/PrivateObject.h>
32 #include <API/Messaging/IMessagingService.h>
33 #include <API/Messaging/IMessage.h>
34
35 namespace TizenApis {
36 namespace Tizen1_0 {
37
38 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Messaging::IAttachmentPtr>::Type JSMessageAttachmentPrivate;      //IAttachmentPtr
39         
40 class JSMessageAttachment
41 {
42         static JSClassRef m_jsClassRef;
43         
44 public:
45         static const JSClassDefinition* getClassInfo();
46         static JSClassRef getClassRef();
47         static JSObjectRef createJS( JSContextRef context, const Api::Messaging::IAttachmentPtr &msg);
48
49 private:
50         
51     /**
52      * The callback invoked when an object is first created.
53      */
54     static void initialize(JSContextRef context,
55             JSObjectRef object);
56
57     /**
58      * The callback invoked when an object is finalized.
59      */
60     static void finalize(JSObjectRef object);
61
62     static bool hasProperty(JSContextRef context,
63             JSObjectRef object,
64             JSStringRef propertyName);
65
66     static JSObjectRef constructor(JSContextRef ctx, 
67                         JSObjectRef constructor, 
68                         size_t argumentCount, 
69                         const JSValueRef arguments[], 
70                         JSValueRef* exception);
71
72     /**
73      * Get MIME Type of Attachment File.  readonly
74      */
75     static JSValueRef getMIMEType(JSContextRef context,
76                 JSObjectRef object,
77                 JSStringRef propertyName,
78                 JSValueRef* exception);
79
80     
81     static JSValueRef getMessageID(JSContextRef context,
82                 JSObjectRef object,
83                 JSStringRef propertyName,
84                 JSValueRef* exception);
85
86     static JSValueRef getContentLocation(JSContextRef context,
87                 JSObjectRef object,
88                 JSStringRef propertyName,
89                 JSValueRef* exception);
90
91     static JSValueRef getContentID(JSContextRef context,
92                 JSObjectRef object,
93                 JSStringRef propertyName,
94                 JSValueRef* exception);
95
96         
97     static JSValueRef getLoaded(JSContextRef context,
98                 JSObjectRef object,
99                 JSStringRef propertyName,
100                 JSValueRef* exception);
101         
102    static JSValueRef getFile(JSContextRef context,
103                 JSObjectRef object,
104                 JSStringRef propertyName,
105                 JSValueRef* exception);
106         
107     /*
108      * returns private object or throws WrtDeviceApis::Commons::NullPointerException
109      */
110     static JSMessageAttachmentPrivate* getPrivate(JSObjectRef value);
111
112         /*
113          * extracts Api Message representation
114          * throws WrtDeviceApis::Commons::NullPointerException if there's no private object
115          * throws WrtDeviceApis::Commons::ConversionException if it's not possible to convert to JSObjectRef
116          */
117         static Api::Messaging::IAttachmentPtr getAttachment(JSContextRef context,
118                         JSValueRef value);
119
120         /*
121          * extracts Api Message representation
122          * throws WrtDeviceApis::Commons::NullPointerException if there's no private object
123          */
124         static Api::Messaging::IAttachmentPtr getAttachment(JSContextRef context,
125                         JSObjectRef object);
126
127         /**
128         * This structure describes a statically declared function property.
129         */
130         static JSStaticFunction m_function[];
131
132         /**
133         * This structure contains properties and callbacks that define a type of object.
134         */
135         static JSClassDefinition m_classInfo;
136
137         /**
138         * This member variable contains the initialization values for the static properties of this class.
139         * The values are given according to the data structure JSPropertySpec
140         */
141         static JSStaticValue m_property[];
142   
143 };
144         
145 }
146 }
147
148 #endif //WRT_PLUGINS_TIZEN_JS_MESSAGE_ATTACHMENT_H_
149