2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FApp_AppImpl.cpp
19 * @brief This is the implementation for the _AppImpl class.
22 #include <unique_ptr.h>
24 #include <notification/notification.h>
25 #include <appsvc/appsvc.h>
29 #include <FBaseInteger.h>
30 #include <FBaseColArrayList.h>
31 #include <FBaseColHashMap.h>
32 #include <FBaseRtThread.h>
33 #include <FAppAppRegistry.h>
34 #include <FAppAppControl.h>
35 #include <FAppDataControlProviderManager.h>
36 #include <FAppIAppCheckPointEventListener.h>
37 #include <FAppISqlDataControlProviderEventListener.h>
38 #include <FAppIMapDataControlProviderEventListener.h>
39 #include <FAppIAppControlProviderEventListener.h>
40 #include <FAppIAppLaunchConditionEventListener.h>
42 #include <FBaseSysLog.h>
44 #include <FBase_StringConverter.h>
45 #include <FIo_RegistryImpl.h>
46 #include <FSys_EnvironmentImpl.h>
47 #include <FSys_PowerManagerImpl.h>
49 #include <FSys_AlarmManager.h>
51 #include "FApp_IAppManager.h"
52 #include "FApp_AppManagerProxy.h"
53 #include "FApp_AppImpl.h"
54 #include "FApp_AppInfo.h"
55 #include "FApp_AppControlManager.h"
56 #include "FApp_AppArg.h"
57 #include "FApp_IAppImpl.h"
58 #include "FApp_AppResourceImpl.h"
59 #include <FSys_SettingInfoImpl.h>
61 using namespace Tizen::Base;
62 using namespace Tizen::Base::Collection;
63 using namespace Tizen::Base::Runtime;
64 using namespace Tizen::Io;
65 using namespace Tizen::System;
70 const int HEARTBEAT_WAIT_COUNT = 3;
71 const wchar_t SERVICE_APPID[] = L"aospd00043.osp-app-service";
72 const char SELECTOR_RESPONSE_KEY[] = "__APP_SVC_START_INFO__";
73 const wchar_t FILE_SCHEME_WITH_DELIMITER[] = L"file://";
74 #ifndef VCONFKEY_APPSERVICE_STATUS
75 #define VCONFKEY_APPSERVICE_STATUS "memory/appservice/status"
80 namespace Tizen { namespace App
83 _AppImpl* _AppImpl::__pAppImpl = null;
84 bool _AppImpl::__isTerminationRequested = false;
86 static const char TIZEN_APPCONTROL_DATA_MULTI_WINDOW[] = "http://tizen.org/appcontrol/data/multiwindow";
89 static const int _DATACONTROL_PACKET_INDEX_APPID = 0;
90 static const int _DATACONTROL_PACKET_INDEX_REQUESTTYPE = 1;
91 static const int _DATACONTROL_PACKET_INDEX_REQID = 2;
92 static const int _DATACONTROL_PACKET_INDEX_PROVIDERID = 3;
94 static const int _DATACONTROL_PACKET_INDEX_DATAID = 0;
95 static const int _DATACONTROL_PACKET_INDEX_COLUMNCOUNT = 1;
96 static const int _DATACONTROL_PACKET_INDEX_DELETEWHERE = 1;
97 static const int _DATACONTROL_PACKET_INDEX_MAPKEY = 1;
98 static const int _DATACONTROL_PACKET_INDEX_COLUMNLIST = 2;
99 static const int _DATACONTROL_PACKET_INDEX_INSERTMAP = 2;
100 static const int _DATACONTROL_PACKET_INDEX_UPDATEMAP = 2;
104 void operator()(char* pValue)
114 _AppImpl::_AppImpl(App* pApp)
115 : __pCheckpointEventListener(null)
116 , __pSqlDataControlProviderEventListener(null)
117 , __pMapDataControlProviderEventListener(null)
118 , __pAppControlProviderEventListener(null)
119 , __pAppControlProviderInternalEventListener(null)
120 , __pAppLaunchConditionEventListener(null)
123 , __pRequestHandler(&_AppImpl::HandleAppRequest)
124 , __pLegacyRequestHandler(&_AppImpl::HandleDummyAppRequest)
125 , __forcedTermination(false)
132 _AppImpl::Construct(const IList* pArgs)
134 SysTryReturnResult(NID_APP, pArgs != null, E_INVALID_ARG, "pArguments must not be null.");
135 SysAssertf(__pApp != null, "Getting App instance failed.");
137 result r = __appUserEvent.Construct();
138 SysTryLog(NID_APP, !IsFailed(r), "[%s] User event handler failure.", GetErrorMessage(r));
140 __appUserEvent.AddListener(*this);
142 _AppInfo::SetAppState(INITIALIZING);
144 r = _SettingInfoImpl::AddSettingEventListenerForInternal(*this);
145 SysTryLog(NID_APP, !IsFailed(r), "[%s] failed to add setting event listener.", GetErrorMessage(r));
151 _AppImpl::Execute(_IAppImpl* pIAppImpl)
153 SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:start]", _AppInfo::GetAppExecutableName().GetPointer());
154 result r = E_SUCCESS;
155 int eflResult = APP_ERROR_NONE;
158 _IAppManager* pAppManager = null;
160 _AppImpl* pAppImpl = _AppImpl::GetInstance();
161 SysTryReturnResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
162 pAppImpl->__pIAppImpl = pIAppImpl;
164 // handle legacy version handling
165 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
167 pAppImpl->SetLegacyRequestHandler();
170 app_event_callback_s state_handler;
171 memset(&state_handler, 0, sizeof(app_event_callback_s));
173 state_handler.create = &OnCreate;
174 state_handler.service = &OnService;
175 state_handler.terminate = &OnTerminate;
176 state_handler.pause = &OnPause;
177 state_handler.resume = &OnResume;
178 state_handler.device_orientation = NULL;
180 state_handler.low_memory = &OnLowMemory;
181 state_handler.low_battery = NULL;
182 state_handler.language_changed = NULL;
183 state_handler.region_format_changed = NULL;
185 _Aul::SetPowerOffNotiListener(OnPowerOffNotiReceived, this);
186 // if (pAppManager != null)
188 // r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), _AppInfo::GetAppType() , _AppInfo::GetProcessId());
189 // SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Application registration failed.", GetErrorMessage(r));
192 appinfo_get_argv(&argc, &pArgv);
193 eflResult = app_efl_main(&argc, &pArgv, &state_handler, this);
194 SysTryLog(NID_APP, eflResult == APP_ERROR_NONE, "app_efl_main failed with error (%d): Unknown", eflResult);
196 pAppManager = _AppManagerProxy::GetService();
198 if (pAppManager != null)
200 pAppManager->UnregisterApplication(_AppInfo::GetProcessId());
203 // clear outstanding ongoing notification
204 notification_delete_all_by_type(appinfo_get_appid(), NOTIFICATION_TYPE_ONGOING);
211 _AppImpl::OnCreate(void* user_data)
213 SysLog(NID_APP, "Platform creation event.");
215 _AppImpl* pAppImpl = static_cast<_AppImpl*>(user_data);
216 if (pAppImpl == null)
218 _AppInfo::SetAppState(TERMINATED);
219 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Invalid platform state.");
223 _AppInfo::SetAppState(INITIALIZING);
225 if (!ConfirmAppService())
227 _AppInfo::SetAppState(TERMINATED);
228 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Osp AppService is not running.");
232 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:start]", _AppInfo::GetAppExecutableName().GetPointer());
233 if (!pAppImpl->__pIAppImpl->OnAppInitializing())
235 _AppInfo::SetAppState(TERMINATED);
236 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] The initialization of your application failed.");
239 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:done]", _AppInfo::GetAppExecutableName().GetPointer());
241 SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:start]", _AppInfo::GetAppExecutableName().GetPointer());
242 _IAppManager* pAppManager = _AppManagerProxy::GetService();
244 if (pAppManager != null)
246 result r = pAppManager->RegisterApplication(_AppInfo::GetApplicationId(), static_cast<_AppType>(_AppInfo::GetAppType()), _AppInfo::GetProcessId());
247 SysTryLog(NID_APP, !IsFailed(r), "[%s] Application registration failed.", GetErrorMessage(r));
249 SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:done]", _AppInfo::GetAppExecutableName().GetPointer());
250 // hide splash window
252 _PowerManagerImpl::InitBatteryEvent();
259 _AppImpl::OnService(service_s* service, void* user_data)
261 _AppImpl* pAppImpl = _AppImpl::GetInstance();
262 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
263 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
265 // ugly code for app selector event handling
266 bundle* pBundle = _AppArg::GetBundleFromSvc(service);
269 const char* pValue = appsvc_get_data(pBundle, SELECTOR_RESPONSE_KEY);
272 const int req = _AppArg::GetRequestIdFromBundle(pBundle);
274 const char* pOperation = appsvc_get_operation(pBundle);
276 SysLog(NID_APP, "App selector response [%s, %s], req(%d).", pValue, pOperation, req);
278 //_AppArg::Print(pBundle);
279 _AppControlManager::GetInstance()->SendAppControlStartResponse(req, pValue, pOperation);
284 //_AppArg::Print(pBundle);
286 _AppHandler handler = _APP_HANDLER_NONE;
287 pAppImpl->RegisterAppRequest(service, req, handler);
289 bool initialLaunch = false;
292 // (1) AppControl / DataControl provider listener
293 // (2) OnAppInitialized()
294 // (3) OnResume() (OnForeground()) (UiApp only)
295 // (4) OnUserEventReceivedN()
298 // (1) AppControl / DataControl provider listener
299 // (2) OnResume() (OnForeground()) (UiApp only)
300 // (3) OnUserEventReceivedN()
302 if (_AppInfo::GetAppState() == INITIALIZING)
304 initialLaunch = true;
306 unsigned int winId = 0;
307 service_get_window(service, &winId);
310 _AppInfo::SetParentWindowHandle(winId);
311 SysLog(NID_APP, "Saving window handle 0x%x.", winId);
314 // set an appinfo value for multi-window mode
316 int errVal = service_get_extra_data(service, TIZEN_APPCONTROL_DATA_MULTI_WINDOW, &pBuf);
317 if (errVal == SERVICE_ERROR_NONE)
319 if (!strcmp(pBuf, "on"))
321 _AppInfo::SetMultiWindow(true);
327 SysLog(NID_APP, "It is failed to get multi-window value: %d", errVal);
330 // call for callbacks
331 // ptr to member function
332 SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:start]", _AppInfo::GetAppExecutableName().GetPointer());
333 (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
335 if (!pAppImpl->__pIAppImpl->OnAppInitialized())
337 _AppInfo::SetAppState(TERMINATING);
338 SysLog(NID_APP, "[E_INIT_FAILED] The Initialization of your application failed.");
342 SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:done]", _AppInfo::GetAppExecutableName().GetPointer());
344 _AppInfo::SetAppState(RUNNING);
346 SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:done]", _AppInfo::GetAppExecutableName().GetPointer());
352 // call for callbacks
353 // ptr to member function
356 pAppImpl->__pIAppImpl->OnService(service, initialLaunch);
358 // ptr to member function
359 (pAppImpl->*pAppImpl->__pLegacyRequestHandler)(service, req, handler);
364 _AppImpl::OnTerminate(void* user_data)
366 SysLog(NID_APP, "Termination event 0x%x state", _AppInfo::GetAppState());
368 _AppImpl* pAppImpl = _AppImpl::GetInstance();
369 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
370 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
372 result r = _SettingInfoImpl::RemoveSettingEventListenerForInternal(*pAppImpl);
373 SysTryLog(NID_APP, !IsFailed(r), "[%s] failed to remove setting event listener.", GetErrorMessage(r));
375 __isTerminationRequested = true;
376 pAppImpl->__pIAppImpl->OnTerminate();
381 _AppImpl::OnResume(void* user_data)
383 SysLog(NID_APP, "System resume event on 0x%x state", _AppInfo::GetAppState());
384 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnResume>:start]", _AppInfo::GetAppExecutableName().GetPointer());
386 _AppImpl* pAppImpl = _AppImpl::GetInstance();
387 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
388 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
389 pAppImpl->__pIAppImpl->OnResume();
390 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnResume>:done]", _AppInfo::GetAppExecutableName().GetPointer());
395 _AppImpl::OnPause(void* user_data)
397 SysLog(NID_APP, "System pause event on 0x%x state", _AppInfo::GetAppState());
398 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnPause>:start]", _AppInfo::GetAppExecutableName().GetPointer());
400 _AppImpl* pAppImpl = _AppImpl::GetInstance();
401 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
402 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
403 pAppImpl->__pIAppImpl->OnPause();
404 pAppImpl->OnAppCheckpoint();
405 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnPause>:done]", _AppInfo::GetAppExecutableName().GetPointer());
409 _AppImpl::~_AppImpl(void)
416 _AppImpl::GetInstance(void)
423 _AppImpl::GetAppInstance(void)
430 _AppImpl::GetAppArgumentListN(void) const
432 ArrayList* pList = null;
433 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(0);
437 pList = pArg->GetArgListN(0);
442 pList = new (std::nothrow) ArrayList();
443 SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
444 String* pData = new (std::nothrow) String(LEGACY_LAUNCH_REASON_NORMAL);
445 SysTryReturn(NID_APP, pData != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
446 String* pData2 = new (std::nothrow) String(LEGACY_OPERATION_MAIN);
447 SysTryReturn(NID_APP, pData2 != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
459 _AppImpl::Terminate(void)
461 result r = E_SUCCESS;
463 SysLog(NID_APP, "Terminate() is called by application itself");
465 __isTerminationRequested = true;
473 _AppImpl::OnAppInitializing(void)
480 _AppImpl::OnAppWillTerminate(void)
482 SysTryReturn(NID_APP, __pApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
484 return __pApp->OnAppWillTerminate();
489 _AppImpl::RegisterAppRequest(service_s* service, int& req, _AppHandler& handler)
491 _AppControlManager* pManager = _AppControlManager::GetInstance();
492 SysTryReturnResult(NID_APP, pManager != null, E_SYSTEM, "Wrong system state.");
494 result r = pManager->RegisterRequest(service, req, handler);
497 SysPropagate(NID_APP, r);
501 int providerType = _AppInfo::GetAppHandlerType();
502 providerType |= (_APP_HANDLER_LAUNCH_NORMAL | _APP_HANDLER_LAUNCH_COND);
504 SysTryLog(NID_APP, (handler & providerType) != 0, "Request 0x%x received for 0x%x.", handler,
505 _AppInfo::GetAppHandlerType());
511 _AppImpl::HandleAppRequest(service_s* service, int req, _AppHandler handler)
513 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(req);
514 SysTryReturnResult(NID_APP, pArg != null, E_SYSTEM, "No argument found for %d.", req);
520 case _APP_HANDLER_DATACONTROL:
521 SysLog(NID_APP, "Handling DataControl request");
523 OnDataControlRequestReceived(*pArg, static_cast< RequestId >(req));
525 //_AppControlManager::GetInstance()->RemoveResultRequest(req);
528 case _APP_HANDLER_LAUNCH_COND:
529 SysLog(NID_APP, "Handling conditional launch request");
531 OnConditionRequestReceived(*pArg, static_cast< RequestId >(req));
535 SysLog(NID_APP, "Handling AppControl request");
537 OnAppControlRequestReceived(*pArg, static_cast< RequestId >(req));
546 _AppImpl::HandleLegacyAppRequest(service_s* service, int req, _AppHandler handler)
548 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(0);
549 SysTryReturnResult(NID_APP, pArg != null, E_SYSTEM, "No argument found for %d.", req);
555 case _APP_HANDLER_LAUNCH_NORMAL:
556 SysLog(NID_APP, "Handling normal launch request");
557 OnUserEventReceivedN(AppLaunchRequestId, pArg->GetArgListN(req), true);
559 // [TODO] request handle memory cleanup confirm
560 _AppControlManager::GetInstance()->RemoveResultRequest(req);
563 case _APP_HANDLER_LAUNCH_COND:
564 SysLog(NID_APP, "Handling conditional launch request");
566 OnUserEventReceivedN(AppLaunchRequestId, pArg->GetArgListN(req), true);
568 // [TODO] request handle memory cleanup confirm
569 _AppControlManager::GetInstance()->RemoveResultRequest(req);
581 _AppImpl::HandleDummyAppRequest(service_s* service, int req, _AppHandler handler)
583 SysLog(NID_APP, "Dummy handler");
590 _AppImpl::SetLegacyRequestHandler(void)
592 SysLog(NID_APP, "Setting request handler for legacy application.");
594 __pRequestHandler = &_AppImpl::HandleDummyAppRequest;
595 __pLegacyRequestHandler = &_AppImpl::HandleLegacyAppRequest;
602 _AppImpl::OnLowMemory(void* user_data)
604 _AppImpl* pAppImpl = _AppImpl::GetInstance();
606 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
607 SysTryReturnVoidResult(NID_APP, pAppImpl->__pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
609 if (_AppInfo::GetAppState() == RUNNING)
611 pAppImpl->__pApp->OnLowMemory();
617 _AppImpl::OnBatteryLevelChanged(BatteryLevel batteryLevel)
619 SysTryReturnVoidResult(NID_APP, __pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
621 __pApp->OnBatteryLevelChanged(batteryLevel);
625 _AppImpl::SendUserEvent(RequestId requestId, const IList* pArgs, bool isPublic)
627 _AppUserEventArg* pArg = new (std::nothrow) _AppUserEventArg(requestId, pArgs, isPublic);
628 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "User event creation failure for %d.", requestId);
630 result r = __appUserEvent.FireAsync(*pArg);
637 _AppImpl::OnUserEventReceivedN(RequestId requestId, IList* pArgs, bool isPublic)
639 SysTryReturnVoidResult(NID_APP, __pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
643 __pApp->OnUserEventReceivedN(requestId, pArgs);
649 case _APP_EVENT_TERMINATE:
650 SysLog(NID_APP, "App terminate is requested.");
653 case _APP_EVENT_RAISE:
654 SysLog(NID_APP, "App raise is requested.");
658 SysLog(NID_APP, "Unknown event : 0x%x.", requestId);
666 _AppImpl::OnAppControlRequestReceived(const _AppArg& arg, RequestId reqId)
668 IAppControlProviderEventListener* pAppControlProviderEventListener = null;
670 const String internalOperation = arg.GetValue(OSP_K_APPCONTROL_INTERNAL_OPERATION);
671 if( !internalOperation.IsEmpty() )
673 SysLog(NID_APP, "internalOperation:%ls", internalOperation.GetPointer() );
674 pAppControlProviderEventListener = __pAppControlProviderInternalEventListener;
678 pAppControlProviderEventListener = __pAppControlProviderEventListener;
681 if( pAppControlProviderEventListener == null)
683 SysLog(NID_APP, "No AppControl provider event listener set for request %d.", reqId);
687 const char* pAppId = appinfo_get_appid();
689 const char* p = appsvc_get_operation(arg.GetBundle());
690 String operationId = (p) ? String(p) : TIZEN_OPERATION_MAIN;
691 if (operationId == L"http://tizen.org/appcontrol/operation/default")
693 operationId = TIZEN_OPERATION_MAIN;
696 SysLog(NID_APP, "AppControl (%s, %ls).", pAppId, operationId.GetPointer());
700 const String* pUri = null;
701 const String* pMime = null;
702 p = appsvc_get_uri(arg.GetBundle());
708 // SLP deals with the URI as plain /opt/.../a.jpg.
709 uri.Insert(FILE_SCHEME_WITH_DELIMITER, 0);
713 SysLog(NID_APP, "Delivered uri is [%ls].", pUri->GetPointer());
716 p = appsvc_get_mime(arg.GetBundle());
723 std::unique_ptr<HashMap> pMap(arg.GetArgMapN());
725 pAppControlProviderEventListener->OnAppControlRequestReceived(reqId, operationId, pUri, pMime, pMap.get());
727 SysLog(NID_APP, "AppControl (%s, %ls) invocation finished.", pAppId, operationId.GetPointer());
732 _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
735 ISqlDataControlProviderEventListener* pSqlListener = null;
736 IMapDataControlProviderEventListener* pMapListener = null;
737 ArrayList* pColumnList = null;
738 HashMap* pInsertMap = null;
739 HashMap* pUpdateMap = null;
744 String* pDataId = null;
746 String* pColumnCount = null;
747 String* pColumn = null;
748 String* pValue = null;
749 String* pWhere = null;
750 String* pOrder = null;
751 String* pErrorMsg = null;
753 String* pCount = null;
754 String* pTmpPath = null;
755 String empty(L"NULL");
758 _DataControlRequestType requestType = _DATACONTROL_REQUEST_TYPE_UNDEFINED;
761 int countPerPage = 0;
764 result r = E_SUCCESS;
765 result res = E_SUCCESS;
766 ArrayList* pList = null;
768 String* pNewValue = null;
769 String* pOldValue = null;
771 SysLog(NID_APP, "[DC_PROV_RECV] Data control request is received.");
772 //arg.Print(); // request info
775 appId = arg.GetCallerAppId();
777 reqType = arg.GetValue(OSP_K_DATACONTROL_REQUEST_TYPE);
778 Integer::Parse(reqType, type);
779 requestType = static_cast< _DataControlRequestType >(type);
781 version = arg.GetValue(OSP_K_DATACONTROL_PROTOCOL_VERSION);
782 callerReqId = arg.GetValue(OSP_K_REQUEST_ID);
783 providerId = arg.GetValue(OSP_K_DATACONTROL_PROVIDER);
785 // list-based request
786 pList = _AppArg::GetListN(arg.GetBundle(), OSP_K_ARG);
787 SysTryCatch(NID_APP, pList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object");
789 pDataId = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_DATAID));// request list[0]: data ID
790 SysTryCatch(NID_APP, pDataId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
792 if (requestType >= _DATACONTROL_REQUEST_TYPE_SQL_QUERY && requestType <= _DATACONTROL_REQUEST_TYPE_SQL_DELETE)
794 pSqlListener = __pSqlDataControlProviderEventListener;
795 SysTryCatch(NID_APP, pSqlListener != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
797 else if (requestType >= _DATACONTROL_REQUEST_TYPE_MAP_QUERY && requestType <= _DATACONTROL_REQUEST_TYPE_MAP_DELETE)
799 pKey = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_MAPKEY)); // request list[1]
800 SysTryCatch(NID_APP, pKey, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
802 pMapListener = __pMapDataControlProviderEventListener;
803 SysTryCatch(NID_APP, pMapListener != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
807 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid request");
813 case _DATACONTROL_REQUEST_TYPE_SQL_QUERY:
814 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl SELECT");
816 // request list[1]: selected column count
817 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
818 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
820 if (pColumnCount->Equals(empty) == true)
826 Integer::Parse(*pColumnCount, columnCount);
827 pColumnList = new (std::nothrow) ArrayList();
828 SysTryReturnVoidResult(NID_APP, pColumnList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
829 pColumnList->Construct();
830 SysLog(NID_APP, "[DC_PROV_RECV] selected column count: %d", columnCount);
833 while (i < columnCount) // request list[2]: column list
835 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNLIST + i));
836 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
838 pColumnList->Add(*(new String(*pColumn)));
839 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", i, pColumn->GetPointer());
844 i += _DATACONTROL_PACKET_INDEX_COLUMNLIST;
845 pWhere = dynamic_cast< String* >(pList->GetAt(i)); // request list: where clause
846 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
848 if (pWhere->Equals(empty) == true)
854 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
858 pOrder = dynamic_cast< String* >(pList->GetAt(i)); // request list: order clause
859 SysTryCatch(NID_APP, pOrder, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
861 if (pOrder->Equals(empty) == true)
867 SysLog(NID_APP, "[DC_PROV_RECV] pOrder: %ls", pOrder->GetPointer());
871 pNo = dynamic_cast <String*>(pList->GetAt(i)); // request list: page number
872 SysTryCatch(NID_APP, pNo, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
873 Integer::Parse(*pNo, pageNo);
876 pCount = dynamic_cast <String*>(pList->GetAt(i)); // request list: count per page
877 SysTryCatch(NID_APP, pCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
878 Integer::Parse(*pCount, countPerPage);
880 pSqlListener->OnSqlDataControlSelectRequestReceived(reqId, providerId, *pDataId, pColumnList,
883 SysSecureLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pColumnList: 0x%0x, pWhere: 0x%x, pOrder: 0x%x, pageNo: %d, countPerPage: %d",
884 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
885 pDataId->GetPointer(), pColumnList, pWhere, pOrder, pageNo, countPerPage);
887 case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
888 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl INSERT");
890 // request list[1]: inserted column count
891 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
892 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
894 Integer::Parse(*pColumnCount, columnCount);
895 SysLog(NID_APP, "[DC_PROV_RECV] inserted column count: %d", columnCount);
897 pInsertMap = new (std::nothrow) HashMap();
898 SysTryReturnVoidResult(NID_APP, pInsertMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
899 pInsertMap->Construct();
901 SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
902 if (version == L"ver_2.1.0.2" || version == L"ver_2.1.0.3")
904 pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
905 SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
906 SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
909 r = request.Construct(*pTmpPath, "r");
910 SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
911 GetErrorMessage(r), pTmpPath->GetPointer());
913 for (i = 0; i < columnCount; ++i) // column-value pairs
916 int ret = request.Read(&length, sizeof(int));
917 SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
918 GetErrorMessage(GetLastResult()));
920 char* pColumn = new (std::nothrow) char[length + 1];
921 ret = request.Read(pColumn, length);
922 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
923 GetErrorMessage(GetLastResult()));
924 pColumn[length] = '\0';
925 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
927 ret = request.Read(&length, sizeof(int));
928 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
929 GetErrorMessage(GetLastResult()));
931 char* pValue = new (std::nothrow) char[length + 1];
932 ret = request.Read(pValue, length);
935 SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
939 pValue[length] = '\0';
940 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
942 pInsertMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
951 while (i < columnCount * 2) // request list: column-value pairs
953 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
954 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
955 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
957 pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
958 SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
959 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
961 pInsertMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
968 r = File::Remove(*pTmpPath);
969 SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
972 pSqlListener->OnSqlDataControlInsertRequestReceived(reqId, providerId, *pDataId, *pInsertMap);
974 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pInsertMap: 0x%x",
975 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
976 pDataId->GetPointer(), pInsertMap);
978 case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE:
979 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl UPDATE");
981 // request list[1]: updated column count
982 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
983 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
985 Integer::Parse(*pColumnCount, columnCount);
986 SysLog(NID_APP, "[DC_PROV_RECV] updated column count: %d", columnCount);
988 pUpdateMap = new (std::nothrow) HashMap();
989 SysTryReturnVoidResult(NID_APP, pUpdateMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
990 pUpdateMap->Construct();
992 SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
993 if (version == L"ver_2.1.0.2" || version == L"ver_2.1.0.3")
995 pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
996 SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
997 SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
1000 r = request.Construct(*pTmpPath, "r");
1001 SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
1002 GetErrorMessage(r), pTmpPath->GetPointer());
1004 for (i = 0; i < columnCount; ++i) // column-value pairs
1007 int ret = request.Read(&length, sizeof(int));
1008 SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
1009 GetErrorMessage(GetLastResult()));
1011 char* pColumn = new (std::nothrow) char[length + 1];
1012 ret = request.Read(pColumn, length);
1013 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
1014 GetErrorMessage(GetLastResult()));
1015 pColumn[length] = '\0';
1016 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
1018 ret = request.Read(&length, sizeof(int));
1019 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
1020 GetErrorMessage(GetLastResult()));
1022 char* pValue = new (std::nothrow) char[length + 1];
1023 ret = request.Read(pValue, length);
1026 SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
1030 pValue[length] = '\0';
1031 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
1033 pUpdateMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
1038 // request list: where clause
1039 pWhere = dynamic_cast< String* >(pList->GetAt(3));
1040 SysTryCatch(NID_APP, pWhere != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
1046 while (i < columnCount * 2) // request list: column-value pairs
1048 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
1049 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1050 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
1052 pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
1053 SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1054 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
1056 pUpdateMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
1060 // request list: where clause
1061 pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i));
1062 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1065 if (pWhere->Equals(empty) == true)
1071 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
1076 r = File::Remove(*pTmpPath);
1077 SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
1080 pSqlListener->OnSqlDataControlUpdateRequestReceived(reqId, providerId, *pDataId, *pUpdateMap, pWhere);
1082 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pUpdateMap: 0x%x, pWhere: 0x%x",
1083 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1084 pDataId->GetPointer(), pUpdateMap, pWhere);
1086 case _DATACONTROL_REQUEST_TYPE_SQL_DELETE:
1087 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl DELETE");
1089 // request list[1]: where clause
1090 pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_DELETEWHERE));
1091 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1093 if (pWhere->Equals(empty) == true)
1099 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
1102 pSqlListener->OnSqlDataControlDeleteRequestReceived(reqId, providerId, *pDataId, pWhere);
1104 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pWhere: 0x%x",
1105 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1106 pDataId->GetPointer(), pWhere);
1108 case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
1109 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl GetValue");
1111 pNo = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1112 SysTryCatch(NID_APP, pNo, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1113 Integer::Parse(*pNo, pageNo);
1115 pCount = dynamic_cast <String*>(pList->GetAt(3)); // request list[3]
1116 SysTryCatch(NID_APP, pCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1117 Integer::Parse(*pCount, countPerPage);
1119 pMapListener->OnMapDataControlGetValueRequestReceived(reqId, providerId, *pDataId, *pKey);
1121 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, pageNo: %d, countPerPage: %d",
1122 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1123 pDataId->GetPointer(), pKey->GetPointer(), pageNo, countPerPage);
1125 case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
1126 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl AddValue");
1128 pValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1129 SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1131 pMapListener->OnMapDataControlAddValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pValue);
1133 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, value: %ls",
1134 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1135 pDataId->GetPointer(), pKey->GetPointer(), pValue->GetPointer());
1137 case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
1138 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl SetValue");
1140 pOldValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1141 SysTryCatch(NID_APP, pOldValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1143 pNewValue = dynamic_cast <String*>(pList->GetAt(3)); // request list[3]
1144 SysTryCatch(NID_APP, pNewValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1146 pMapListener->OnMapDataControlSetValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pOldValue, *pNewValue);
1148 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, oldValue: %ls, newValue: %ls",
1149 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1150 pDataId->GetPointer(), pKey->GetPointer(), pOldValue->GetPointer(), pNewValue->GetPointer());
1152 case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
1153 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl RemoveValue");
1155 pValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1156 SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1158 pMapListener->OnMapDataControlRemoveValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pValue);
1160 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, value: %ls",
1161 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1162 pDataId->GetPointer(), pKey->GetPointer(), pValue->GetPointer());
1165 SysTryCatch(NID_APP, false, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1171 pColumnList->RemoveAll(true);
1177 pInsertMap->RemoveAll(true);
1183 pUpdateMap->RemoveAll(true);
1192 pColumnList->RemoveAll(true);
1198 pInsertMap->RemoveAll(true);
1204 pUpdateMap->RemoveAll(true);
1210 pErrorMsg = new (std::nothrow) String("[E_SYSTEM] A system error has occurred.");
1212 else if (r == E_OUT_OF_MEMORY)
1214 pErrorMsg = new (std::nothrow) String("[E_OUT_OF_MEMORY] The memory was insufficient.");
1216 SysTryReturnVoidResult(NID_APP, pErrorMsg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory was insufficient.");
1218 res = DataControlProviderManager::GetInstance()->SendDataControlError(reqId, *pErrorMsg);
1227 _AppImpl::OnConditionRequestReceived(const _AppArg& arg, RequestId reqId)
1229 if (__pAppLaunchConditionEventListener == null)
1231 SysLog(NID_APP, "No App launch condition event listener");
1235 String condition = arg.GetValue(OSP_K_COND);
1236 //Object* pExtraData = null;//TODO: retrieve NFC extra data.
1237 HashMap* pExtraData = arg.GetArgMapN();
1238 ArrayList* pList = arg.GetArgListN();
1240 __pAppLaunchConditionEventListener->OnAppLaunchConditionMetN(condition, pExtraData, pList);
1245 _AppImpl::GetWindowHandle(void) const
1247 SysTryReturn(NID_APP, __pIAppImpl != null, -1, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
1249 return __pIAppImpl->OnWindowHandleRequest();
1254 _AppImpl::RaiseWindow(void)
1256 SysTryReturnVoidResult(NID_APP, __pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
1258 __pIAppImpl->OnFrameRaiseRequested();
1263 _AppImpl::OnAppCheckpoint(void)
1265 if (__pCheckpointEventListener)
1267 __pCheckpointEventListener->OnAppCheckpointing(*(AppRegistry::GetInstance()));
1273 _AppImpl::ConfirmAppService(void)
1275 if (_AppInfo::GetApplicationId() == SERVICE_APPID)
1282 long interval = 100;
1286 int res = vconf_get_int(VCONFKEY_APPSERVICE_STATUS, &value);
1292 if (count >= HEARTBEAT_WAIT_COUNT)
1297 SysLog(NID_APP, "Waiting for app service %dth time(%d msec).", count, interval);
1299 Thread::Sleep(interval);
1307 _AppImpl::SetListener(_AppEvent appEvent, IEventListener* pListener)
1311 case _APP_EVENT_CHECKPOINT:
1312 SysTryReturnResult(NID_APP, __pCheckpointEventListener == null, E_OBJ_ALREADY_EXIST, "Checkpoint listener is already set.");
1315 case _APP_EVENT_CLEAR_LISTENER:
1316 __pCheckpointEventListener = dynamic_cast <IAppCheckpointEventListener*>(pListener);
1328 _AppImpl::SetSqlDataControlProviderEventListener(ISqlDataControlProviderEventListener* pListener)
1330 __pSqlDataControlProviderEventListener = pListener;
1331 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1332 tmpAppHandlerType |= _APP_HANDLER_DATACONTROL;
1333 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1339 _AppImpl::SetMapDataControlProviderEventListener(IMapDataControlProviderEventListener* pListener)
1341 __pMapDataControlProviderEventListener = pListener;
1342 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1343 tmpAppHandlerType |= _APP_HANDLER_DATACONTROL;
1344 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1350 _AppImpl::SetAppControlProviderEventListener(IAppControlProviderEventListener* pListener)
1352 __pAppControlProviderEventListener = pListener;
1353 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1354 tmpAppHandlerType |= _APP_HANDLER_APPCONTROL;
1355 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1360 _AppImpl::SetAppControlProviderInternalEventListener(IAppControlProviderEventListener* pListener)
1362 __pAppControlProviderInternalEventListener = pListener;
1363 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1364 tmpAppHandlerType |= _APP_HANDLER_APPCONTROL;
1365 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1371 _AppImpl::SetAppLaunchConditionEventListener(IAppLaunchConditionEventListener* pListener)
1373 __pAppLaunchConditionEventListener = pListener;
1374 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1375 tmpAppHandlerType |= _APP_HANDLER_LAUNCH_COND;
1376 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1383 _AppImpl::IsTerminationRequested(void)
1385 return __isTerminationRequested;
1388 typedef void (*cbForVconf)(keynode_t* node, void *pData);
1391 _AppImpl::OnPowerOffNotiReceived(void* node, void* user_data)
1394 if (!vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &value))
1396 if (value == VCONFKEY_SYSMAN_POWER_OFF_DIRECT || value == VCONFKEY_SYSMAN_POWER_OFF_RESTART)
1398 SysLog(NID_APP, "Application is being terminated by power off.");
1400 if (vconf_ignore_key_changed(VCONFKEY_SYSMAN_POWER_OFF_STATUS, (cbForVconf)_AppImpl::OnPowerOffNotiReceived))
1402 SysLog(NID_APP, "Fail to ignore vconf for key(%s)", VCONFKEY_SYSMAN_POWER_OFF_STATUS);
1405 _AppImpl* pAppImpl = _AppImpl::GetInstance();
1406 if (pAppImpl != null)
1408 pAppImpl->__forcedTermination = true;
1417 _AppImpl::OnSettingChanged(String& key)
1419 if (key == L"http://tizen.org/setting/locale.language")
1421 _AppInfo::UpdatePackageInfo(true);
1422 _AppResourceImpl::Reinitialize();
1423 SysLog(NID_APP, "Reinitialized resources due to locale change.");
1428 _AppImpl::IsForcedTermination(void)
1430 return __forcedTermination;