2 * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 MessageMenager.h
18 * @author Yunchan Cho (yunchan.cho@samsung.com)
25 #include <Core/Util/Log.h>
26 #include "MessageManager.h"
30 static const std::string jsFireWindowEventFunction("webprovider.fireAppWidgetEvent");
31 static const std::string jsPdMessageEvent("pdmessage");
32 static const std::string jsBoxMessageEvent("boxmessage");
34 MessageManager::MessageManager()
39 MessageManager::~MessageManager()
44 bool MessageManager::send(Evas_Object* webview, ReceiverType receiver, std::string& message)
48 std::string eventName;
52 // set message event name triggered by receiver
55 eventName = jsPdMessageEvent;
58 eventName = jsBoxMessageEvent;
64 std::string script = jsFireWindowEventFunction;
70 LogD("calling javascript: %s", script.c_str());
72 // execute js code for sending message
73 if (EINA_FALSE == ewk_view_script_execute(
74 webview, script.c_str(), executeScriptCallback, this)) {
75 LogD("ewk_view_script_execute fail.");
81 void MessageManager::executeScriptCallback(
82 Evas_Object* webview, const char* result, void* data)
85 std::string resultStr(result ? result : "null");
86 LogD("result: %s", resultStr.c_str());