tizen beta release
[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* userParam)
30 //{
31 //    FeatureManager::platformCallback(widgetHandler, static_cast<void*>(object), userParam);
32 //}
33
34 void FeatureManager::OnRequestReceived(const Api::EventLoadFeaturePtr &event)
35 {
36     //TODO commented
37     //EventWrapper *eventWrapper = new EventWrapper(this, event);
38     LogDebug("Call for dynamic feature: " << event->getFeature().c_str());
39     JSCallbackManagerPtr jsCallbackManager =
40         DPL::StaticPointerCast<JSCallbackManager,
41                                Platform::IEventPrivateData>(
42             event->getPrivateData());
43     /* TODO uncomment - this function _will_ be available in new wrt-engine API */
44     LogError("*** CRITICAL wrt_dynamic_feature_request is disable!");
45     //    wrt_dynamic_feature_request(jsCallbackManager->getContext(), event->getFeature().c_str(), wrtPlatformCallback, eventWrapper);
46 }
47
48 void FeatureManager::platformCallback(int,
49         void* object,
50         void* userParam)
51 {
52     if (object == NULL) {
53         LogError("Request has been rejected.");
54     } else {
55         LogDebug("Request has been approved.");
56     }
57     EventWrapper *eventWrapper = static_cast<EventWrapper*>(userParam);
58     eventWrapper->m_event->setObject(object);
59     eventWrapper->m_event->setStatus((object == 0) ? false : true);
60     eventWrapper->m_featureManager->Platform::EventRequestReceiver<
61         EventLoadFeature>::ManualAnswer(eventWrapper->m_event);
62     delete eventWrapper;
63 }
64 } // namespace Platform
65 } // namespace WrtPlugins