2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FApp_AppImpl.cpp
20 * @brief This is the implementation for the _AppImpl class.
23 #include <unique_ptr.h>
25 #include <notification/notification.h>
26 #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>
43 #include <FBaseSysLog.h>
44 #include <FIo_RegistryImpl.h>
45 #include <FSys_EnvironmentImpl.h>
46 #include <FSys_PowerManagerImpl.h>
48 #include <FSys_AlarmManager.h>
50 #include "FApp_IAppManager.h"
51 #include "FApp_AppManagerProxy.h"
52 #include "FApp_AppImpl.h"
53 #include "FApp_AppInfo.h"
54 #include "FApp_AppControlManager.h"
55 #include "FApp_AppArg.h"
56 #include "FApp_IAppImpl.h"
57 #include "FApp_AppResourceImpl.h"
59 using namespace Tizen::Base;
60 using namespace Tizen::Base::Collection;
61 using namespace Tizen::Base::Runtime;
62 using namespace Tizen::Io;
63 using namespace Tizen::System;
68 const int HEARTBEAT_WAIT_COUNT = 3;
69 const wchar_t SERVICE_APPID[] = L"aospd00043.osp-app-service";
70 const char SELECTOR_RESPONSE_KEY[] = "__APP_SVC_START_INFO__";
71 const wchar_t FILE_SCHEME_WITH_DELIMITER[] = L"file://";
72 #ifndef VCONFKEY_APPSERVICE_STATUS
73 #define VCONFKEY_APPSERVICE_STATUS "memory/appservice/status"
78 namespace Tizen { namespace App
81 _AppImpl* _AppImpl::__pAppImpl = null;
82 bool _AppImpl::__isTerminationRequested = false;
84 static const int _DATACONTROL_PACKET_INDEX_APPID = 0;
85 static const int _DATACONTROL_PACKET_INDEX_REQUESTTYPE = 1;
86 static const int _DATACONTROL_PACKET_INDEX_REQID = 2;
87 static const int _DATACONTROL_PACKET_INDEX_PROVIDERID = 3;
89 static const int _DATACONTROL_PACKET_INDEX_DATAID = 0;
90 static const int _DATACONTROL_PACKET_INDEX_COLUMNCOUNT = 1;
91 static const int _DATACONTROL_PACKET_INDEX_DELETEWHERE = 1;
92 static const int _DATACONTROL_PACKET_INDEX_MAPKEY = 1;
93 static const int _DATACONTROL_PACKET_INDEX_COLUMNLIST = 2;
94 static const int _DATACONTROL_PACKET_INDEX_INSERTMAP = 2;
95 static const int _DATACONTROL_PACKET_INDEX_UPDATEMAP = 2;
99 void operator()(char* pValue)
109 _AppImpl::_AppImpl(App* pApp)
110 : __pCheckpointEventListener(null)
111 , __pSqlDataControlProviderEventListener(null)
112 , __pMapDataControlProviderEventListener(null)
113 , __pAppControlProviderEventListener(null)
114 , __pAppControlProviderInternalEventListener(null)
115 , __pAppLaunchConditionEventListener(null)
118 , __pRequestHandler(&_AppImpl::HandleAppRequest)
119 , __pLegacyRequestHandler(&_AppImpl::HandleDummyAppRequest)
120 , __forcedTermination(false)
127 _AppImpl::Construct(const IList* pArgs)
129 SysTryReturnResult(NID_APP, pArgs != null, E_INVALID_ARG, "pArguments must not be null.");
130 SysAssertf(__pApp != null, "Getting App instance failed.");
132 result r = __appUserEvent.Construct();
133 SysTryLog(NID_APP, !IsFailed(r), "[%s] User event handler failure.", GetErrorMessage(r));
135 __appUserEvent.AddListener(*this);
137 _AppInfo::SetAppState(INITIALIZING);
144 _AppImpl::Execute(_IAppImpl* pIAppImpl)
146 SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:start]", _AppInfo::GetAppExecutableName().GetPointer());
147 result r = E_SUCCESS;
148 int eflResult = APP_ERROR_NONE;
149 int argc = _AppInfo::GetArgc();
150 char** pArgv = _AppInfo::GetArgv();
151 _IAppManager* pAppManager = null;
153 _AppImpl* pAppImpl = _AppImpl::GetInstance();
154 SysTryReturnResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
155 pAppImpl->__pIAppImpl = pIAppImpl;
157 // handle legacy version handling
158 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
160 pAppImpl->SetLegacyRequestHandler();
163 // clear previous notification
164 // [INFO] behavior change : platform does not clear previous notification
165 notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI);
167 app_event_callback_s state_handler;
168 memset(&state_handler, 0, sizeof(app_event_callback_s));
170 state_handler.create = &OnCreate;
171 state_handler.service = &OnService;
172 state_handler.terminate = &OnTerminate;
173 state_handler.pause = &OnPause;
174 state_handler.resume = &OnResume;
175 state_handler.device_orientation = NULL;
177 state_handler.low_memory = &OnLowMemory;
178 state_handler.low_battery = NULL;
179 state_handler.language_changed = &OnLanguageChanged;
180 state_handler.region_format_changed = &OnRegionFormatChanged;
182 _Aul::SetPowerOffNotiListener(OnPowerOffNotiReceived, this);
183 // if (pAppManager != null)
185 // r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), _AppInfo::GetAppType() , _AppInfo::GetProcessId());
186 // SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Application registration failed.", GetErrorMessage(r));
189 eflResult = app_efl_main(&argc, &pArgv, &state_handler, this);
191 SysTryLog(NID_APP, eflResult == APP_ERROR_NONE, "app_efl_main failed with error (%d): Unknown", eflResult);
193 // clear outstanding ongoing notification
194 notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_ONGOING);
197 pAppManager = _AppManagerProxy::GetService();
199 if (pAppManager != null)
201 pAppManager->UnregisterApplication(_AppInfo::GetProcessId());
209 _AppImpl::OnCreate(void* user_data)
211 SysLog(NID_APP, "Platform creation event.");
213 _AppImpl* pAppImpl = static_cast<_AppImpl*>(user_data);
214 if (pAppImpl == null)
216 _AppInfo::SetAppState(TERMINATED);
217 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Invalid platform state.");
221 _AppInfo::SetAppState(INITIALIZING);
223 if (!ConfirmAppService())
225 _AppInfo::SetAppState(TERMINATED);
226 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] Osp AppService is not running.");
230 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:start]", _AppInfo::GetAppExecutableName().GetPointer());
231 if (!pAppImpl->__pIAppImpl->OnAppInitializing())
233 _AppInfo::SetAppState(TERMINATED);
234 SysLogException(NID_APP, E_INIT_FAILED, "[E_INIT_FAILED] The initialization of your application failed.");
237 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnAppInitializing>:done]", _AppInfo::GetAppExecutableName().GetPointer());
239 SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:start]", _AppInfo::GetAppExecutableName().GetPointer());
240 _IAppManager* pAppManager = _AppManagerProxy::GetService();
242 if (pAppManager != null)
244 result r = pAppManager->RegisterApplication(_AppInfo::GetPackageId(), _AppInfo::GetAppExecutableName(), static_cast<_AppType>(_AppInfo::GetAppType()), _AppInfo::GetProcessId());
245 SysTryLog(NID_APP, !IsFailed(r), "[%s] Application registration failed.", GetErrorMessage(r));
247 SysLogTag(NID_APP, "LAUNCH","[%ls:<RegisterApplication>:done]", _AppInfo::GetAppExecutableName().GetPointer());
248 // hide splash window
250 _PowerManagerImpl::InitBatteryEvent();
257 _AppImpl::OnService(service_s* service, void* user_data)
259 _AppImpl* pAppImpl = _AppImpl::GetInstance();
260 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
261 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
263 // ugly code for app selector event handling
264 bundle* pBundle = _AppArg::GetBundleFromSvc(service);
267 const char* pValue = appsvc_get_data(pBundle, SELECTOR_RESPONSE_KEY);
270 const int req = _AppArg::GetRequestIdFromBundle(pBundle);
272 const char* pOperation = appsvc_get_operation(pBundle);
274 SysLog(NID_APP, "App selector response [%s, %s], req(%d).", pValue, pOperation, req);
276 //_AppArg::Print(pBundle);
277 _AppControlManager::GetInstance()->SendAppControlStartResponse(req, pValue, pOperation);
282 //_AppArg::Print(pBundle);
284 _AppHandler handler = _APP_HANDLER_NONE;
285 pAppImpl->RegisterAppRequest(service, req, handler);
287 bool initialLaunch = false;
290 // (1) AppControl / DataControl provider listener
291 // (2) OnAppInitialized()
292 // (3) OnResume() (OnForeground()) (UiApp only)
293 // (4) OnUserEventReceivedN()
296 // (1) AppControl / DataControl provider listener
297 // (2) OnResume() (OnForeground()) (UiApp only)
298 // (3) OnUserEventReceivedN()
300 if (_AppInfo::GetAppState() == INITIALIZING)
302 initialLaunch = true;
304 unsigned int winId = 0;
305 service_get_window(service, &winId);
308 _AppInfo::GetAppInfo()->SetParentWindowHandle(winId);
309 SysLog(NID_APP, "Saving window handle 0x%x.", winId);
311 // call for callbacks
312 // ptr to member function
313 SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:start]", _AppInfo::GetAppExecutableName().GetPointer());
314 (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
316 if (!pAppImpl->__pIAppImpl->OnAppInitialized())
318 _AppInfo::SetAppState(TERMINATING);
319 SysLog(NID_APP, "[E_INIT_FAILED] The Initialization of your application failed.");
323 SysLogTag(NID_APP, "LAUNCH","[%ls:<RequestHandler and OnAppInitialized>:done]", _AppInfo::GetAppExecutableName().GetPointer());
325 _AppInfo::SetAppState(RUNNING);
327 SysLogTag(NID_APP, "LAUNCH","[%ls:<Initialize Application>:done]", _AppInfo::GetAppExecutableName().GetPointer());
333 // call for callbacks
334 // ptr to member function
335 (pAppImpl->*pAppImpl->__pRequestHandler)(service, req, handler);
337 std::unique_ptr<char[], charDeleter> pOperation(null);
340 int errVal = service_get_operation(service, &pBuf);
341 pOperation.reset(pBuf);
343 if((errVal == SERVICE_ERROR_NONE) && (!strcmp((const char*)pOperation.get(), "osp.operation.ALARM")))
345 std::unique_ptr<char[], charDeleter> pAlarmId(null);
348 errVal = service_get_extra_data(service, SERVICE_DATA_ALARM_ID, &pBuf);
349 pAlarmId.reset(pBuf);
350 SysTryReturnVoidResult(NID_SYS, errVal == SERVICE_ERROR_NONE, E_SYSTEM, "It is failed to get reserved alarm id.");
351 int alarmId = atoi((const char*)pAlarmId.get());
353 _AlarmManager* pAlarmManager = _AlarmManager::GetInstance();
354 pAlarmManager->OnAlarmExpired(alarmId);
360 pAppImpl->__pIAppImpl->OnService(service, initialLaunch);
362 // ptr to member function
363 (pAppImpl->*pAppImpl->__pLegacyRequestHandler)(service, req, handler);
368 _AppImpl::OnTerminate(void* user_data)
370 SysLog(NID_APP, "Termination event 0x%x state", _AppInfo::GetAppState());
372 _AppImpl* pAppImpl = _AppImpl::GetInstance();
373 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
374 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
376 __isTerminationRequested = true;
377 pAppImpl->__pIAppImpl->OnTerminate();
382 _AppImpl::OnResume(void* user_data)
384 SysLog(NID_APP, "System resume event on 0x%x state", _AppInfo::GetAppState());
385 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnResume>:start]", _AppInfo::GetAppExecutableName().GetPointer());
387 _AppImpl* pAppImpl = _AppImpl::GetInstance();
388 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
389 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
390 pAppImpl->__pIAppImpl->OnResume();
391 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnResume>:done]", _AppInfo::GetAppExecutableName().GetPointer());
396 _AppImpl::OnPause(void* user_data)
398 SysLog(NID_APP, "System pause event on 0x%x state", _AppInfo::GetAppState());
399 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnPause>:start]", _AppInfo::GetAppExecutableName().GetPointer());
401 _AppImpl* pAppImpl = _AppImpl::GetInstance();
402 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
403 SysTryReturnVoidResult(NID_APP, pAppImpl->__pIAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
404 pAppImpl->__pIAppImpl->OnPause();
405 pAppImpl->OnAppCheckpoint();
406 SysLogTag(NID_APP, "LAUNCH","[%ls:<OnPause>:done]", _AppInfo::GetAppExecutableName().GetPointer());
410 _AppImpl::~_AppImpl(void)
417 _AppImpl::GetInstance(void)
424 _AppImpl::GetAppInstance(void)
431 _AppImpl::GetAppArgumentListN(void) const
433 ArrayList* pList = null;
434 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(0);
438 pList = pArg->GetArgListN(0);
443 pList = new (std::nothrow) ArrayList();
444 SysTryReturn(NID_APP, pList != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
445 String* pData = new (std::nothrow) String(LEGACY_LAUNCH_REASON_NORMAL);
446 SysTryReturn(NID_APP, pData != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
447 String* pData2 = new (std::nothrow) String(L"osp.operation.MAIN");
448 SysTryReturn(NID_APP, pData2 != null, null, E_OUT_OF_MEMORY, "ArrayList creation failure.");
460 _AppImpl::Terminate(void)
462 result r = E_SUCCESS;
464 __isTerminationRequested = true;
472 _AppImpl::OnAppInitializing(void)
479 _AppImpl::OnAppWillTerminate(void)
481 SysTryReturn(NID_APP, __pApp != null, false, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
483 return __pApp->OnAppWillTerminate();
488 _AppImpl::RegisterAppRequest(service_s* service, int& req, _AppHandler& handler)
490 _AppControlManager* pManager = _AppControlManager::GetInstance();
491 SysTryReturnResult(NID_APP, pManager != null, E_SYSTEM, "Wrong system state.");
493 result r = pManager->RegisterRequest(service, req, handler);
494 SysTryReturn(NID_APP, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
496 int providerType = _AppInfo::GetAppHandlerType();
497 providerType |= (_APP_HANDLER_LAUNCH_NORMAL | _APP_HANDLER_LAUNCH_COND);
499 SysTryLog(NID_APP, (handler & providerType) != 0, "Request 0x%x received for 0x%x.", handler,
500 _AppInfo::GetAppHandlerType());
506 _AppImpl::HandleAppRequest(service_s* service, int req, _AppHandler handler)
508 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(req);
509 SysTryReturnResult(NID_APP, pArg != null, E_SYSTEM, "No argument found for %d.", req);
515 case _APP_HANDLER_DATACONTROL:
516 SysLog(NID_APP, "Handling DataControl request");
518 OnDataControlRequestReceived(*pArg, static_cast< RequestId >(req));
520 _AppControlManager::GetInstance()->RemoveResultRequest(req);
523 case _APP_HANDLER_LAUNCH_COND:
524 SysLog(NID_APP, "Handling conditional launch request");
526 OnConditionRequestReceived(*pArg, static_cast< RequestId >(req));
530 SysLog(NID_APP, "Handling AppControl request");
532 OnAppControlRequestReceived(*pArg, static_cast< RequestId >(req));
541 _AppImpl::HandleLegacyAppRequest(service_s* service, int req, _AppHandler handler)
543 const _AppArg* pArg = _AppControlManager::GetInstance()->FindResultRequest(0);
544 SysTryReturnResult(NID_APP, pArg != null, E_SYSTEM, "No argument found for %d.", req);
550 case _APP_HANDLER_LAUNCH_NORMAL:
551 SysLog(NID_APP, "Handling normal launch request");
552 OnUserEventReceivedN(AppLaunchRequestId, pArg->GetArgListN(req));
554 // [TODO] request handle memory cleanup confirm
555 _AppControlManager::GetInstance()->RemoveResultRequest(req);
558 case _APP_HANDLER_LAUNCH_COND:
559 SysLog(NID_APP, "Handling conditional launch request");
561 OnUserEventReceivedN(AppLaunchRequestId, pArg->GetArgListN(req));
563 // [TODO] request handle memory cleanup confirm
564 _AppControlManager::GetInstance()->RemoveResultRequest(req);
576 _AppImpl::HandleDummyAppRequest(service_s* service, int req, _AppHandler handler)
578 SysLog(NID_APP, "Dummy handler");
585 _AppImpl::SetLegacyRequestHandler(void)
587 SysLog(NID_APP, "Setting request handler for legacy application.");
589 __pRequestHandler = &_AppImpl::HandleDummyAppRequest;
590 __pLegacyRequestHandler = &_AppImpl::HandleLegacyAppRequest;
597 _AppImpl::OnLowMemory(void* user_data)
599 _AppImpl* pAppImpl = _AppImpl::GetInstance();
601 SysTryReturnVoidResult(NID_APP, pAppImpl != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
602 SysTryReturnVoidResult(NID_APP, pAppImpl->__pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
604 if (_AppInfo::GetAppState() == RUNNING)
606 pAppImpl->__pApp->OnLowMemory();
612 _AppImpl::OnBatteryLevelChanged(BatteryLevel batteryLevel)
614 SysTryReturnVoidResult(NID_APP, __pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
616 __pApp->OnBatteryLevelChanged(batteryLevel);
620 _AppImpl::OnLanguageChanged(void* user_data)
623 _AppInfo::UpdatePackageInfo(true);
625 _AppResourceImpl::Reinitialize();
626 SysLog(NID_APP, "Language change done.");
630 _AppImpl::OnRegionFormatChanged(void* user_data)
632 // Osp doesn't implement this callback.
637 _AppImpl::SendUserEvent(RequestId requestId, const IList* pArgs)
639 _AppUserEventArg* pArg = new (std::nothrow) _AppUserEventArg(requestId, pArgs);
640 SysTryReturnResult(NID_APP, pArg != null, E_OUT_OF_MEMORY, "User event creation failure for %d.", requestId);
642 result r = __appUserEvent.FireAsync(*pArg);
649 _AppImpl::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
651 SysTryReturnVoidResult(NID_APP, __pApp != null, E_INVALID_STATE, "[E_INVALID_STATE] Getting internal instance failed.");
653 __pApp->OnUserEventReceivedN(requestId, pArgs);
658 _AppImpl::OnAppControlRequestReceived(const _AppArg& arg, RequestId reqId)
660 IAppControlProviderEventListener* pAppControlProviderEventListener = null;
662 const String internalOperation = arg.GetValue(OSP_K_APPCONTROL_INTERNAL_OPERATION);
663 if( !internalOperation.IsEmpty() )
665 SysLog(NID_APP, "internalOperation:%ls", internalOperation.GetPointer() );
666 pAppControlProviderEventListener = __pAppControlProviderInternalEventListener;
670 pAppControlProviderEventListener = __pAppControlProviderEventListener;
673 if( pAppControlProviderEventListener == null)
675 SysLog(NID_APP, "No AppControl provider event listener set for request %d.", reqId);
679 const String& appId = _AppInfo::GetApplicationId();
681 const char* p = appsvc_get_operation(arg.GetBundle());
682 String operationId = (p) ? String(p) : TIZEN_OPERATION_MAIN;
683 if (operationId == L"http://tizen.org/appcontrol/operation/default")
685 operationId = TIZEN_OPERATION_MAIN;
688 SysLog(NID_APP, "AppControl (%ls, %ls).", appId.GetPointer(), operationId.GetPointer());
692 const String* pUri = null;
693 const String* pMime = null;
694 p = appsvc_get_uri(arg.GetBundle());
700 // SLP deals with the URI as plain /opt/.../a.jpg.
701 uri.Insert(FILE_SCHEME_WITH_DELIMITER, 0);
705 SysLog(NID_APP, "Delivered uri is [%ls].", pUri->GetPointer());
708 p = appsvc_get_mime(arg.GetBundle());
715 std::unique_ptr<HashMap> pMap(arg.GetArgMapN());
717 pAppControlProviderEventListener->OnAppControlRequestReceived(reqId, operationId, pUri, pMime, pMap.get());
719 SysLog(NID_APP, "AppControl (%ls, %ls) invocation finished.", appId.GetPointer(), operationId.GetPointer());
724 _AppImpl::OnDataControlRequestReceived(const _AppArg& arg, RequestId reqId)
727 ISqlDataControlProviderEventListener* pSqlListener = null;
728 IMapDataControlProviderEventListener* pMapListener = null;
729 ArrayList* pColumnList = null;
730 HashMap* pInsertMap = null;
731 HashMap* pUpdateMap = null;
736 String* pDataId = null;
738 String* pColumnCount = null;
739 String* pColumn = null;
740 String* pValue = null;
741 String* pWhere = null;
742 String* pOrder = null;
743 String* pErrorMsg = null;
745 String* pCount = null;
746 String* pTmpPath = null;
747 String empty(L"NULL");
750 _DataControlRequestType requestType = _DATACONTROL_REQUEST_TYPE_UNDEFINED;
753 int countPerPage = 0;
756 result r = E_SUCCESS;
757 result res = E_SUCCESS;
758 ArrayList* pList = null;
760 String* pNewValue = null;
761 String* pOldValue = null;
763 SysLog(NID_APP, "[DC_PROV_RECV] Data control request is received.");
764 //arg.Print(); // request info
767 appId = arg.GetCallerAppId();
769 reqType = arg.GetValue(OSP_K_DATACONTROL_REQUEST_TYPE);
770 Integer::Parse(reqType, type);
771 requestType = static_cast< _DataControlRequestType >(type);
773 version = arg.GetValue(OSP_K_DATACONTROL_PROTOCOL_VERSION);
774 callerReqId = arg.GetValue(OSP_K_REQUEST_ID);
775 providerId = arg.GetValue(OSP_K_DATACONTROL_PROVIDER);
777 // list-based request
778 pList = _AppArg::GetListN(arg.GetBundle(), OSP_K_ARG);
779 SysTryCatch(NID_APP, pList, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid result object");
781 pDataId = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_DATAID));// request list[0]: data ID
782 SysTryCatch(NID_APP, pDataId, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
784 if (requestType >= _DATACONTROL_REQUEST_TYPE_SQL_QUERY && requestType <= _DATACONTROL_REQUEST_TYPE_SQL_DELETE)
786 pSqlListener = __pSqlDataControlProviderEventListener;
787 SysTryCatch(NID_APP, pSqlListener != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
789 else if (requestType >= _DATACONTROL_REQUEST_TYPE_MAP_QUERY && requestType <= _DATACONTROL_REQUEST_TYPE_MAP_DELETE)
791 pKey = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_MAPKEY)); // request list[1]
792 SysTryCatch(NID_APP, pKey, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
794 pMapListener = __pMapDataControlProviderEventListener;
795 SysTryCatch(NID_APP, pMapListener != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
799 SysLogException(NID_APP, E_SYSTEM, "[E_SYSTEM] invalid request");
805 case _DATACONTROL_REQUEST_TYPE_SQL_QUERY:
806 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl SELECT");
808 // request list[1]: selected column count
809 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
810 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
812 if (pColumnCount->Equals(empty) == true)
818 Integer::Parse(*pColumnCount, columnCount);
819 pColumnList = new (std::nothrow) ArrayList();
820 SysTryReturnVoidResult(NID_APP, pColumnList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
821 pColumnList->Construct();
822 SysLog(NID_APP, "[DC_PROV_RECV] selected column count: %d", columnCount);
825 while (i < columnCount) // request list[2]: column list
827 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNLIST + i));
828 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
830 pColumnList->Add(*(new String(*pColumn)));
831 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", i, pColumn->GetPointer());
836 i += _DATACONTROL_PACKET_INDEX_COLUMNLIST;
837 pWhere = dynamic_cast< String* >(pList->GetAt(i)); // request list: where clause
838 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
840 if (pWhere->Equals(empty) == true)
846 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
850 pOrder = dynamic_cast< String* >(pList->GetAt(i)); // request list: order clause
851 SysTryCatch(NID_APP, pOrder, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
853 if (pOrder->Equals(empty) == true)
859 SysLog(NID_APP, "[DC_PROV_RECV] pOrder: %ls", pOrder->GetPointer());
863 pNo = dynamic_cast <String*>(pList->GetAt(i)); // request list: page number
864 SysTryCatch(NID_APP, pNo, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
865 Integer::Parse(*pNo, pageNo);
868 pCount = dynamic_cast <String*>(pList->GetAt(i)); // request list: count per page
869 SysTryCatch(NID_APP, pCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
870 Integer::Parse(*pCount, countPerPage);
872 pSqlListener->OnSqlDataControlSelectRequestReceived(reqId, providerId, *pDataId, pColumnList,
875 SysLog(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",
876 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
877 pDataId->GetPointer(), pColumnList, pWhere, pOrder, pageNo, countPerPage);
879 case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
880 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl INSERT");
882 // request list[1]: inserted column count
883 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
884 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
886 Integer::Parse(*pColumnCount, columnCount);
887 SysLog(NID_APP, "[DC_PROV_RECV] inserted column count: %d", columnCount);
889 pInsertMap = new (std::nothrow) HashMap();
890 SysTryReturnVoidResult(NID_APP, pInsertMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
891 pInsertMap->Construct();
893 SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
894 if (version == L"ver_2.1.0.2")
896 pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
897 SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
898 SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
901 r = request.Construct(*pTmpPath, "r");
902 SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
903 GetErrorMessage(r), pTmpPath->GetPointer());
905 for (i = 0; i < columnCount; ++i) // column-value pairs
908 int ret = request.Read(&length, sizeof(int));
909 SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
910 GetErrorMessage(GetLastResult()));
912 char* pColumn = new (std::nothrow) char[length + 1];
913 ret = request.Read(pColumn, length);
914 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
915 GetErrorMessage(GetLastResult()));
916 pColumn[length] = '\0';
917 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
919 ret = request.Read(&length, sizeof(int));
920 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
921 GetErrorMessage(GetLastResult()));
923 char* pValue = new (std::nothrow) char[length + 1];
924 ret = request.Read(pValue, length);
927 SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
931 pValue[length] = '\0';
932 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
934 pInsertMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
943 while (i < columnCount * 2) // request list: column-value pairs
945 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
946 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
947 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
949 pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_INSERTMAP + i++));
950 SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
951 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
953 pInsertMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
960 r = File::Remove(*pTmpPath);
961 SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
964 pSqlListener->OnSqlDataControlInsertRequestReceived(reqId, providerId, *pDataId, *pInsertMap);
966 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pInsertMap: 0x%x",
967 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
968 pDataId->GetPointer(), pInsertMap);
970 case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE:
971 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl UPDATE");
973 // request list[1]: updated column count
974 pColumnCount = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_COLUMNCOUNT));
975 SysTryCatch(NID_APP, pColumnCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
977 Integer::Parse(*pColumnCount, columnCount);
978 SysLog(NID_APP, "[DC_PROV_RECV] updated column count: %d", columnCount);
980 pUpdateMap = new (std::nothrow) HashMap();
981 SysTryReturnVoidResult(NID_APP, pUpdateMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
982 pUpdateMap->Construct();
984 SysLog(NID_APP, "[DC_PROV_RECV] version: %ls", version.GetPointer());
985 if (version == L"ver_2.1.0.2")
987 pTmpPath = dynamic_cast< String* >(pList->GetAt(2)); // request list[2]: path
988 SysTryCatch(NID_APP, pTmpPath != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
989 SysLog(NID_APP, "[DC_PROV_RECV] request: %ls", pTmpPath->GetPointer());
992 r = request.Construct(*pTmpPath, "r");
993 SysTryCatch(NID_APP, !IsFailed(r), , E_SYSTEM, "[%s] Failed to open request (%ls).",
994 GetErrorMessage(r), pTmpPath->GetPointer());
996 for (i = 0; i < columnCount; ++i) // column-value pairs
999 int ret = request.Read(&length, sizeof(int));
1000 SysTryCatch(NID_APP, ret > 0, , E_SYSTEM, "[%s] Failed to receive request.",
1001 GetErrorMessage(GetLastResult()));
1003 char* pColumn = new (std::nothrow) char[length + 1];
1004 ret = request.Read(pColumn, length);
1005 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
1006 GetErrorMessage(GetLastResult()));
1007 pColumn[length] = '\0';
1008 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %s", i, pColumn);
1010 ret = request.Read(&length, sizeof(int));
1011 SysTryCatch(NID_APP, ret > 0, delete pColumn, E_SYSTEM, "[%s] Failed to receive request.",
1012 GetErrorMessage(GetLastResult()));
1014 char* pValue = new (std::nothrow) char[length + 1];
1015 ret = request.Read(pValue, length);
1018 SysLogException(NID_APP, E_SYSTEM, "[%s] Failed to receive request.", GetErrorMessage(GetLastResult()));
1022 pValue[length] = '\0';
1023 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %s", i, pValue);
1025 pUpdateMap->Add(new (std::nothrow) String(pColumn), new (std::nothrow) String(pValue));
1030 // request list: where clause
1031 pWhere = dynamic_cast< String* >(pList->GetAt(3));
1032 SysTryCatch(NID_APP, pWhere != null, , E_SYSTEM, "[E_SYSTEM] invalid request");
1038 while (i < columnCount * 2) // request list: column-value pairs
1040 pColumn = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
1041 SysTryCatch(NID_APP, pColumn != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1042 SysLog(NID_APP, "[DC_PROV_RECV] column[%d]: %ls", index, pColumn->GetPointer());
1044 pValue = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i++));
1045 SysTryCatch(NID_APP, pValue != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1046 SysLog(NID_APP, "[DC_PROV_RECV] value[%d]: %ls", index, pValue->GetPointer());
1048 pUpdateMap->Add(new (std::nothrow) String(*pColumn), new (std::nothrow) String(*pValue));
1052 // request list: where clause
1053 pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_UPDATEMAP + i));
1054 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1057 if (pWhere->Equals(empty) == true)
1063 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
1068 r = File::Remove(*pTmpPath);
1069 SysTryLog(NID_APP, !IsFailed(r), "Failed to remove result: %ls", pTmpPath->GetPointer());
1072 pSqlListener->OnSqlDataControlUpdateRequestReceived(reqId, providerId, *pDataId, *pUpdateMap, pWhere);
1074 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pUpdateMap: 0x%x, pWhere: 0x%x",
1075 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1076 pDataId->GetPointer(), pUpdateMap, pWhere);
1078 case _DATACONTROL_REQUEST_TYPE_SQL_DELETE:
1079 SysLog(NID_APP, "[DC_PROV_RECV] SqlDataControl DELETE");
1081 // request list[1]: where clause
1082 pWhere = dynamic_cast< String* >(pList->GetAt(_DATACONTROL_PACKET_INDEX_DELETEWHERE));
1083 SysTryCatch(NID_APP, pWhere, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1085 if (pWhere->Equals(empty) == true)
1091 SysLog(NID_APP, "[DC_PROV_RECV] pWhere: %ls", pWhere->GetPointer());
1094 pSqlListener->OnSqlDataControlDeleteRequestReceived(reqId, providerId, *pDataId, pWhere);
1096 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, pWhere: 0x%x",
1097 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1098 pDataId->GetPointer(), pWhere);
1100 case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
1101 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl GetValue");
1103 pNo = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1104 SysTryCatch(NID_APP, pNo, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1105 Integer::Parse(*pNo, pageNo);
1107 pCount = dynamic_cast <String*>(pList->GetAt(3)); // request list[3]
1108 SysTryCatch(NID_APP, pCount, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1109 Integer::Parse(*pCount, countPerPage);
1111 pMapListener->OnMapDataControlGetValueRequestReceived(reqId, providerId, *pDataId, *pKey);
1113 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, pageNo: %d, countPerPage: %d",
1114 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1115 pDataId->GetPointer(), pKey->GetPointer(), pageNo, countPerPage);
1117 case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
1118 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl AddValue");
1120 pValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1121 SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1123 pMapListener->OnMapDataControlAddValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pValue);
1125 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, value: %ls",
1126 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1127 pDataId->GetPointer(), pKey->GetPointer(), pValue->GetPointer());
1129 case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
1130 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl SetValue");
1132 pOldValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1133 SysTryCatch(NID_APP, pOldValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1135 pNewValue = dynamic_cast <String*>(pList->GetAt(3)); // request list[3]
1136 SysTryCatch(NID_APP, pNewValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1138 pMapListener->OnMapDataControlSetValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pOldValue, *pNewValue);
1140 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, oldValue: %ls, newValue: %ls",
1141 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1142 pDataId->GetPointer(), pKey->GetPointer(), pOldValue->GetPointer(), pNewValue->GetPointer());
1144 case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
1145 SysLog(NID_APP, "[DC_PROV_RECV] MapDataControl RemoveValue");
1147 pValue = dynamic_cast <String*>(pList->GetAt(2)); // request list[2]
1148 SysTryCatch(NID_APP, pValue, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1150 pMapListener->OnMapDataControlRemoveValueRequestReceived(reqId, providerId, *pDataId, *pKey, *pValue);
1152 SysLog(NID_APP, "[DC_PROV_RECV] caller app: %ls, requestType: %d, caller req: %ls, provider: %ls, data: %ls, key: %ls, value: %ls",
1153 appId.GetPointer(), requestType, callerReqId.GetPointer(), providerId.GetPointer(),
1154 pDataId->GetPointer(), pKey->GetPointer(), pValue->GetPointer());
1157 SysTryCatch(NID_APP, false, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] invalid request");
1163 pColumnList->RemoveAll(true);
1169 pInsertMap->RemoveAll(true);
1175 pUpdateMap->RemoveAll(true);
1184 pErrorMsg = new (std::nothrow) String("[E_SYSTEM] A system error has occurred.");
1186 else if (r == E_OUT_OF_MEMORY)
1188 pErrorMsg = new (std::nothrow) String("[E_OUT_OF_MEMORY] The memory was insufficient.");
1190 SysTryReturnVoidResult(NID_APP, pErrorMsg, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory was insufficient.");
1192 res = DataControlProviderManager::GetInstance()->SendDataControlError(reqId, *pErrorMsg);
1196 pColumnList->RemoveAll(true);
1202 pInsertMap->RemoveAll(true);
1208 pUpdateMap->RemoveAll(true);
1219 _AppImpl::OnConditionRequestReceived(const _AppArg& arg, RequestId reqId)
1221 if (__pAppLaunchConditionEventListener == null)
1223 SysLog(NID_APP, "No App launch condition event listener");
1227 String condition = arg.GetValue(OSP_K_COND);
1228 //Object* pExtraData = null;//TODO: retrieve NFC extra data.
1229 HashMap* pExtraData = arg.GetArgMapN();
1230 ArrayList* pList = arg.GetArgListN();
1232 __pAppLaunchConditionEventListener->OnAppLaunchConditionMetN(condition, pExtraData, pList);
1237 _AppImpl::GetWindowHandle(void) const
1239 SysTryReturn(NID_APP, __pIAppImpl != null, -1, E_INVALID_STATE, "[E_INVALID_STATE] Getting App instance failed.");
1241 return __pIAppImpl->OnWindowHandleRequest();
1246 _AppImpl::OnAppCheckpoint(void)
1248 if (__pCheckpointEventListener)
1250 __pCheckpointEventListener->OnAppCheckpointing(*(AppRegistry::GetInstance()));
1256 _AppImpl::ConfirmAppService(void)
1258 if (_AppInfo::GetApplicationId() == SERVICE_APPID)
1265 long interval = 100;
1269 int res = vconf_get_int(VCONFKEY_APPSERVICE_STATUS, &value);
1275 if (count >= HEARTBEAT_WAIT_COUNT)
1280 SysLog(NID_APP, "Waiting for app service %dth time(%d msec).", count, interval);
1282 Thread::Sleep(interval);
1290 _AppImpl::SetListener(_AppEvent appEvent, IEventListener* pListener)
1295 SysTryReturnResult(NID_APP, __pCheckpointEventListener == null, E_OBJ_ALREADY_EXIST, "Checkpoint listener is already set.");
1298 case AE_CLEAR_LISTENER:
1299 __pCheckpointEventListener = dynamic_cast <IAppCheckpointEventListener*>(pListener);
1311 _AppImpl::SetSqlDataControlProviderEventListener(ISqlDataControlProviderEventListener* pListener)
1313 __pSqlDataControlProviderEventListener = pListener;
1314 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1315 tmpAppHandlerType |= _APP_HANDLER_DATACONTROL;
1316 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1322 _AppImpl::SetMapDataControlProviderEventListener(IMapDataControlProviderEventListener* pListener)
1324 __pMapDataControlProviderEventListener = pListener;
1325 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1326 tmpAppHandlerType |= _APP_HANDLER_DATACONTROL;
1327 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1333 _AppImpl::SetAppControlProviderEventListener(IAppControlProviderEventListener* pListener)
1335 __pAppControlProviderEventListener = pListener;
1336 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1337 tmpAppHandlerType |= _APP_HANDLER_APPCONTROL;
1338 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1343 _AppImpl::SetAppControlProviderInternalEventListener(IAppControlProviderEventListener* pListener)
1345 __pAppControlProviderInternalEventListener = pListener;
1346 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1347 tmpAppHandlerType |= _APP_HANDLER_APPCONTROL;
1348 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1354 _AppImpl::SetAppLaunchConditionEventListener(IAppLaunchConditionEventListener* pListener)
1356 __pAppLaunchConditionEventListener = pListener;
1357 int tmpAppHandlerType = _AppInfo::GetAppHandlerType();
1358 tmpAppHandlerType |= _APP_HANDLER_LAUNCH_COND;
1359 _AppInfo::SetAppHandlerType(tmpAppHandlerType);
1366 _AppImpl::IsTerminationRequested(void)
1368 return __isTerminationRequested;
1372 _AppImpl::OnPowerOffNotiReceived(void* user_data)
1374 SysLog(NID_APP, "Application is being terminated by power off.");
1376 _AppImpl* pAppImpl = _AppImpl::GetInstance();
1377 if (pAppImpl != null)
1379 pAppImpl->__forcedTermination = true;
1386 _AppImpl::IsForcedTermination(void)
1388 return __forcedTermination;