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.
17 * @file view_logic_message_support.cpp
18 * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
19 * @author Yunchan Cho (yunchan.cho@samsung.com)
20 * @brief View logic message support - implementation
22 #include "view_logic_message_support.h"
26 #include <common/message_support.h>
27 #include <js_overlay_types.h>
29 namespace ViewLogicMessageSupport {
30 void init(Ewk_Context* ewkContext, const std::string& tizenId)
32 const char* name = Message::ToInjectedBundle::INIT;
33 const char* msg = tizenId.c_str();
35 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
38 void start(Ewk_Context* ewkContext,
39 const DPL::String& tizenId,
41 const char *encodedBundle,
44 std::stringstream ssMsg;
46 std::string id = DPL::ToUTF8String(tizenId);
49 ssMsg << "_" << scale << " ";
52 ssMsg << "_" << encodedBundle << " ";
54 ssMsg << "null" << " ";
58 ssMsg << "_" << theme;
63 std::string msgString = ssMsg.str();
65 const char* msg = msgString.c_str();
66 const char* name = Message::ToInjectedBundle::START;
68 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
71 void shutdown(Ewk_Context* ewkContext)
73 const char* name = Message::ToInjectedBundle::SHUTDOWN;
74 ewk_context_message_post_to_injected_bundle(ewkContext, name, name);
77 void setCustomProperties(
78 Ewk_Context* ewkContext,
80 const char* encodedBundle,
83 std::stringstream ssMsg;
86 ssMsg << "_" << *scale << " ";
88 ssMsg << "null" << " ";
92 ssMsg << "_" << encodedBundle << " ";
94 ssMsg << "null" << " ";
98 ssMsg << "_" << theme;
103 std::string msgString = ssMsg.str();
105 const char* msg = msgString.c_str();
106 const char* name = Message::ToInjectedBundle::SET_CUSTOM_PROPERTIES;
108 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
111 void dispatchJavaScriptEvent(
112 Ewk_Context* ewkContext,
113 WrtPlugins::W3C::CustomEventType eventType,
116 using namespace WrtPlugins::W3C;
117 std::stringstream str;
120 // if needed, arguments for event should be set here
121 if (eventType == SoftKeyboardChangeCustomEvent) {
123 SoftKeyboardChangeArgs* args =
124 static_cast<SoftKeyboardChangeArgs *>(data);
125 str << " " << args->state;
126 str << " " << args->width;
127 str << " " << args->height;
131 std::string msgString = str.str();
132 const char* msg = msgString.c_str();
133 const char* name = Message::ToInjectedBundle::DISPATCH_JS_EVENT;
135 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
138 void setXwindowHandle(Ewk_Context* ewkContext, const unsigned int handle)
140 const char* name = Message::ToInjectedBundle::SET_XWINDOW_HANDLE;
141 std::stringstream ssMsg;
143 std::string msgString = ssMsg.str();
144 const char* msg = msgString.c_str();
146 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
148 } // namespace ViewLogicMessageSupport