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 <EWebKit_internal.h>
27 #include <message_support.h>
28 #include <js_overlay_types.h>
30 namespace ViewLogicMessageSupport {
31 void init(Ewk_Context* ewkContext, const std::string& tizenId)
33 const char* name = Message::ToInjectedBundle::INIT;
34 const char* msg = tizenId.c_str();
36 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
39 void start(Ewk_Context* ewkContext,
40 const DPL::String& tizenId,
42 const char *encodedBundle,
45 std::stringstream ssMsg;
47 std::string id = DPL::ToUTF8String(tizenId);
50 ssMsg << "_" << scale << " ";
53 ssMsg << "_" << encodedBundle << " ";
55 ssMsg << "null" << " ";
59 ssMsg << "_" << theme;
64 std::string msgString = ssMsg.str();
66 const char* msg = msgString.c_str();
67 const char* name = Message::ToInjectedBundle::START;
69 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
72 void shutdown(Ewk_Context* ewkContext)
74 const char* name = Message::ToInjectedBundle::SHUTDOWN;
75 ewk_context_message_post_to_injected_bundle(ewkContext, name, name);
78 void setCustomProperties(
79 Ewk_Context* ewkContext,
81 const char* encodedBundle,
84 std::stringstream ssMsg;
87 ssMsg << "_" << *scale << " ";
89 ssMsg << "null" << " ";
93 ssMsg << "_" << encodedBundle << " ";
95 ssMsg << "null" << " ";
99 ssMsg << "_" << theme;
104 std::string msgString = ssMsg.str();
106 const char* msg = msgString.c_str();
107 const char* name = Message::ToInjectedBundle::SET_CUSTOM_PROPERTIES;
109 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
112 void dispatchJavaScriptEvent(
113 Ewk_Context* ewkContext,
114 WrtPlugins::W3C::CustomEventType eventType,
117 using namespace WrtPlugins::W3C;
118 std::stringstream str;
121 // if needed, arguments for event should be set here
122 if (eventType == SoftKeyboardChangeCustomEvent) {
124 SoftKeyboardChangeArgs* args =
125 static_cast<SoftKeyboardChangeArgs *>(data);
126 str << " " << args->state;
127 str << " " << args->width;
128 str << " " << args->height;
132 std::string msgString = str.str();
133 const char* msg = msgString.c_str();
134 const char* name = Message::ToInjectedBundle::DISPATCH_JS_EVENT;
136 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
139 void setXwindowHandle(Ewk_Context* ewkContext, const unsigned int handle)
141 const char* name = Message::ToInjectedBundle::SET_XWINDOW_HANDLE;
142 std::stringstream ssMsg;
144 std::string msgString = ssMsg.str();
145 const char* msg = msgString.c_str();
147 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
150 void setViewmodes(Ewk_Context* ewkContext, const char* msg)
152 const char* name = Message::ToInjectedBundle::SET_VIEWMODES;
153 ewk_context_message_post_to_injected_bundle(ewkContext, name, msg);
155 } // namespace ViewLogicMessageSupport