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>
28 #include <FBaseInteger.h>
29 #include <FBaseColArrayList.h>
30 #include <FBaseColHashMap.h>
31 #include <FBaseRtThread.h>
32 #include <FAppAppRegistry.h>
33 #include <FAppAppControl.h>
34 #include <FAppDataControlProviderManager.h>
35 #include <FAppIAppCheckPointEventListener.h>
36 #include <FAppISqlDataControlProviderEventListener.h>
37 #include <FAppIMapDataControlProviderEventListener.h>
38 #include <FAppIAppControlProviderEventListener.h>
39 #include <FAppIAppLaunchConditionEventListener.h>
42 #include <FBaseSysLog.h>
43 #include <FIo_RegistryImpl.h>
44 #include <FSys_EnvironmentImpl.h>
45 #include <FSys_PowerManagerImpl.h>
47 #include <FSys_AlarmManager.h>
49 #include "FApp_IAppManager.h"
50 #include "FApp_AppManagerProxy.h"
51 #include "FApp_AppImpl.h"
52 #include "FApp_AppInfo.h"
53 #include "FApp_AppControlManager.h"
54 #include "FApp_AppArg.h"
55 #include "FApp_IAppImpl.h"
56 #include "FApp_AppResourceImpl.h"
58 using namespace Tizen::Base;
59 using namespace Tizen::Base::Collection;
60 using namespace Tizen::Base::Runtime;
61 using namespace Tizen::Io;
62 using namespace Tizen::System;
67 const int HEARTBEAT_WAIT_COUNT = 3;
68 const wchar_t SERVICE_APPID[] = L"aospd00043.osp-app-service";
69 const char SELECTOR_RESPONSE_KEY[] = "__APP_SVC_START_INFO__";
70 const wchar_t FILE_SCHEME_WITH_DELIMITER[] = L"file://";
71 #ifndef VCONFKEY_APPSERVICE_STATUS
72 #define VCONFKEY_APPSERVICE_STATUS "memory/appservice/status"
77 namespace Tizen { namespace App
80 _AppImpl* _AppImpl::__pAppImpl = null;
81 bool _AppImpl::__isTerminationRequested = false;
83 static const int _DATACONTROL_PACKET_INDEX_APPID = 0;
84 static const int _DATACONTROL_PACKET_INDEX_REQUESTTYPE = 1;
85 static const int _DATACONTROL_PACKET_INDEX_REQID = 2;
86 static const int _DATACONTROL_PACKET_INDEX_PROVIDERID = 3;
88 static const int _DATACONTROL_PACKET_INDEX_DATAID = 0;
89 static const int _DATACONTROL_PACKET_INDEX_COLUMNCOUNT = 1;
90 static const int _DATACONTROL_PACKET_INDEX_DELETEWHERE = 1;
91 static const int _DATACONTROL_PACKET_INDEX_MAPKEY = 1;
92 static const int _DATACONTROL_PACKET_INDEX_COLUMNLIST = 2;
93 static const int _DATACONTROL_PACKET_INDEX_INSERTMAP = 2;
94 static const int _DATACONTROL_PACKET_INDEX_UPDATEMAP = 2;
98 void operator()(char* pValue)
108 _AppImpl::_AppImpl(App* pApp)
109 : __pCheckpointEventListener(null)
110 , __pSqlDataControlProviderEventListener(null)
111 , __pMapDataControlProviderEventListener(null)
112 , __pAppControlProviderEventListener(null)
113 , __pAppControlProviderInternalEventListener(null)
114 , __pAppLaunchConditionEventListener(null)
117 , __pRequestHandler(&_AppImpl::HandleAppRequest)
118 , __pLegacyRequestHandler(&_AppImpl::HandleDummyAppRequest)
119 , __forcedTermination(false)
126 _AppImpl::Construct(const IList* pArgs)
128 SysTryReturnResult(NID_APP, pArgs != null, E_INVALID_ARG, "pArguments must not be null.");
129 SysAssertf(__pApp != null, "Getting App instance failed.");
131 result r = __appUserEvent.Construct();
132 SysTryLog(NID_APP, !IsFailed(r), "[%s] User event handler failure.", GetErrorMessage(r));
134 __appUserEvent.AddListener(*this);
136 _AppInfo::SetAppState(INITIALIZING);
143 _AppImpl::Execute(_IAppImpl* pIAppImpl)
145 SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:start]", _AppInfo::GetAppExecutableName().GetPointer());
146 result r = E_SUCCESS;
147 int eflResult = APP_ERROR_NONE;
148 int argc = _AppInfo::GetArgc();
149 char** pArgv = _AppInfo::GetArgv();
150 _IAppManager* pAppManager = null;
152 _AppImpl* pAppImpl = _AppImpl::GetInstance();
153 SysTryReturnResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
154 pAppImpl->__pIAppImpl = pIAppImpl;
156 // handle legacy version handling
157 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
159 pAppImpl->SetLegacyRequestHandler();
162 // clear previous notification
163 // [INFO] behavior change : platform does not clear previous notification
164 notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI);
166 app_event_callback_s state_handler;
167 memset(&state_handler, 0, sizeof(app_event_callback_s));
169 state_handler.create = &OnCreate;
170 state_handler.service = &OnService;
171 state_handler.terminate = &OnTerminate;
172 state_handler.pause = &OnPause;
173 state_handler.resume = &OnResume;
174 state_handler.device_orientation = NULL;
176 state_handler.low_memory = &OnLowMemory;
177 state_handler.low_battery = NULL;
178 state_handler.language_changed = &OnLanguageChanged;
179 state_handler.region_format_changed = &OnRegionFormatChanged;
181 _Aul::SetPowerOffNotiListener(OnPowerOffNotiReceived, this);
182 // if (pAppManager != null)
184 // r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), _AppInfo::GetAppType() , _AppInfo::GetProcessId());
185 // SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Application registration failed.", GetErrorMessage(r));
188 eflResult = app_efl_main(&argc, &pArgv, &state_handler, this);
190 SysTryLog(NID_APP, eflResult == APP_ERROR_NONE, "app_efl_main failed with error (%d): Unknown", eflResult);
192 // clear outstanding ongoing notification
193 notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_ONGOING);
196 pAppManager = _AppManagerProxy::GetService();
198 if (pAppManager != null)
200 pAppManager->UnregisterApplication(_AppInfo::GetProcessId());
208 _AppImpl::OnCreate(void* user_data)
210 SysLog(NID_APP, "Platform creation event.");
212 _AppImpl* pAppImpl = static_cast<_AppImpl*>(user_data);
213 if (pAppImpl == null)
215 _AppInfo::SetAppState(TERMINATED);
216 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Invalid platform state.");
220 _AppInfo::SetAppState(INITIALIZING);
222 if (!ConfirmAppService())
224 _AppInfo::SetAppState(TERMINATED);
225 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Osp AppService is not running.");
229 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:start]", _AppInfo::GetAppExecutableName().GetPointer());
230 if (!pAppImpl->__pIAppImpl->OnAppInitializing())
232 _AppInfo::SetAppState(TERMINATED);
233 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] The initialization of your application failed.");
236 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:done]", _AppInfo::GetAppExecutableName().GetPointer());
238 SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:start]", _AppInfo::GetAppExecutableName().GetPointer());
239 _IAppManager* pAppManager = _AppManagerProxy::GetService();
241 if (pAppManager != null)
243 result r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), static_cast<_AppType>(_AppInfo::GetAppType()), _AppInfo::GetProcessId());
244 SysTryLog(NID_APP, !IsFailed(r), "[%s] Application registration failed.", GetErrorMessage(r));
246 SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:done]", _AppInfo::GetAppExecutableName().GetPointer());
247 // hide splash window
249 _PowerManagerImpl::InitBatteryEvent();
256 _AppImpl::OnService(service_s* service, void* user_data)
258 _AppImpl* pAppImpl = _AppImpl::GetInstance();
259 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
260 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
262 // ugly code for app selector event handling
263 bundle* pBundle = _AppArg::GetBundleFromSvc(service);
266 const char* pValue = appsvc_get_data(pBundle, SELECTOR_RESPONSE_KEY);
269 const int req = _AppArg::GetRequestIdFromBundle(pBundle);
271 const char* pOperation = appsvc_get_operation(pBundle);
273 SysLog(NID_APP, "App selector response [%s, %s], req(%d).", pValue, pOperation, req);
275 //_AppArg::Print(pBundle);
276 _AppControlManager::GetInstance()->SendAppControlStartResponse(req, pValue, pOperation);
281 //_AppArg::Print(pBundle);
283 _AppHandler handler = _APP_HANDLER_NONE;
284 pAppImpl->RegisterAppRequest(service, req, handler);
286 bool initialLaunch = false;
289 // (1) AppControl / DataControl provider listener
290 // (2) OnAppInitialized()
291 // (3) OnResume() (OnForeground()) (UiApp only)
292 // (4) OnUserEventReceivedN()
295 // (1) AppControl / DataControl provider listener
296 // (2) OnResume() (OnForeground()) (UiApp only)
297 // (3) OnUserEventReceivedN()
299 if (_AppInfo::GetAppState() == INITIALIZING)
301 initialLaunch = true;
303 unsigned int winId = 0;
304 service_get_window(service, &winId);
307 _AppInfo::GetAppInfo()->SetParentWindowHandle(winId);
308 SysLog(NID_APP, "Saving window handle 0x%x.", winId);
310 // call for callbacks
311 // ptr to member function
312 SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:start]", _AppInfo::GetAppExecutableName().GetPointer());
313 (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
315 if (!pAppImpl->__pIAppImpl->OnAppInitialized())
317 _AppInfo::SetAppState(TERMINATING);
318 SysLog(NID_APP, "[E_INIT_FAILED] The Initialization of your application failed.");
322 SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:done]", _AppInfo::GetAppExecutableName().GetPointer());
324 _AppInfo::SetAppState(RUNNING);
326 SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:done]", _AppInfo::GetAppExecutableName().GetPointer());
332 // call for callbacks
333 // ptr to member function
334 (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
336 std::unique_ptr<char[], charDeleter> pOperation(null);
339 int errVal = service_get_operation(service, &pBuf);
340 pOperation.reset(pBuf);
342 if((errVal == SERVICE_ERROR_NONE) && (!strcmp((const char*)pOperation.get(), "osp.operation.ALARM")))
344 std::unique_ptr<char[], charDeleter> pAlarmId(null);
347 errVal = service_get_extra_data(service, SERVICE_DATA_ALARM_ID, &pBuf);
348 pAlarmId.reset(pBuf);
349 SysTryReturnVoidResult(NID_SYS, errVal == SERVICE_ERROR_NONE, E_SYSTEM, "It is failed to get reserved alarm id.");
350 int alarmId = atoi((const char*)pAlarmId.get());
352 _AlarmManager* pAlarmManager = _AlarmManager::GetInstance();
353 pAlarmManager->OnAlarmExpired(alarmId);
359 pAppImpl->__pIAppImpl->OnService(service, initialLaunch);
361 // ptr to member function
362 (pAppImpl->*pAppImpl->__pLegacyRequestHandler)(service, req, handler);
367 _AppImpl::OnTerminate(void* user_data)
369 SysLog(NID_APP, "Termination event 0x%x state", _AppInfo::GetAppState());
371 _AppImpl* pAppImpl = _AppImpl::GetInstance();
372 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
373 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
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(L"osp.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 __isTerminationRequested = true;
471 _AppImpl::OnAppInitializing(void)
478 _AppImpl::OnAppWillTerminate(void)
480 SysTryReturn(NID_APP, __pApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
482 return __pApp->OnAppWillTerminate();
487 _AppImpl::RegisterAppRequest(service_s* service, int& req, _AppHandler& handler)
489 _AppControlManager* pManager = _AppControlManager::GetInstance();
490 SysTryReturnResult(NID_APP, pManager != null, E_SYSTEM, "Wrong system state.");
492 result r = pManager->RegisterRequest(service, req, handler);
493 SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
495 int providerType = _AppInfo::GetAppHandlerType();
496 providerType |= (_APP_HANDLER_LAUNCH_NORMAL | _APP_HANDLER_LAUNCH_COND);
498 SysTryLog(NID_APP, (handler & providerType) != 0, "Request 0x%x received for 0x%x.", handler,
499 _AppInfo::GetAppHandlerType());
505 _AppImpl::HandleAppRequest(service_s* service, int req, _AppHandler handler)
507 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(req);
508 SysTryReturnResult(NID_APP, pArg != null, E_SYSTEM, "No argument found for %d.", req);
514 case _APP_HANDLER_DATACONTROL:
515 SysLog(NID_APP, "Handling DataControl request");
517 OnDataControlRequestReceived(*pArg, static_cast< RequestId >(req));
519 //_AppControlManager::GetInstance()->RemoveResultRequest(req);
522 case _APP_HANDLER_LAUNCH_COND:
523 SysLog(NID_APP, "Handling conditional launch request");
525 OnConditionRequestReceived(*pArg, static_cast< RequestId >(req));
529 SysLog(NID_APP, "Handling AppControl request");
531 OnAppControlRequestReceived(*pArg, static_cast< RequestId >(req));
540 _AppImpl::HandleLegacyAppRequest(service_s* service, int req, _AppHandler handler)
542 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(0);
543 SysTryReturnResult(NID_APP, pArg != null, E_SYSTEM, "No argument found for %d.", req);
549 case _APP_HANDLER_LAUNCH_NORMAL:
550 SysLog(NID_APP, "Handling normal launch request");
551 OnUserEventReceivedN(AppLaunchRequestId, pArg->GetArgListN(req));
553 // [TODO] request handle memory cleanup confirm
554 _AppControlManager::GetInstance()->RemoveResultRequest(req);
557 case _APP_HANDLER_LAUNCH_COND:
558 SysLog(NID_APP, "Handling conditional launch request");
560 OnUserEventReceivedN(AppLaunchRequestId, pArg->GetArgListN(req));
562 // [TODO] request handle memory cleanup confirm
563 _AppControlManager::GetInstance()->RemoveResultRequest(req);
575 _AppImpl::HandleDummyAppRequest(service_s* service, int req, _AppHandler handler)
577 SysLog(NID_APP, "Dummy handler");
584 _AppImpl::SetLegacyRequestHandler(void)
586 SysLog(NID_APP, "Setting request handler for legacy application.");
588 __pRequestHandler = &_AppImpl::HandleDummyAppRequest;
589 __pLegacyRequestHandler = &_AppImpl::HandleLegacyAppRequest;
596 _AppImpl::OnLowMemory(void* user_data)
598 _AppImpl* pAppImpl = _AppImpl::GetInstance();
600 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
601 SysTryReturnVoidResult(NID_APP, pAppImpl->__pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
603 if (_AppInfo::GetAppState() == RUNNING)
605 pAppImpl->__pApp->OnLowMemory();
611 _AppImpl::OnBatteryLevelChanged(BatteryLevel batteryLevel)
613 SysTryReturnVoidResult(NID_APP, __pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
615 __pApp->OnBatteryLevelChanged(batteryLevel);
619 _AppImpl::OnLanguageChanged(void* user_data)
622 _AppInfo::UpdatePackageInfo(true);
624 _AppResourceImpl::Reinitialize();
625 SysLog(NID_APP, "Language change done.");
629 _AppImpl::OnRegionFormatChanged(void* user_data)
631 // Osp doesn't implement this callback.
636 _AppImpl::SendUserEvent(RequestId requestId, const IList* pArgs)
638 _AppUserEventArg* pArg = new (std::nothrow) _AppUserEventArg(requestId, pArgs);
639 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "User event creation failure for %d.", requestId);
641 result r = __appUserEvent.FireAsync(*pArg);
648 _AppImpl::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
650 SysTryReturnVoidResult(NID_APP, __pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
652 __pApp->OnUserEventReceivedN(requestId, pArgs);
657 _AppImpl::OnAppControlRequestReceived(const _AppArg& arg, RequestId reqId)
659 IAppControlProviderEventListener* pAppControlProviderEventListener = null;
661 const String internalOperation = arg.GetValue(OSP_K_APPCONTROL_INTERNAL_OPERATION);
662 if( !internalOperation.IsEmpty() )
664 SysLog(NID_APP, "internalOperation:%ls", internalOperation.GetPointer() );
665 pAppControlProviderEventListener = __pAppControlProviderInternalEventListener;
669 pAppControlProviderEventListener = __pAppControlProviderEventListener;
672 if( pAppControlProviderEventListener == null)
674 SysLog(NID_APP, "No AppControl provider event listener set for request %d.", reqId);
678 const String& appId = _AppInfo::GetApplicationId();
680 const char* p = appsvc_get_operation(arg.GetBundle());
681 String operationId = (p) ? String(p) : TIZEN_OPERATION_MAIN;
682 if (operationId == L"http://tizen.org/appcontrol/operation/default")
684 operationId = TIZEN_OPERATION_MAIN;
687 SysLog(NID_APP, "AppControl (%ls, %ls).", appId.GetPointer(), operationId.GetPointer());
691 const String* pUri = null;
692 const String* pMime = null;
693 p = appsvc_get_uri(arg.GetBundle());
699 // SLP deals with the URI as plain /opt/.../a.jpg.
700 uri.Insert(FILE_SCHEME_WITH_DELIMITER, 0);
704 SysLog(NID_APP, "Delivered uri is [%ls].", pUri->GetPointer());
707 p = appsvc_get_mime(arg.GetBundle());
714 std::unique_ptr<HashMap> pMap(arg.GetArgMapN());
716 pAppControlProviderEventListener->OnAppControlRequestReceived(reqId, operationId, pUri, pMime, pMap.get());
718 SysLog(NID_APP, "AppControl (%ls, %ls) invocation finished.", appId.GetPointer(), operationId.GetPointer());
723 _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
726 ISqlDataControlProviderEventListener* pSqlListener = null;
727 IMapDataControlProviderEventListener* pMapListener = null;
728 ArrayList* pColumnList = null;
729 HashMap* pInsertMap = null;
730 HashMap* pUpdateMap = null;
735 String* pDataId = null;
737 String* pColumnCount = null;
738 String* pColumn = null;
739 String* pValue = null;
740 String* pWhere = null;
741 String* pOrder = null;
742 String* pErrorMsg = null;
744 String* pCount = null;
745 String* pTmpPath = null;
746 String empty(L"NULL");
749 _DataControlRequestType requestType = _DATACONTROL_REQUEST_TYPE_UNDEFINED;
752 int countPerPage = 0;
755 result r = E_SUCCESS;
756 result res = E_SUCCESS;
757 ArrayList* pList = null;
759 String* pNewValue = null;
760 String* pOldValue = null;
762 SysLog(NID_APP, "[DC_PROV_RECV] Data control request is received.");
763 //arg.Print(); // request info
766 appId = arg.GetCallerAppId();
768 reqType = arg.GetValue(OSP_K_DATACONTROL_REQUEST_TYPE);
769 Integer::Parse(reqType, type);
770 requestType = static_cast< _DataControlRequestType >(type);
772 version = arg.GetValue(OSP_K_DATACONTROL_PROTOCOL_VERSION);
773 callerReqId = arg.GetValue(OSP_K_REQUEST_ID);
774 providerId = arg.GetValue(OSP_K_DATACONTROL_PROVIDER);
776 // list-based request
777 pList = _AppArg::GetListN(arg.GetBundle(), OSP_K_ARG);
778 SysTryCatch(NID_APP, pList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object");
780 pDataId = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_DATAID));// request list[0]: data ID
781 SysTryCatch(NID_APP, pDataId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
783 if (requestType >= _DATACONTROL_REQUEST_TYPE_SQL_QUERY && requestType <= _DATACONTROL_REQUEST_TYPE_SQL_DELETE)
785 pSqlListener = __pSqlDataControlProviderEventListener;
786 SysTryCatch(NID_APP, pSqlListener != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
788 else if (requestType >= _DATACONTROL_REQUEST_TYPE_MAP_QUERY && requestType <= _DATACONTROL_REQUEST_TYPE_MAP_DELETE)
790 pKey = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_MAPKEY)); // request list[1]
791 SysTryCatch(NID_APP, pKey, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
793 pMapListener = __pMapDataControlProviderEventListener;
794 SysTryCatch(NID_APP, pMapListener != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
798 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid request");
804 case _DATACONTROL_REQUEST_TYPE_SQL_QUERY:
805 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl SELECT");
807 // request list[1]: selected column count
808 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
809 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
811 if (pColumnCount->Equals(empty) == true)
817 Integer::Parse(*pColumnCount, columnCount);
818 pColumnList = new (std::nothrow) ArrayList();
819 SysTryReturnVoidResult(NID_APP, pColumnList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
820 pColumnList->Construct();
821 SysLog(NID_APP, "[DC_PROV_RECV] selected column count: %d", columnCount);
824 while (i < columnCount) // request list[2]: column list
826 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNLIST + i));
827 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
829 pColumnList->Add(*(new String(*pColumn)));
830 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", i, pColumn->GetPointer());
835 i += _DATACONTROL_PACKET_INDEX_COLUMNLIST;
836 pWhere = dynamic_cast< String* >(pList->GetAt(i)); // request list: where clause
837 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
839 if (pWhere->Equals(empty) == true)
845 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
849 pOrder = dynamic_cast< String* >(pList->GetAt(i)); // request list: order clause
850 SysTryCatch(NID_APP, pOrder, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
852 if (pOrder->Equals(empty) == true)
858 SysLog(NID_APP, "[DC_PROV_RECV] pOrder: %ls", pOrder->GetPointer());
862 pNo = dynamic_cast <String*>(pList->GetAt(i)); // request list: page number
863 SysTryCatch(NID_APP, pNo, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
864 Integer::Parse(*pNo, pageNo);
867 pCount = dynamic_cast <String*>(pList->GetAt(i)); // request list: count per page
868 SysTryCatch(NID_APP, pCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
869 Integer::Parse(*pCount, countPerPage);
871 pSqlListener->OnSqlDataControlSelectRequestReceived(reqId, providerId, *pDataId, pColumnList,
874 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",
875 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
876 pDataId->GetPointer(), pColumnList, pWhere, pOrder, pageNo, countPerPage);
878 case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
879 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl INSERT");
881 // request list[1]: inserted column count
882 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
883 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
885 Integer::Parse(*pColumnCount, columnCount);
886 SysLog(NID_APP, "[DC_PROV_RECV] inserted column count: %d", columnCount);
888 pInsertMap = new (std::nothrow) HashMap();
889 SysTryReturnVoidResult(NID_APP, pInsertMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
890 pInsertMap->Construct();
892 SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
893 if (version == L"ver_2.1.0.2" || version == L"ver_2.1.0.3")
895 pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
896 SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
897 SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
900 r = request.Construct(*pTmpPath, "r");
901 SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
902 GetErrorMessage(r), pTmpPath->GetPointer());
904 for (i = 0; i < columnCount; ++i) // column-value pairs
907 int ret = request.Read(&length, sizeof(int));
908 SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
909 GetErrorMessage(GetLastResult()));
911 char* pColumn = new (std::nothrow) char[length + 1];
912 ret = request.Read(pColumn, length);
913 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
914 GetErrorMessage(GetLastResult()));
915 pColumn[length] = '\0';
916 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
918 ret = request.Read(&length, sizeof(int));
919 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
920 GetErrorMessage(GetLastResult()));
922 char* pValue = new (std::nothrow) char[length + 1];
923 ret = request.Read(pValue, length);
926 SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
930 pValue[length] = '\0';
931 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
933 pInsertMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
942 while (i < columnCount * 2) // request list: column-value pairs
944 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
945 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
946 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
948 pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
949 SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
950 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
952 pInsertMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
959 r = File::Remove(*pTmpPath);
960 SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
963 pSqlListener->OnSqlDataControlInsertRequestReceived(reqId, providerId, *pDataId, *pInsertMap);
965 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pInsertMap: 0x%x",
966 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
967 pDataId->GetPointer(), pInsertMap);
969 case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE:
970 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl UPDATE");
972 // request list[1]: updated column count
973 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
974 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
976 Integer::Parse(*pColumnCount, columnCount);
977 SysLog(NID_APP, "[DC_PROV_RECV] updated column count: %d", columnCount);
979 pUpdateMap = new (std::nothrow) HashMap();
980 SysTryReturnVoidResult(NID_APP, pUpdateMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
981 pUpdateMap->Construct();
983 SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
984 if (version == L"ver_2.1.0.2" || version == L"ver_2.1.0.3")
986 pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
987 SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
988 SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
991 r = request.Construct(*pTmpPath, "r");
992 SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
993 GetErrorMessage(r), pTmpPath->GetPointer());
995 for (i = 0; i < columnCount; ++i) // column-value pairs
998 int ret = request.Read(&length, sizeof(int));
999 SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
1000 GetErrorMessage(GetLastResult()));
1002 char* pColumn = new (std::nothrow) char[length + 1];
1003 ret = request.Read(pColumn, length);
1004 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
1005 GetErrorMessage(GetLastResult()));
1006 pColumn[length] = '\0';
1007 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
1009 ret = request.Read(&length, sizeof(int));
1010 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
1011 GetErrorMessage(GetLastResult()));
1013 char* pValue = new (std::nothrow) char[length + 1];
1014 ret = request.Read(pValue, length);
1017 SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
1021 pValue[length] = '\0';
1022 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
1024 pUpdateMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
1029 // request list: where clause
1030 pWhere = dynamic_cast< String* >(pList->GetAt(3));
1031 SysTryCatch(NID_APP, pWhere != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
1037 while (i < columnCount * 2) // request list: column-value pairs
1039 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
1040 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1041 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
1043 pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
1044 SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1045 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
1047 pUpdateMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
1051 // request list: where clause
1052 pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i));
1053 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1056 if (pWhere->Equals(empty) == true)
1062 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
1067 r = File::Remove(*pTmpPath);
1068 SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
1071 pSqlListener->OnSqlDataControlUpdateRequestReceived(reqId, providerId, *pDataId, *pUpdateMap, pWhere);
1073 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pUpdateMap: 0x%x, pWhere: 0x%x",
1074 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1075 pDataId->GetPointer(), pUpdateMap, pWhere);
1077 case _DATACONTROL_REQUEST_TYPE_SQL_DELETE:
1078 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl DELETE");
1080 // request list[1]: where clause
1081 pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_DELETEWHERE));
1082 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1084 if (pWhere->Equals(empty) == true)
1090 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
1093 pSqlListener->OnSqlDataControlDeleteRequestReceived(reqId, providerId, *pDataId, pWhere);
1095 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pWhere: 0x%x",
1096 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1097 pDataId->GetPointer(), pWhere);
1099 case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
1100 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl GetValue");
1102 pNo = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1103 SysTryCatch(NID_APP, pNo, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1104 Integer::Parse(*pNo, pageNo);
1106 pCount = dynamic_cast <String*>(pList->GetAt(3)); // request list[3]
1107 SysTryCatch(NID_APP, pCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1108 Integer::Parse(*pCount, countPerPage);
1110 pMapListener->OnMapDataControlGetValueRequestReceived(reqId, providerId, *pDataId, *pKey);
1112 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, pageNo: %d, countPerPage: %d",
1113 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1114 pDataId->GetPointer(), pKey->GetPointer(), pageNo, countPerPage);
1116 case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
1117 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl AddValue");
1119 pValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1120 SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1122 pMapListener->OnMapDataControlAddValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pValue);
1124 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, value: %ls",
1125 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1126 pDataId->GetPointer(), pKey->GetPointer(), pValue->GetPointer());
1128 case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
1129 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl SetValue");
1131 pOldValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1132 SysTryCatch(NID_APP, pOldValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1134 pNewValue = dynamic_cast <String*>(pList->GetAt(3)); // request list[3]
1135 SysTryCatch(NID_APP, pNewValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1137 pMapListener->OnMapDataControlSetValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pOldValue, *pNewValue);
1139 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, oldValue: %ls, newValue: %ls",
1140 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1141 pDataId->GetPointer(), pKey->GetPointer(), pOldValue->GetPointer(), pNewValue->GetPointer());
1143 case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
1144 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl RemoveValue");
1146 pValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1147 SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1149 pMapListener->OnMapDataControlRemoveValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pValue);
1151 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, value: %ls",
1152 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1153 pDataId->GetPointer(), pKey->GetPointer(), pValue->GetPointer());
1156 SysTryCatch(NID_APP, false, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1162 pColumnList->RemoveAll(true);
1168 pInsertMap->RemoveAll(true);
1174 pUpdateMap->RemoveAll(true);
1183 pErrorMsg = new (std::nothrow) String("[E_SYSTEM] A system error has occurred.");
1185 else if (r == E_OUT_OF_MEMORY)
1187 pErrorMsg = new (std::nothrow) String("[E_OUT_OF_MEMORY] The memory was insufficient.");
1189 SysTryReturnVoidResult(NID_APP, pErrorMsg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory was insufficient.");
1191 res = DataControlProviderManager::GetInstance()->SendDataControlError(reqId, *pErrorMsg);
1195 pColumnList->RemoveAll(true);
1201 pInsertMap->RemoveAll(true);
1207 pUpdateMap->RemoveAll(true);
1218 _AppImpl::OnConditionRequestReceived(const _AppArg& arg, RequestId reqId)
1220 if (__pAppLaunchConditionEventListener == null)
1222 SysLog(NID_APP, "No App launch condition event listener");
1226 String condition = arg.GetValue(OSP_K_COND);
1227 //Object* pExtraData = null;//TODO: retrieve NFC extra data.
1228 HashMap* pExtraData = arg.GetArgMapN();
1229 ArrayList* pList = arg.GetArgListN();
1231 __pAppLaunchConditionEventListener->OnAppLaunchConditionMetN(condition, pExtraData, pList);
1236 _AppImpl::GetWindowHandle(void) const
1238 SysTryReturn(NID_APP, __pIAppImpl != null, -1, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
1240 return __pIAppImpl->OnWindowHandleRequest();
1245 _AppImpl::OnAppCheckpoint(void)
1247 if (__pCheckpointEventListener)
1249 __pCheckpointEventListener->OnAppCheckpointing(*(AppRegistry::GetInstance()));
1255 _AppImpl::ConfirmAppService(void)
1257 if (_AppInfo::GetApplicationId() == SERVICE_APPID)
1264 long interval = 100;
1268 int res = vconf_get_int(VCONFKEY_APPSERVICE_STATUS, &value);
1274 if (count >= HEARTBEAT_WAIT_COUNT)
1279 SysLog(NID_APP, "Waiting for app service %dth time(%d msec).", count, interval);
1281 Thread::Sleep(interval);
1289 _AppImpl::SetListener(_AppEvent appEvent, IEventListener* pListener)
1294 SysTryReturnResult(NID_APP, __pCheckpointEventListener == null, E_OBJ_ALREADY_EXIST, "Checkpoint listener is already set.");
1297 case AE_CLEAR_LISTENER:
1298 __pCheckpointEventListener = dynamic_cast <IAppCheckpointEventListener*>(pListener);
1310 _AppImpl::SetSqlDataControlProviderEventListener(ISqlDataControlProviderEventListener* pListener)
1312 __pSqlDataControlProviderEventListener = pListener;
1313 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1314 tmpAppHandlerType |= _APP_HANDLER_DATACONTROL;
1315 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1321 _AppImpl::SetMapDataControlProviderEventListener(IMapDataControlProviderEventListener* pListener)
1323 __pMapDataControlProviderEventListener = pListener;
1324 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1325 tmpAppHandlerType |= _APP_HANDLER_DATACONTROL;
1326 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1332 _AppImpl::SetAppControlProviderEventListener(IAppControlProviderEventListener* pListener)
1334 __pAppControlProviderEventListener = pListener;
1335 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1336 tmpAppHandlerType |= _APP_HANDLER_APPCONTROL;
1337 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1342 _AppImpl::SetAppControlProviderInternalEventListener(IAppControlProviderEventListener* pListener)
1344 __pAppControlProviderInternalEventListener = pListener;
1345 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1346 tmpAppHandlerType |= _APP_HANDLER_APPCONTROL;
1347 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1353 _AppImpl::SetAppLaunchConditionEventListener(IAppLaunchConditionEventListener* pListener)
1355 __pAppLaunchConditionEventListener = pListener;
1356 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1357 tmpAppHandlerType |= _APP_HANDLER_LAUNCH_COND;
1358 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1365 _AppImpl::IsTerminationRequested(void)
1367 return __isTerminationRequested;
1371 _AppImpl::OnPowerOffNotiReceived(void* user_data)
1373 SysLog(NID_APP, "Application is being terminated by power off.");
1375 _AppImpl* pAppImpl = _AppImpl::GetInstance();
1376 if (pAppImpl != null)
1378 pAppImpl->__forcedTermination = true;
1385 _AppImpl::IsForcedTermination(void)
1387 return __forcedTermination;