wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / Messaging / ConverterMessage.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #include <CommonsJavaScript/Converter.h>
19 #include "IMessagingTypes.h"
20 #include "MessageFactory.h"
21 #include "Recipient.h"
22 #include "IMessage.h"
23 #include "EventUpdateMessage.h"
24 #include "IConversation.h"
25
26 #include "MessageSendCallback.h"
27 #include "MessagingStorageMultiCallback.h"
28
29 #if 0 // MESSAGING ATTACHMENT IS BLOCKED
30 #include <API/Messaging/IMessageFolder.h>
31 #include <API/Filesystem/INodeTypes.h>
32 #endif
33
34 #ifndef CONVERTEDMESSAGE_H
35 #define CONVERTEDMESSAGE_H
36
37 namespace DeviceAPI {
38 namespace Messaging {
39 class ConverterMessage : public WrtDeviceApis::CommonsJavaScript::Converter
40 {
41   private:
42     enum messageTypes
43     {
44         messageTypeSms = 1,
45         messageTypeMms = 2,
46         messageTypeEmail = 3
47     };
48
49     enum messageFolders
50     {
51         messageFolderInbox = 1,
52         messageFolderOutbox = 2,
53         messageFolderDrafts = 3,
54         messageFolderSentbox = 4
55     };
56     static MessageFunctions m_callbackNames[MESSAGING_MULTI_FUNTION_MAX];
57
58
59   public:
60     using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef;
61
62     explicit ConverterMessage(JSContextRef context);
63
64     virtual ~ConverterMessage();
65
66     OnMessagesChanged toMessageMultifunctions(JSValueRef argument, int MessageFunctionNum);
67
68     JSContextRef toJSGlobalContext(JSObjectRef arg);
69
70     JSValueRef toJSValueRef(FolderType arg);
71
72     JSValueRef toJSValueRef(const std::vector<IMmsSlidePtr>& slides);
73
74     JSValueRef toJSValueRef(MessageType arg);
75
76     JSValueRef toJSValueRef(const IMessagePtr& arg);
77
78     JSValueRef toJSValueRef(const IMessagePtr& arg,
79             EventUpdateMessageAnswerReceiver* listener);
80
81     JSValueRef toJSValueRef(const std::vector<IMessagePtr>& arg,
82             EventUpdateMessageAnswerReceiver* listener);
83     JSValueRef toJSValueRef(const std::vector<IConversationPtr>& conversations);
84     JSValueRef toJSValueRef(const std::vector<IMessageFolderPtr>& messagefolders);
85         
86     IConversationPtr toConversation(const JSValueRef& arg);
87     std::vector<IConversationPtr> toVectorOfConversation(const JSValueRef& arg);
88
89     JSValueRef toJSValueRef(const MessagePriority& arg);
90
91     JSValueRef toJSValueRef(const IAttachmentPtr& arg);
92
93     JSValueRef keyToJSValue(JSValueRef value,
94             const std::string& key);
95
96     IMessagePtr toIMessage(JSValueRef arg);
97
98     IMessagePtr toIMessage(JSObjectRef arg);
99
100     IAttachmentPtr toIAttachment(JSValueRef arg);
101
102     IAttachmentPtr toIAttachment(JSObjectRef arg);
103         
104     Recipients toRecipients(JSValueRef arg);
105
106     std::vector<FolderType> toVectorOfFolderTypes(JSValueRef arg);
107
108     FolderType toFolderType(const JSValueRef& arg);
109
110     IMessageFolderPtr toIMessageFolder(JSValueRef arg);
111
112     IMessageFolderPtr toIMessageFolder(JSObjectRef arg);
113
114     MessageType toMessageType(JSValueRef arg);
115
116     MessageType toMessageType(JSObjectRef arg);
117
118     std::string toMessageType( long msgtype );
119
120     MessageType toMessageType(std::string arg);
121
122     std::string toMessageStatusType( long msgstatus );
123
124     std::string convertIntToString( int msgInt );
125
126     AddressType toAddressType(JSValueRef arg);
127
128     MessagePriority::Priority toMessagePriority(JSValueRef arg);
129
130 #if 0 // MESSAGING ATTACHMENT IS BLOCKED
131     DeviceAPI::Filesystem::INodePtr toFilesystemNode(JSValueRef arg);
132 #endif
133  
134
135     /**
136      * @throw InvalidArgumentException If not a callback nor JS null.
137      */
138     JSValueRef toFunctionOrNull(const JSValueRef& arg);
139
140     /**
141      * @throw ConversionException If JS null.
142      * @throw InvalidArgumentException If not a callback nor JS null.
143      */
144     JSValueRef toFunction(const JSValueRef& arg);
145
146     MessageSendCallback toMessageSendCallback(const JSValueRef& arg);
147 };
148
149 typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<ConverterMessage> ConverterMessageFactory;
150 }
151 }
152
153 #endif