Update change log and spec for wrt-plugins-tizen_0.4.44
[platform/framework/web/wrt-plugins-tizen.git] / src / Systeminfo / SysteminfoListener.cpp
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #include <CommonsJavaScript/JSCallbackManager.h>
19 #include "SysteminfoListener.h"
20 #include <CommonsJavaScript/ScopedJSStringRef.h>
21 #include "SysteminfoAsyncCallbackManager.h"
22 #include <TimeTracer.h>
23 #include <Logger.h>
24
25 using namespace std;
26
27 namespace DeviceAPI {
28 namespace Systeminfo {
29
30 SysteminfoListener& SysteminfoListener::getInstance()
31 {
32     static SysteminfoListener instance;
33     return instance;
34 }
35
36 SysteminfoListener::SysteminfoListener() : 
37     EventGetSysteminfoAnswerReceiver(WrtDeviceApis::Commons::ThreadEnum::SYSTEMINFO_THREAD), 
38     EventWatchSysteminfoAnswerReceiver(WrtDeviceApis::Commons::ThreadEnum::SYSTEMINFO_THREAD)
39 {
40 }
41
42 SysteminfoListener::~SysteminfoListener()
43 {
44 }
45
46 void SysteminfoListener::OnAnswerReceived(const EventGetSysteminfoPtr& event)
47 {
48     LoggerD("Enter");
49     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<WrtDeviceApis::CommonsJavaScript::JSCallbackManager >(event->getPrivateData());
50     LoggerD("thread=" << DPL::Thread::GetCurrentThread());
51
52     SysteminfoAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager); 
53
54     if (!event->checkCancelled()) {
55         JSValueRef tmpValue = event->getValue();
56         if ((WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) && (NULL != tmpValue)) {
57             callbackManager->callOnSuccess(tmpValue);
58                         TIME_TRACER_ITEM_END(event->getProperty(), 0);
59         }
60     }
61 }    
62
63 void SysteminfoListener::OnAnswerReceived(const EventWatchSysteminfoPtr& event)
64 {
65 }
66
67 }
68 }