summaryrefslogtreecommitdiff
path: root/src/standards/Tizen/Messaging/ConverterMessage.h
blob: e4b3e1973854950ef5ce9c5c19cef5b3be2dd4db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. 
*/


/**
 *
 *
 * @file
 * @author     Pawel Misiak (p.misiak@samsung.com)
 * @author     Grzegorz Krawczyk (g.krawczyk@samsung.com)
 * @version    0.1
 * @brief
 */
#include <dpl/log/log.h>
#include <CommonsJavaScript/Converter.h>
#include <API/Messaging/IMessagingTypes.h>
#include <API/Messaging/MessageFactory.h>
#include <API/Messaging/Recipient.h>
#include <API/Messaging/IMessage.h>
#include <API/Messaging/EventUpdateMessage.h>
#include <API/Messaging/IConversation.h>

#include "MessageSendCallback.h"
#include "MessagingStorageMultiCallback.h"

#if 0 // MESSAGING ATTACHMENT IS BLOCKED
#include <API/Messaging/IMessageFolder.h>
#include <API/Filesystem/INodeTypes.h>
#endif

#ifndef CONVERTEDMESSAGE_H
#define CONVERTEDMESSAGE_H

namespace TizenApis {
namespace Tizen1_0 {
class ConverterMessage : public WrtDeviceApis::CommonsJavaScript::Converter
{
  private:
    enum messageTypes
    {
        messageTypeSms = 1,
        messageTypeMms = 2,
        messageTypeEmail = 3
    };

    enum messageFolders
    {
        messageFolderInbox = 1,
        messageFolderOutbox = 2,
        messageFolderDrafts = 3,
        messageFolderSentbox = 4
    };
    static MessageFunctions m_callbackNames[MESSAGING_MULTI_FUNTION_MAX];


  public:
    using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef;

    explicit ConverterMessage(JSContextRef context);

    virtual ~ConverterMessage();

    OnMessagesChanged toMessageMultifunctions(JSValueRef argument);

    JSContextRef toJSGlobalContext(JSObjectRef arg);

    JSValueRef toJSValueRef(Api::Messaging::FolderType arg);

    JSValueRef toJSValueRef(const std::vector<Api::Messaging::IMmsSlidePtr>& slides);

    JSValueRef toJSValueRef(Api::Messaging::MessageType arg);

    JSValueRef toJSValueRef(const Api::Messaging::IMessagePtr& arg,
            Api::Messaging::EventUpdateMessageAnswerReceiver* listener);

    JSValueRef toJSValueRef(const std::vector<Api::Messaging::IMessagePtr>& arg,
            Api::Messaging::EventUpdateMessageAnswerReceiver* listener);
    JSValueRef toJSValueRef(const std::vector<Api::Messaging::IConversationPtr>& conversations);
    JSValueRef toJSValueRef(const std::vector<Api::Messaging::IMessageFolderPtr>& messagefolders);
	
    Api::Messaging::IConversationPtr toConversation(const JSValueRef& arg);
    std::vector<Api::Messaging::IConversationPtr> toVectorOfConversation(const JSValueRef& arg);

    JSValueRef toJSValueRef(const Api::Messaging::MessagePriority& arg);

    JSValueRef keyToJSValue(JSValueRef value,
            const std::string& key);

    Api::Messaging::IMessagePtr toIMessage(JSValueRef arg);

    Api::Messaging::IMessagePtr toIMessage(JSObjectRef arg);

    Api::Messaging::IAttachmentPtr toIAttachment(JSValueRef arg);

    Api::Messaging::IAttachmentPtr toIAttachment(JSObjectRef arg);
	
    Api::Messaging::Recipients toRecipients(JSValueRef arg);

    std::vector<Api::Messaging::FolderType> toVectorOfFolderTypes(JSValueRef arg);

    Api::Messaging::FolderType toFolderType(const JSValueRef& arg);

    Api::Messaging::IMessageFolderPtr toIMessageFolder(JSValueRef arg);

    Api::Messaging::IMessageFolderPtr toIMessageFolder(JSObjectRef arg);

    Api::Messaging::MessageType toMessageType(JSValueRef arg);

    Api::Messaging::MessageType toMessageType(JSObjectRef arg);

    std::string toMessageType( long msgtype );

    std::string toMessageStatusType( long msgstatus );

    Api::Messaging::AddressType toAddressType(JSValueRef arg);

    Api::Messaging::MessagePriority::Priority toMessagePriority(JSValueRef arg);

#if 0 // MESSAGING ATTACHMENT IS BLOCKED
    Api::Filesystem::INodePtr toFilesystemNode(JSValueRef arg);
#endif
 

    /**
     * @throw InvalidArgumentException If not a callback nor JS null.
     */
    JSValueRef toFunctionOrNull(const JSValueRef& arg);

    /**
     * @throw ConversionException If JS null.
     * @throw InvalidArgumentException If not a callback nor JS null.
     */
    JSValueRef toFunction(const JSValueRef& arg);

    MessageSendCallback toMessageSendCallback(const JSValueRef& arg);
};

typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<ConverterMessage> ConverterMessageFactory;
}
}

#endif