42cca023eeeac3966a7a5b94a044b2ed2983ee07
[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
67     /**
68      * Get MIME Type of Attachment File.  readonly
69      */
70     static JSValueRef getMIMEType(JSContextRef context,
71                 JSObjectRef object,
72                 JSStringRef propertyName,
73                 JSValueRef* exception);
74
75     
76     static JSValueRef getMessageID(JSContextRef context,
77                 JSObjectRef object,
78                 JSStringRef propertyName,
79                 JSValueRef* exception);
80
81     static JSValueRef getContentLocation(JSContextRef context,
82                 JSObjectRef object,
83                 JSStringRef propertyName,
84                 JSValueRef* exception);
85
86     static JSValueRef getContentID(JSContextRef context,
87                 JSObjectRef object,
88                 JSStringRef propertyName,
89                 JSValueRef* exception);
90
91         
92     static JSValueRef getLoaded(JSContextRef context,
93                 JSObjectRef object,
94                 JSStringRef propertyName,
95                 JSValueRef* exception);
96         
97    static JSValueRef getFile(JSContextRef context,
98                 JSObjectRef object,
99                 JSStringRef propertyName,
100                 JSValueRef* exception);
101         
102     /*
103      * returns private object or throws WrtDeviceApis::Commons::NullPointerException
104      */
105     static JSMessageAttachmentPrivate* getPrivate(JSObjectRef value);
106
107         /*
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
111          */
112         static Api::Messaging::IAttachmentPtr getAttachment(JSContextRef context,
113                         JSValueRef value);
114
115         /*
116          * extracts Api Message representation
117          * throws WrtDeviceApis::Commons::NullPointerException if there's no private object
118          */
119         static Api::Messaging::IAttachmentPtr getAttachment(JSContextRef context,
120                         JSObjectRef object);
121
122         /**
123         * This structure describes a statically declared function property.
124         */
125         static JSStaticFunction m_function[];
126
127         /**
128         * This structure contains properties and callbacks that define a type of object.
129         */
130         static JSClassDefinition m_classInfo;
131
132         /**
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
135         */
136         static JSStaticValue m_property[];
137   
138 };
139         
140 }
141 }
142
143 #endif //WRT_PLUGINS_TIZEN_JS_MESSAGE_ATTACHMENT_H_
144