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)
24 #include <Core/Util/Log.h>
25 #include "MessageManager.h"
29 static const std::string jsFireWindowEventFunction("webprovider.fireAppWidgetEvent");
30 static const std::string jsPdMessageEvent("pdmessage");
31 static const std::string jsBoxMessageEvent("boxmessage");
33 MessageManager::MessageManager()
38 MessageManager::~MessageManager()
43 bool MessageManager::send(Evas_Object* webview, ReceiverType receiver, std::string& message)
47 std::string eventName;
49 // set message event name triggered by receiver
52 eventName = jsPdMessageEvent;
55 eventName = jsBoxMessageEvent;
61 std::string script = jsFireWindowEventFunction;
67 LogD("calling javascript: %s", script.c_str());
69 // execute js code for sending message
70 ewk_view_script_execute(webview, script.c_str(), executeScriptCallback, this);
75 void MessageManager::executeScriptCallback(
76 Evas_Object* webview, const char* result, void* data)
79 std::string resultStr(result ? result : "null");
80 LogD("result: %s", resultStr.c_str());