484d664742a73c4bf11190768e250775b9a57083
[platform/framework/web/wrt-plugins-common.git] / src / modules / tizen / DEPRACATED / FeatureLoader / FeatureManager.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /*
17  * @author Bartlomiej Grzelewski
18  */
19
20 #include <dpl/log/log.h>
21 #include <commons/JSCallbackManager.h>
22 #include <vector>
23 #include "FeatureManager.h"
24
25 using namespace WrtPlugins::Api;
26
27 namespace WrtPlugins {
28 namespace Platform {
29 //static void wrtPlatformCallback(int widgetHandler, JSObjectRef object, void*
30 // userParam)
31 //{
32 //    FeatureManager::platformCallback(widgetHandler,
33 // static_cast<void*>(object), userParam);
34 //}
35
36 void FeatureManager::OnRequestReceived(const Api::EventLoadFeaturePtr &event)
37 {
38     //TODO commented
39     //EventWrapper *eventWrapper = new EventWrapper(this, event);
40     LogDebug("Call for dynamic feature: " << event->getFeature().c_str());
41     JSCallbackManagerPtr jsCallbackManager =
42         DPL::StaticPointerCast<JSCallbackManager,
43                                Platform::IEventPrivateData>(
44             event->getPrivateData());
45     /* TODO uncomment - this function _will_ be available in new wrt-engine API
46     **/
47     LogError("*** CRITICAL wrt_dynamic_feature_request is disable!");
48     //    wrt_dynamic_feature_request(jsCallbackManager->getContext(),
49     // event->getFeature().c_str(), wrtPlatformCallback, eventWrapper);
50 }
51
52 void FeatureManager::platformCallback(int,
53                                       void* object,
54                                       void* userParam)
55 {
56     if (object == NULL) {
57         LogError("Request has been rejected.");
58     } else {
59         LogDebug("Request has been approved.");
60     }
61     EventWrapper *eventWrapper = static_cast<EventWrapper*>(userParam);
62     eventWrapper->m_event->setObject(object);
63     eventWrapper->m_event->setStatus((object == 0) ? false : true);
64     eventWrapper->m_featureManager->Platform::EventRequestReceiver<
65         EventLoadFeature>::ManualAnswer(eventWrapper->m_event);
66     delete eventWrapper;
67 }
68 } // namespace Platform
69 } // namespace WrtPlugins